Fork me on GitHub

it's possible to have a type system which assigns one type to each entity, but allows you to use different namespaces for the attributes. that doesn't restrict power and allows you to know that a user is a user, and have a user spec etc


can someone help me with dates in queries? in this example i'm looking for entities that have transactions made to their :item/available attribute before some date (now). *edit:

(d/q '{:find  [?e]
       :in    [$]
       :where [
               [?e :item/available? _ ?t]
               [?t :db/txInstant ?inst]
               [(< ?inst (java.util.Date.))]
=> ExceptionInfo processing clause: [?t :db/txInstant ?inst], message: java.lang.ClassCastException  clojure.core/ex-info (core.clj:4739)


wait that's all screwy. updating...


and flipping < to > runs successfully with no results, which makes sense because nothing has been transacted in the future. => []


@joshkh Use the methods .before or .after on j.u.Date


> should have thrown a ClassCastException too.


cheers @benoit, that was driving me nuts. thanks.


I thought the ClassCastException was on the < clause, expecting a Number instead of a Date, but apparently this is somewhere else: processing clause: [?t :db/txInstant ?inst], message: java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to java.util.Date and you're right, it return an empty set with >. Very surprising behavior.


yeah.. i started erroneously heading down the type hinting route with no luck


(of course)


@marshall I know the query was malformed in the first place but shouldn't the error indicate a problem with using < on a Date? Does the ClassCastException on PersistentList makes sense to you?

Ben Kamphaus21:02:07

you can do comparison on dates in Datomic datalog clauses. You want to pass a date as a parameter into the :in portion of the query, not instantiate one in-line with the java.utile.Date constructor.


that was my next thought. i know i've used comparisons in the past.


@bkamphaus Good catch. That's likely why I didn't remember this behavior.


This is a little surprising that the 2 queries don't have the same behavior whether you pass the date or inline it. I would like one day to understand why that is.

Ben Kamphaus22:02:19

I’d guess that the way it errors is considered undefined behavior b/c it’s not valid Datomic datalog. A fn-expression can be an expression-clause which can be a where-clause but you can’t nest functions this way. A fn expression itself is only valid as [[fn fn-arg+] binding]


I have a datomic ions related question. Is there a way to include sources and dependencies from extra-paths and extra-deps defined within an alias in deps.edn while creating a new ions revision? I’ve tried to run push command with including my alias but it didn’t help: clojure -A:dev:my-alias -m '{:op :push}'. I’ve checked the contents of the resulting revision zip file and it didn’t contain the sources defined in extra-paths.


I’ve seen a similar post in datomic forum Is there anyone who can help about this?


That was my post, still haven't heard anything.


Aha! I thought it would work pretty straightforward, and I was wrong 🙂. Hope someone has answers for us!