Fork me on GitHub
#datomic
<
2017-06-20
>
steveb8n01:06:37

I’m designing a schema where ordered to-many relationships are a requirement. I’ve seen the various blog posts etc and that seems to suggest either 1/ component wrapper entities with :position attr, 2/ referenced/child entities with :position attribute or 3/ referenced/child entities with linked-list attributes

steveb8n01:06:07

Does anybody have any experience or war stories from using these various techniques?

steveb8n01:06:28

Or even better, is there anything on the Datomic roadmap that will help with this?

robert-stuttaford05:06:51

@steveb8n Datomic can’t really help because it can’t know which of these is most suited to your use-case. few vs many items, items-have-one-parent-list vs items-have-many-parent-lists both have an impact on what you do. by providing for one case, Datomic could mislead people on thinking about these concerns

val_waeselynck05:06:38

@steveb8n you should ask on Stackoverflow or the mailing list, and we'll try and give you the tradeoffs

steveb8n06:06:07

good point. I’m starting to play with this tomorrow so that helps

steveb8n06:06:17

thanks both, I will post on SO

shaneprince13:06:50

Has anyone successfully created a leiningen project with dependencies for both the datomic client and ring? I've found this unresolved issue on SO relating to the exact same problem I have and can't figure out a way around it: https://stackoverflow.com/questions/43291069/lein-ring-server-headless-fails-when-including-datomic-dependency - appears to be caused by ring and the datomic client relying on different but incompatible versions of Jetty?

karol.adamiec13:06:30

@shaneprince i had issues with some AWS libs conflicting and had to add ‘[com.amazonaws/aws-java-sdk-dynamodb “1.11.0”]’ by hand to resolve it.

karol.adamiec13:06:49

try running lein deps :tree to find offensive lib

karol.adamiec13:06:51

in your case try to include a version of jetty that will satisfy different libs

shaneprince13:06:28

Thanks @karol.adamiec, running lein deps :tree shows the datomic client depends on jetty-util 9.3.7.v20160115 but from my investigation ring core depends on jetty-util 7.6.8.v20121106. I'm on ring 1.6.1 which I believe is the latest version. Is it even possible to include both dependencies that each require different versions of jetty?

karol.adamiec13:06:38

dont know… maybe someone else can answer that ;(

shaneprince15:06:22

For anyone else that comes across this issue: from what I understand it looks like ring-core is using an older jetty adapter for legacy purposes. I've found https://github.com/sunng87/ring-jetty9-adapter a worthy replacement so far.

matthavener17:06:12

is the ability to compare datomic :db.type/instant with < documented anywhere?

matthavener18:06:03

@robert-stuttaford i’m more asking if the ability to use a predicate like [(< ?inst1 ?inst2)] is documented

souenzzo18:06:07

@matthavener and I think that is really odd that inside datalog we can compare #inst, and on clojure not.

favila18:06:57

all datomic valueTypes must be comparable

favila18:06:08

otherwise sorted index would be impossible

favila18:06:12

(except bytes compare on something other than contents? not sure what)

souenzzo20:06:33

so it's more a clojure "problem", that cant compare #inst, and datomic has a workaround to make it work internally ?

favila20:06:44

most likely they have a custom comparator for whatever sorted-datom-set data structure they made

favila20:06:16

the < <= >= > datalog ops are not clojure functions, they are magic

souenzzo20:06:24

I'm trying to

`[(my-ns/function-that-returns-function ~'?foo) ~bar]
 [(~bar ~'?var1 ~'?var2) ~'?foobar]
But getting com.google.common.util.concurrent.UncheckedExecutionException: java.lang.IllegalArgumentException: Parameter declaration ?var2 should be a vector I'm missing something?

favila20:06:00

what does ~bar expand to?

souenzzo21:06:36

~'bar both*

souenzzo21:06:32

com.google.common.util.concurrent.UncheckedExecutionException: java.lang.RuntimeException: Unable to resolve symbol: ?f in this context This is the real exception. The other exception was because I'm using fn(on ~'bar) keyword and it's trying to evaluate a function 😜

souenzzo21:06:37

`[(my-ns/function-that-returns-function ~'?foo) ~'bar]
 [(~'bar ~'?var1 ~'?var2) ~'?foobar]
=> Unable to resolve symbol: bar in this context
`[((my-ns/function-that-returns-function ~'?foo) ~'?var1 ~'?var2) ~'?foobar]
=> Unable to resolve symbol: ?foo in this context

souenzzo21:06:01

Functions aren't first class inside datalog?

souenzzo21:06:21

`[(my-ns/function-that-returns-function ~'?foo) ~'?bar]
 [(.invoke ^clojure.lang.Var ~'?bar ~'?var1 ~'?var2) ~'?foobar]
Works for me 😄