From 1f42aad23e6cbd8bdebaa33677a7b32fec1b4e49 Mon Sep 17 00:00:00 2001 From: Josha von Gizycki Date: Mon, 4 Jan 2021 16:56:13 +0100 Subject: [PATCH] replace old param syntax --- .gitignore | 1 + src/wanijo/infrastructure/repl.clj | 4 +-- src/wanijo/link/db.clj | 12 ++++---- src/wanijo/schema/db.clj | 48 +++++++++++++++--------------- src/wanijo/user/db.clj | 11 ++++--- src/wanijo/visualisation/db.clj | 2 +- 6 files changed, 39 insertions(+), 39 deletions(-) diff --git a/.gitignore b/.gitignore index e84b3bc..0903fd2 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ resources/public/js/out .rebel_readline_history /elm-stuff *.*~ +*#* diff --git a/src/wanijo/infrastructure/repl.clj b/src/wanijo/infrastructure/repl.clj index ea42587..040fa19 100644 --- a/src/wanijo/infrastructure/repl.clj +++ b/src/wanijo/infrastructure/repl.clj @@ -19,13 +19,13 @@ (neo4j/defquery init-config "MERGE (c:dbconfig) ON CREATE SET - c.installed_at = {now}, + c.installed_at = $now, c.db_version = 0, c.last_migration = ''") (neo4j/defquery merge-config "MATCH (c:dbconfig) - SET c.last_migration = {now}, + SET c.last_migration = $now, c.db_version = {version}") (neo4j/defquery config diff --git a/src/wanijo/link/db.clj b/src/wanijo/link/db.clj index 9b5ca2a..3f73841 100644 --- a/src/wanijo/link/db.clj +++ b/src/wanijo/link/db.clj @@ -9,13 +9,13 @@ ::name])) (neo4j/defquery create - "MATCH (i:instance {uuid:{from}}), - (t:instance {uuid:{target}}) + "MATCH (i:instance {uuid: $from}), + (t:instance {uuid: $target}) CREATE (i)-[l:link]->(t) - SET l.created_at = {created_at}, - l.name = {name}, - l.created_by = {by}, - l.uuid = {uuid}") + SET l.created_at = $created_at, + l.name = $name, + l.created_by = $by, + l.uuid = $uuid") (defn create! [{:keys [from name to by]}] (let [tuples (map (fn [target-uuid] [create diff --git a/src/wanijo/schema/db.clj b/src/wanijo/schema/db.clj index ebe793d..2dbf976 100644 --- a/src/wanijo/schema/db.clj +++ b/src/wanijo/schema/db.clj @@ -24,11 +24,11 @@ (neo4j/defquery create-new "MATCH (u:user) - WHERE u.uuid = {u_uuid} + WHERE u.uuid = $u_uuid CREATE (s:schema)-[:created_by]->(u) - SET s.name = {name} - SET s.uuid = {s_uuid} - SET s.created_at = {created_at} + SET s.name = $name + SET s.uuid = $s_uuid + SET s.created_at = $created_at RETURN s") (defn create-new! [schema-name user-uuid] (->> @@ -43,7 +43,7 @@ (neo4j/defquery find-by-uuid "MATCH (s:schema) - WHERE s.uuid = {uuid} + WHERE s.uuid = $uuid OPTIONAL MATCH (s)<-[:of]-(a:attribute) WHERE a.required = 1 @@ -60,13 +60,13 @@ :req-attrs (map :a result))))) (neo4j/defquery schema-permissions - "MATCH (s:schema {uuid:{schema_uuid}}) + "MATCH (s:schema {uuid: $schema_uuid}) RETURN - EXISTS((:user {uuid:{user_uuid}}) - -[:permission {type:{type}}]- + EXISTS((:user {uuid: $user_uuid}) + -[:permission {type: $type}]- (s)) AS user_has_permission, NOT EXISTS((:user) - -[:permission {type:{type}}]- + -[:permission {type: $type}]- (s)) AS is_public") (defn has-user-permission? [perm-type schema-uuid user-uuid] (let [perms (first @@ -82,7 +82,7 @@ (neo4j/defquery accessible-schemas "MATCH (s:schema), - (u:user {uuid:{user_uuid}}) + (u:user {uuid: $user_uuid}) WHERE EXISTS((u)-[:permission {type:'read'}]->(s)) OR NOT EXISTS((:user)-[:permission {type:'read'}]->(s)) WITH s @@ -100,7 +100,7 @@ {:user_uuid user-uuid}))) (neo4j/defquery delete - "MATCH (s:schema {uuid:{uuid}}) + "MATCH (s:schema {uuid: $uuid}) WITH s OPTIONAL MATCH (s)--(a:attribute)-[cb:created_by]-(:user) DELETE cb, a @@ -114,8 +114,8 @@ (neo4j/defquery edit "MATCH (s:schema) - WHERE s.uuid = {uuid} - SET s.name = {name}") + WHERE s.uuid = $uuid + SET s.name = $name") (defn edit! [schema] (neo4j/exec-query! edit @@ -123,7 +123,7 @@ (neo4j/defquery assigned-users "MATCH (s:schema)-[p:permission]-(u:user) - WHERE s.uuid = {uuid} + WHERE s.uuid = $uuid RETURN u, p ORDER BY u.ident") (defn assigned-users! [uuid] @@ -133,7 +133,7 @@ (neo4j/defquery assigned-schemas "MATCH (s1:schema)-[p:permission]-(s2:schema) - WHERE s1.uuid = {uuid} + WHERE s1.uuid = $uuid RETURN s2 ORDER BY s2.name") (defn assigned-schemas! [uuid] @@ -157,14 +157,14 @@ (neo4j/defquery remove-assignments "MATCH (s:schema)-[c:permission]-(:user) - WHERE s.uuid = {uuid} - AND c.type = {permtype} + WHERE s.uuid = $uuid + AND c.type = $permtype DELETE c") (neo4j/defquery create-assignments "MATCH (s:schema), (u:user) - WHERE s.uuid = {uuid} - AND u.uuid IN {users} - CREATE (s)<-[:permission{type:{permtype}}]-(u)") + WHERE s.uuid = $uuid + AND u.uuid IN $users + CREATE (s)<-[:permission{type: $permtype}]-(u)") (defn assign-users! [uuid users permission] (neo4j/exec-queries! [remove-assignments @@ -177,12 +177,12 @@ (neo4j/defquery remove-schema-assignments "MATCH (s1:schema)-[p:permission]-(s2:schema) - WHERE s1.uuid = {uuid} + WHERE s1.uuid = $uuid DELETE p") (neo4j/defquery create-schema-assignments "MATCH (s1:schema), (s2:schema) - WHERE s1.uuid = {uuid} - AND s2.uuid IN {schemas} + WHERE s1.uuid = $uuid + AND s2.uuid IN $schemas CREATE (s1)-[:permission]->(s2)") (defn assign-schemas! [uuid schemas] (neo4j/exec-queries! @@ -192,7 +192,7 @@ {:uuid uuid :schemas schemas}])) (neo4j/defquery find-by-instance - "MATCH (i:instance {uuid:{uuid}})-[:of]->(s:schema) + "MATCH (i:instance {uuid: $uuid})-[:of]->(s:schema) RETURN s") (defn find-by-instance! [uuid] (-> find-by-instance diff --git a/src/wanijo/user/db.clj b/src/wanijo/user/db.clj index 229bc9e..31b6338 100644 --- a/src/wanijo/user/db.clj +++ b/src/wanijo/user/db.clj @@ -1,7 +1,6 @@ (ns wanijo.user.db (:require [clojure.spec.alpha :as spec] - [wanijo.infrastructure.neo4j :as neo4j] - [neo4j-clj.core :as db])) + [wanijo.infrastructure.neo4j :as neo4j])) (spec/def ::ident (spec/and string? not-empty)) @@ -14,7 +13,7 @@ (neo4j/defquery find-user "MATCH (n:user) - WHERE n.ident = {ident} + WHERE n.ident = $ident RETURN n") (defn find! [ident] @@ -27,14 +26,14 @@ (comment (macroexpand '(db/defquery test-find-user - "MATCH (u:user) WHERE u.ident = {ident} RETURN u")) + "MATCH (u:user) WHERE u.ident = $ident RETURN u")) (macroexpand '(neo4j/defquery find-user - "MATCH (n:user) WHERE n.ident = {ident} RETURN n")) + "MATCH (n:user) WHERE n.ident = $ident RETURN n")) (require '[neo4j-clj.core :as db]) (db/defquery test-find-user - "MATCH (u:user) WHERE u.ident = {ident} RETURN u") + "MATCH (u:user) WHERE u.ident = $ident RETURN u") (with-open [s (db/get-session @neo4j/conn)] (test-find-user s {:ident "admin"})) (neo4j/exec-query! test-find-user {:ident "admin"})) diff --git a/src/wanijo/visualisation/db.clj b/src/wanijo/visualisation/db.clj index ccf0cfd..1418108 100644 --- a/src/wanijo/visualisation/db.clj +++ b/src/wanijo/visualisation/db.clj @@ -27,7 +27,7 @@ (neo4j/defquery search "MATCH (i:instance) - WHERE i.name =~ {term} + WHERE i.name =~ $term RETURN i LIMIT 10") (defn enrich-links [instance]