Fork me on GitHub
#datomic
<
2019-02-21
>
joelsanchez10:02:59

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

5
joshkh19:02:27

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.))]
               ]}
     db) 
=> ExceptionInfo processing clause: [?t :db/txInstant ?inst], message: java.lang.ClassCastException  clojure.core/ex-info (core.clj:4739)

joshkh19:02:08

wait that's all screwy. updating...

joshkh19:02:10

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

benoit19:02:03

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

benoit19:02:45

> should have thrown a ClassCastException too.

joshkh20:02:38

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

benoit20:02:11

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.

joshkh20:02:51

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

joshkh20:02:13

(of course)

benoit20:02:46

@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?

bkamphaus21: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.

joshkh21:02:02

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

benoit22:02:59

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

benoit22:02:29

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.

bkamphaus22: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]

furkan3ayraktar22:02:09

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 datomic.ion.dev '{:op :push}'. I’ve checked the contents of the resulting revision zip file and it didn’t contain the sources defined in extra-paths.

furkan3ayraktar10:02:37

I’ve seen a similar post in datomic forum https://forum.datomic.com/t/tools-deps-aliases-in-ion-deployments/667. Is there anyone who can help about this?

ro618:02:04

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

furkan3ayraktar20:02:33

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

ro620:02:12

Definitely