Fork me on GitHub
#datomic
<
2018-02-16
>
souenzzo00:02:26

@kenny there is a "feature request" here (please vote!) https://receptive.io/app/#/case/17714

madstap15:02:51

Quick question, would changing an attribute's schema from unique-value to unique-identity be breaking or have any unintended consequences in any way?

jaret15:02:13

If you had :db/index true on the same attribute and you kept your values unique it shouldn’t have much change

jaret15:02:31

however if you did not have db/index set you’re going to keep an AVET index after the change

jaret15:02:54

and there are some other notes in that section of the docs if your values aren’t truly unique

madstap15:02:46

Right, so since it was :db/unique :db.unique/value, that means that there was an AVET index and the change won't break anything. Thanks!

mgrbyte16:02:27

@madstap unless your app code is expecting exceptions to be thrown if a transaction tries to violate a uniqueness constraint, whereas the with :db.unique/identity: upsert - I believe.

madstap16:02:00

Oh, right. I actually think it uses an exception being thrown to check for duplicate use emails. So it does break my code I guess...

uwo20:02:48

would y’all say nil-punning with boolean attributes is usually a poor modeling choice for flags, since it forces queries to search with (or [?e :attr false] [(missing? $ ?e :attr)])? The alternative being to always ensure that entities that can have that attribute do have it. (I personally prefer modeling flags with enums, but assuming the choice has already been made to use a boolean flag.)

uwo21:02:13

lol a colleague just pointed out that I could use (not [?e :flag true]), so it doesn’t really add any additional work to the query, I suppose

Ben Kamphaus21:02:32

@uwo my opinion: I like to infer things from the presence of attributes. You could also use not, but I’m OK writing the occasional query like the or .. missing example you provide, but say I have entities that have possible statuses processed and not-processed — I would model something like :status/to-process and query for that if I expected to mostly write queries that looks for things to process. Then retract :status/to-process e.g. when the entity was processed. If there are multiple stages though (not binary), I enumerate all the possibilities and basically state-machine it out. In practice for me thus far the perf aspect of realizing an additional set for negation or whatnot has only been an issue with relations between entities (where e.g. relation b/t entities is M * N instead of linear), not with queries just doing the single attr.

uwo21:02:58

I feel this way too. In this case it’s just a simple boolean flag, but I like to create an db.type/ref attribute and use enums as the value. We’re working with a flag that has already been created as a boolean, and we don’t want to rewrite code at the moment. So we were talking through potential tradeoffs of nil-punning, so to speak.

bmaddy21:02:50

I believe (not [?e :flag true]) requires the :flag attribute to exist (haven't tried it though).

bmaddy21:02:35

Nevermind, that does seem to work.