How (or at what layer) do you deal with null vs empty collections

40 views
Skip to first unread message

mindplay.dk

unread,
Mar 26, 2015, 4:24:53 PM3/26/15
to orient-...@googlegroups.com
Suppose a Person has a list of Tools - I just learned that an empty collection is not the same as a NULL value, so there are two ways in which person.tools could be empty.

My first thought was, set a default value of [] for the Person.tools property, but there's no such thing as default values for properties (?)

My issue is, when dealing with document objects, you constantly need guard clauses around code that uses these collections, e.g.

if (person.tools) {
    person.tools.forEach(...);
}

In a sense, it feels like the property-type isn't strictly List<Tool> but something more like Nullable<List<Tool>> which isn't really what I wanted...

Setting "Mandatory" and "Not Null" doesn't really solve the problem either, because it doesn't guarantee data consistency after a schema change - that is, if you add a new collection-property, existing records will have NULL-values for that property.

Patching all documents on load is the best I could come up with, and that doesn't feel right - I really wanted consistency at the schema-level, and unless I'm dealing with schema-less documents, there is no useful distinction between NULL and an empty collection; they're just two representations of the same thing.

How, or at what level do you deal with this?

Luca Garulli

unread,
Mar 27, 2015, 7:44:32 AM3/27/15
to orient-database
Hi Rasmus,
Please could you provide a small test case that will help us reproduce the problem?

Lvc@


--

---
You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-databa...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rasmus Schultz

unread,
Mar 31, 2015, 3:23:36 PM3/31/15
to orient-...@googlegroups.com
Well, it's not really a technical problem, so much as a practical one.

I understand that the database needs to be able to make a distinction between an empty collection and NULL, because otherwise you couldn't tell if schema-less documents have a given property or not.

By the way, I'm using Oriento - it looks like that isn't really schema-aware yet, and therefore cannot tell what type a given property with a current NULL value should have been, if it's not present in the set, maybe that's part of the problem? I guess it also doesn't support the new binary serialization format yet, maybe that's part of it.

I really wish Orient had more complete driver support in either Node or PHP, since those are my only platform options. I guess Java is your primary market, but that's not an option where I work.

Do you have any plans to provide real driver support for either Node or PHP? (by "real", I mean more than naming a third-party driver as "official", e.g. providing actual official drivers, holding them to the same standard as the native drivers, keeping them up to date, and so on...)


--

---
You received this message because you are subscribed to a topic in the Google Groups "OrientDB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/orient-database/zh4D-HSGveQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to orient-databa...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages