diff --git a/src/wanijo/attribute/db.clj b/src/wanijo/attribute/db.clj index d26db19..9b43faa 100644 --- a/src/wanijo/attribute/db.clj +++ b/src/wanijo/attribute/db.clj @@ -12,13 +12,15 @@ findy-by-schema {:uuid schema-uuid}))) -(neo4j/defquery with-name - "MATCH (a:attribute) +(neo4j/defquery with-name-in-schema + "MATCH (a:attribute)-[:of]->(s:schema) WHERE a.name = {name} + AND s.uuid = {schema_uuid} RETURN a") -(defn with-name! [matching-name] - (-> (neo4j/exec-query! with-name - {:name matching-name}) +(defn with-name-in-schema! [matching-name schema-uuid] + (-> (neo4j/exec-query! with-name-in-schema + {:name matching-name + :schema_uuid schema-uuid}) first :a)) diff --git a/src/wanijo/schema/forms.clj b/src/wanijo/schema/forms.clj index 503bfa9..d4c1854 100644 --- a/src/wanijo/schema/forms.clj +++ b/src/wanijo/schema/forms.clj @@ -8,7 +8,8 @@ (defn unique-attr-name-in-schema! [req] (let [attr-uuid (get-in req [:params :uuid]) name (get-in req [:params :name]) - matching-attr (db-attr/with-name! name)] + schema-uuid (get-in req [:params :schema]) + matching-attr (db-attr/with-name-in-schema! name schema-uuid)] (or (nil? matching-attr) (= attr-uuid (:uuid matching-attr)))))