diff --git a/bb/resources/native-image-tests/run-native-image-tests b/bb/resources/native-image-tests/run-native-image-tests index 14f67a54..fb0f05ce 100755 --- a/bb/resources/native-image-tests/run-native-image-tests +++ b/bb/resources/native-image-tests/run-native-image-tests @@ -57,4 +57,15 @@ fi ./dthk query '[:find ?e . :where [?e :name ?n]]' db:$CONFIG --format cbor >> /tmp/test ./dthk query '[:find ?i :in $ ?i . :where [?e :name ?n]]' db:$CONFIG cbor:/tmp/test # => 1 +# test arbitrary :in[puts] as positional args +QUERY_OUT=`./dthk query '[:find (pull ?e [*]) . :in $ ?name :where [?e :name ?name]]' db:$CONFIG '"Judea"'` +if [ "$QUERY_OUT" = '{:db/id 100001, :name "Judea"}' ] +then + echo "Positional input test successful." +else + echo "Exception: Query did not return correct value." + exit 1 +fi + ./dthk delete-database $CONFIG +./dthk delete-database $ATTR_REF_CONFIG diff --git a/doc/cli.md b/doc/cli.md index 3b75bfa5..8d5c581e 100644 --- a/doc/cli.md +++ b/doc/cli.md @@ -42,8 +42,15 @@ value(s), whereas the `db:` argument to `query` comes after the query value, mirroring the Clojure API. As an added benefit, this also allows passing multiple db configuration files prefixed with `db:` for joining over arbitrary many databases or data files with "edn:" or "json:". Everything non-prefixed is -read in as `edn` and passed to the query engine as well. +read in as `edn` and passed to the query engine as well: +```bash +$ dthk query '[:find ?e . :in $ ?name :where [?e :name ?name]]' db:myconfig.edn '"Linus"' +123 +``` + +When passing strings as EDN, make sure to enclose double quotes as part of the +command-line arg value. Otherwise it will be parsed as a symbol. Provided the filestore is configured with `{:in-place? true}` you can even write to the same database without a dedicated daemon from different shells: diff --git a/src/datahike/cli.clj b/src/datahike/cli.clj index 9454eea3..f9270842 100644 --- a/src/datahike/cli.clj +++ b/src/datahike/cli.clj @@ -144,8 +144,7 @@ nil input->db)] res - (throw (ex-info "Input format not know." {:type :input-format-not-known - :input s})))) + (edn/read-string s))) (defn report [format out] (case format