Fork me on GitHub
#datomic
<
2015-08-12
>
Ben Kamphaus00:08:55

@misha I’m not sure I follow your example, but if you mean unique within the collection w/the collection being that implied by the set of card-many vals (refs to enums or otherwise), then it sounds like you just want the default behavior.

Ben Kamphaus01:08:44

(d/pull (d/db conn) '[*] 17592186045418)
;{:db/id 17592186045418
; :person/aliases ["Bert" "Bobby" "Curly" "Robert" "Robin”]}

@(d/transact conn [[:db/add 17592186045418 :person/aliases "Robert"]])
;{:db-after datomic.db.Db@b1bf43ff
; :db-before datomic.db.Db@834c4088
; :tempids {}
; :tx-data [#datom[13194139534315 50 #inst "2015-08-12T00:58:36.834-00:00” 13194139534315 true]]}
;; ^ no new data in card-many attr, only tx

(d/pull (d/db conn) '[*] 17592186045418)
{:db/id 17592186045418
 :person/aliases ["Bert" "Bobby" "Curly" "Robert" "Robin"]}

madvas08:08:09

Hey guys, how do I connect to heroku postgresql database? I have installed:

[com.datomic/datomic-pro "0.9.5206" :exclusions [joda-time]]
[postgresql "9.3-1102.jdbc41"]
When I try to connect as:
(def uri "datomic:)
(def conn (d/connect uri))
I get error
java.sql.SQLException: No suitable driver
clojure.lang.Compiler$CompilerException: java.sql.SQLException: No suitable driver, compiling:(server.clj:28:11)

misha09:08:13

@bkamphaus, not if you mean unique within the collection , with the available enum values a b c I need to be able to have entities representing these combinations:

[a]
[b]
[c]
[a b]
[a c]
[b c]
[a b c]
And it would be nice, if adding another [a b] would just upsert already existing one. Also, I am not entirely sure if this is significant or not, but you use strings as list items, and I use keywords, which are idents. With :db/unique :db.unique/value in :person/aliases definition, you would not be able to have these 2 :
{:db/id 1
 :person/aliases [:names/Bert :names/Bobby]}
{:db/id 2
 :person/aliases [:names/Bert :names/Curly]}
And with with :db/unique :db.unique/identity in :person/aliases definition, the second would have overwritten the 1st one.

misha09:08:03

Now – a is treated as unique value, not [a]. a and b, not [a b]. Re-using your example: :db.unique/value and :db.unique/identity enforce only one person being able to have Bert as an alias across entire db.

magnars10:08:33

Any ideas why I get multiple historic entries for an attribute that has :noHistory set to true? Here's a very short repl-session demonstrating it: https://gist.github.com/magnars/093c6c437b1760ac22cf

magnars10:08:34

Turns out Stuart Halloway has addressed this quirk here: http://datomic.narkive.com/gIuZhcp8/db-nohistory >:db/noHistory is not a logical property of your data, it is only a storage optimization hint. The memory database has no storage, so :db/noHistory is irrelevant.

magnars10:08:26

I wish it wasn't so, tho - because this makes for a real difference between my development and testing environments, and production.

robert-stuttaford13:08:52

anyone using dynamodb as a datomic backend, here?

robert-stuttaford13:08:14

curious what it’ll cost to restore 30gb of datomic backups to ddb

tcrayford13:08:31

@robert-stuttaford: gonna bet you could e.g. dig in the backup format and count the number of segments, then assume it's something like that many writes?

robert-stuttaford13:08:41

such strange pricing

robert-stuttaford13:08:51

pay per hour for the ability to write

ericfode21:08:48

is there any way to guess the number of segments in a database?

arohner21:08:10

@ericfode: you could just go poking around your postgres instance or whatever

arohner21:08:16

based on data size, I’m not sure

ericfode21:08:32

It’s a ddb, should i just look for the number of rows?

sdegutis21:08:25

Hello. I am inexplicably receiving an error that I wasn't receiving this morning, during a transact.

sdegutis21:08:49

I've reset my database to no avail, the error still occurs: clojure.lang.ExceptionInfo: :db/invalid-data Unable to resolve entity: :question-template/sort-pos {:db/error :db/invalid-data}

sdegutis21:08:55

Please help?

shaunxcode21:08:21

Wait, is that exception happening when starting transactor or when doing a specific transaction? What are the details of the transaction?

sdegutis21:08:02

While I'm doing a transaction. One of the tx-data (a list) contains a map like this: {:question-template/sort-pos 0, ...} and includes a legitimate temporary eid as :db/id

shaunxcode21:08:46

what is schema for :question-template/sort-pos ?

sdegutis21:08:46

{:db/id (d/tempid :db.part/db) :db/ident :question-template/sort-pos :db/valueType :db.type/long :db/cardinality :db.cardinality/one :db.install/_attribute :db.part/db}

shaunxcode21:08:53

is there a way to see entire transaction? (can you anonymize or what not?)

sdegutis21:08:11

I don't think it's related to this specific attribute. When I remove this attribute from the map, I get the same error with another attribute, and so on.

bostonaholic21:08:27

has the schema been transacted?

shaunxcode21:08:44

aww, there was someone else having a similar issue but I think it is lost to slack black hole

sdegutis21:08:50

bostonaholic: Yes. At the beginning of starting the process, every schema is transacted again.

sdegutis21:08:28

Did the gist share correctly?

kbaribeau21:08:36

can you produce the error with a smaller transaction?

sdegutis21:08:50

Yeah one sec.

kbaribeau21:08:04

usually tempids look like #db/id[:db.part/user -1000106] not sure why yours are different

sdegutis21:08:49

kbaribeau: Yeah I noticed that too, seemed odd. Assumed it was because that's the map it really boils down to.

sdegutis21:08:57

So, I got it to stop giving the error.

sdegutis21:08:41

It succeeds as long as I omit the fields :answer-template/correct?, :answer-template/sort-pos, :question-template/sort-pos, :question-template/enabled?, :question-template/allowed-types, :question-template/answers, and :question-template/science?.

sdegutis21:08:50

If any of those is present, it fails with the same basic error.

kbaribeau21:08:10

(d/create-database "datomic:")
@(d/transact (d/connect "datomic:")
           [{:db/id (d/tempid :db.part/user)
             :thisthing/doestnexist 0}])

kbaribeau21:08:28

^ I get a very similar error by running that. it really looks to me like your schema has not been transacted

kbaribeau21:08:48

or, it could be only partially transacted

kbaribeau21:08:58

the error I get due to missing schema is CompilerException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: :db.error/not-an-entity Unable to resolve entity: :thisthing/doestnexist, compiling:(:62:1)

sdegutis22:08:21

I'm using Datomic 0.8.4218 btw

sdegutis22:08:27

Datomic Free

Ben Kamphaus22:08:14

^ simplest explanation, probably best next step is to confirm those exist (and that data type matches, etc.) - the tempid map is just what d/tempid resolves to.

Ben Kamphaus22:08:56

i.e.

(d/tempid :db.part/user)
; <#C03RZMDSH>.db.DbId{:idx -1000000 :part :db.part/user}

sdegutis22:08:19

Also, it works just fine when I do it using the in-memory database.

Ben Kamphaus22:08:05

If it succeeds when you omit fields, my next step would be to confirm that a problem attr’s schema has been transacted and is in the db prior to transacting (in the isolated case of free storage).

sdegutis22:08:37

bkamphaus: Very good idea, thanks, will do.

misha22:08:01

@sdegutis looks like missing schema to me too

misha22:08:38

gentlemen, what is (or is there) an idiomatic way to keep track of order of items in collections in datomic?

misha22:08:08

E.g. I have 3 "reusable" item-entities: a b c, and I want to have some list-entities which not only contain list of items, but know their order in the list as well.

misha22:08:42

In which case [a c] and [c a] would be different.

misha22:08:32

The only solution I have in mind, is to wrap items in an item-container-entities, and make lists out of those: [{:item a, :idx 0} {:item c, :idx 1}] and [{:item c, :idx 0} {:item a, :idx 1}] or [{:item a, :idx 0} {:item c, :idx 1}] and [{:item a, :idx 1} {:item c, :idx 0}]

misha22:08:59

is there a better/other way?

sdegutis23:08:24

@bkamphaus: How do you confirm the existence of such a thing in code?

Ben Kamphaus23:08:26

query for the attr entity (e.g. By ident) using the db value from the conn prior to submitting the tx. Entity or attribute apis are options, too.

sdegutis23:08:07

Yeah yeah I know some of these words .gif

misha23:08:18

@sdegutis (datomic.api/entity (datomic.api/db (datomic.api/connect db-url)) :my/attr)