Skip to content

Commit

Permalink
Avoid keywordize attributes in schema->clj(closes #153)
Browse files Browse the repository at this point in the history
  • Loading branch information
alef committed Mar 26, 2016
1 parent e1ca971 commit d4acd8f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/datascript/js.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

(defn- schema->clj [schema]
(->> (js->clj schema)
(walk/postwalk keywordize)))
(reduce-kv
(fn [m k v] (assoc m k (walk/postwalk keywordize v))) {})))

(declare entities->clj)

Expand Down
25 changes: 24 additions & 1 deletion test/js/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,28 @@ function test_filter() {
})));
}

function test_upsert() {
var schema = {
":my/tid": {
":db/unique": ":db.unique/identity"
}
};
var conn = d.create_conn(schema);

d.transact(conn, [{
":my/tid": "5x",
":my/name": "Terin"
}]);

d.transact(conn, [{
":my/tid": "5x",
":my/name": "Charlie"
}]);

var names = d.q('[:find ?name :where [?e ":my/tid" "5x"] [?e ":my/name" ?name]]', d.db(conn));
assert_eq_set([["Charlie"]], names);
}

function test_datascript_js() {
return test_fns([ test_db_with,
test_nested_maps,
Expand All @@ -452,7 +474,8 @@ function test_datascript_js() {
test_q_fns,
test_find_specs,
test_datoms,
test_filter
test_filter,
test_upsert
]);
}

Expand Down

0 comments on commit d4acd8f

Please sign in to comment.