tonsky / tonsky/datascript

"_" as a wildcard for attribute produces false positives on large dataset.

Open
#215 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Clojure
Stars
5.8k
Forks
318
PR merge metrics
No merged PRs in 30d

Description

I don't have minimal reproducible case yet (db size I see this with is 60k+ datoms).

"False positives": some property entities are included in result set.
Issue is not reproducible with the following snippet, but schema and query have this shape:

(let [conn (ds/create-conn
             {:bar/properties    {:db/valueType :db.type/ref
                                  :db/cardinality :db.cardinality/many}
              :foo/properties    {:db/valueType :db.type/ref
                                  :db/cardinality :db.cardinality/many}
              :property/attribute {:db/valueType :db.type/ref}
              :attribute/name {:db/unique :db.unique/identity}})]
  (ds/transact! conn [{:db/id -1 :attribute/name "A"}
                      {:db/id -2 :foo/properties {:db/id -21 :property/attribute -1}}
                      {:db/id -3 :bar/properties {:db/id -31 :property/attribute -1}}])

  (->>
    (ds/q '[:find [?e ...]
            :in $ ?a
            :where
            [?p :property/attribute ?a]
            [?e _ ?p]]
      @conn 1)
    (ds/pull-many @conn '[*])))

https://clojurians-log.clojureverse.org/datascript/2017-04-06.html
https://clojurians-log.clojureverse.org/datascript/2017-04-07.html

[org.clojure/clojurescript "1.9.229"]
[org.clojure/clojure "1.8.0"]
[datascript "0.15.5"]

might be related:

  1. actual dataset has retracted entities
  2. https://github.com/tonsky/datascript/issues/214

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reducing the reported schema and query to a reproducible case, using the 60k+ datom dataset shape and checking whether retracted entities matter. Compare the wildcard _ query behavior with the discussion linked in the issue and issue #214. Done means the false positives are reproduced and a regression test demonstrates the corrected result set.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure
Domain
databases
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.