Skip to content

Commit 1ce5d7b

Browse files
committed
Closes #6, Closes #7
1 parent 78f26ca commit 1ce5d7b

File tree

7 files changed

+16
-17
lines changed

7 files changed

+16
-17
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FROM metabase/metabase:v0.36.2
22

33
ADD --chown=2000:2000 \
4-
https://github.com/bbenzikry/metabase-neo4j-driver/releases/download/v0.0.4/neo4j.metabase-driver.jar \
4+
https://github.com/bbenzikry/metabase-neo4j-driver/releases/download/v0.0.5/neo4j.metabase-driver.jar \
55
/plugins/neo4j.neo4j-driver.jar

deps.edn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
{:deps {bbenzikry/neo4clj {:git/url "https://github.com/bbenzikry/neo4clj" :sha "6384a47a34378d528f29cdb5c62b68de4a6c48c5"}
1+
{:deps {bbenzikry/neo4clj {:git/url "https://github.com/bbenzikry/neo4clj" :sha "6b0f55cd37fd5e11f08288641da820b0f9e4ca21"}
22
neo4j/neo4j-bi-jdbc {:mvn/version "1.0.0"}
33
org.neo4j/neo4j-cypher {:mvn/version "4.1.1"}}}

project.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(defproject metabase/neo4j-driver "0.0.4-SNAPSHOT-neo4j-connector-1.0.0"
1+
(defproject metabase/neo4j-driver "0.0.5-SNAPSHOT-neo4j-connector-1.0.0"
22
:min-lein-version "2.5.0"
33
; git repo support
44
:plugins [[lein-tools-deps "0.4.5"]]

resources/metabase-plugin.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# see: https://github.com/metabase/metabase/wiki/Metabase-Plugin-Manifest-Reference
22
info:
33
name: Metabase Neo4j Driver
4-
version: 0.0.4-SNAPSHOT
4+
version: 0.0.5-SNAPSHOT
55
description: Allows Metabase to connect to Neo4j.
66
driver:
77
name: neo4j
@@ -24,6 +24,10 @@ driver:
2424
- merge:
2525
- password
2626
- default: default
27+
- name: protocol
28+
display-name: Protocol
29+
description: One of bolt,bolt+s,bolt+ssc,neo4j,neo4j+s,neo4j+ssc
30+
default: bolt
2731
- merge:
2832
- additional-options
2933
- name: jdbc-flags

src/metabase/driver/neo4j.clj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
(driver/register! :neo4j, :parent :sql-jdbc)
2121
(defmethod driver/display-name :neo4j [_] "Neo4j 4")
22-
22+
(def accepted-neo-protocols (sorted-set "bolt" "bolt+s" "bolt+ssc" "neo4j" "neo4j+s" "neo4j+ssc"))
2323
(defn- make-subname [host port db jdbc-flags]
2424
(str "//" host ":" port "/" db jdbc-flags))
2525

@@ -128,6 +128,8 @@
128128

129129
(defmethod sql-jdbc.conn/connection-details->spec :neo4j
130130
[_ details]
131+
(when-not (contains? accepted-neo-protocols (:protocol details))
132+
(throw (Exception. (str "Protocol must be one of " (clojure.string/join ", " accepted-neo-protocols)))))
131133
(-> details
132134
(update :port (fn [port]
133135
(if (string? port)
@@ -154,7 +156,7 @@
154156
(try
155157
(log/info "Received neo4j query. Checking if cypher ❓")
156158
(.parse cypher-parser query cypher-exception-factory nil)
157-
true (catch Throwable ex (log/info ex) false)))
159+
true (catch Throwable ex (log/debug ex) false)))
158160

159161
(defmethod driver/execute-reducible-query :neo4j
160162
[driver query chans respond]

src/metabase/driver/neo4j/execute.clj

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,6 @@
3737
results-metadata {:cols (sql-jdbc.execute/column-metadata driver rsmeta)}]
3838
(respond results-metadata (sql-jdbc.execute/reducible-rows driver rs rsmeta (context/canceled-chan context)))))))
3939

40-
; TODO add with-neo4j-connection macro
41-
(defn get-neo-connection
42-
[{host :host port :port user :user password :password dbname :dbname}]
43-
(let [base (str "bolt://" host ":" port)
44-
url (if dbname (str base "/" dbname) base)]
45-
(if password (neo4j/connect url user password) (neo4j/connect url user))))
46-
4740
(defn get-cypher-columns [result]
4841
(if (seq? result)
4942
{:cols (into [] (map #(assoc {} :name %) (keys (first (take 1 result)))))}
@@ -54,7 +47,8 @@
5447
[_ {{query :query} :native} context respond]
5548
(log/info "Executing reducible query for cypher")
5649
(with-neo-connection [^Driver connection (:details (qp.store/database))]
57-
(let [results (volatile! (neo4j/execute! connection query))
50+
(let [dbname (:dbname (:details (qp.store/database)))
51+
results (volatile! (neo4j/execute! connection dbname query))
5852
nonseq-val (volatile! false)
5953
columns (get-cypher-columns @results)
6054
row-thunk #(if-not (seq? @results) ((if-not @nonseq-val (vreset! nonseq-val true) @results) nil)

src/metabase/driver/neo4j/util.clj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414
nil)
1515

1616
(defn get-neo-connection
17-
[{host :host port :port user :user password :password dbname :dbname}]
18-
(let [base (str "bolt://" host ":" port)
19-
url (if dbname (str base "/" dbname) base)]
17+
[{host :host port :port user :user password :password protocol :protocol}]
18+
(let [url (str protocol "://" host ":" port)]
2019
(if password (neo4j/connect url user password) (neo4j/connect url user))))
2120

2221
(defn -with-neo-connection

0 commit comments

Comments
 (0)