How to query for an empty UUID in ORDA

I have tables with UUID fields where some of the records have no UUID assigned yet. How do I query to find those records using ORDA?

This does not work in 17.3:

$equips_es:= **ds** .Equip. *query* ("ItemID = :1 or ItemID = :2";"0"*32;"20"*16)

Sorry, I see this does work in 4D standalone but not 4D server.

For 4D server I can do this but wondering if the is the recommended way?

$equips_es:=$equips_es.minus ($equips_es.item.equips)

UUID’s are not simple Alpha fields and it works best (for me) to use them as special field type.

for me an UUID is either valid or null. Null means it does not has any value.
“0”*32 is a fake value. It is the trial to have a value for something without value.

You see this only if you have the checkbox “assign empty values for NULL” for the field enabled.

Note: this works for many field types, like 0 for number or “” for alpha, but makes not a lot of sense for UUID. And that’s your problem.

So remove this check box.
Now you can easily query for NULL, simply by doing:

$equips_es:=ds.query("ItemID = null")
1 Like

Hi Thomas,
I don’t agree with this. If it was not 4D, I would, but we’re used in 4D since the dawn of times that an empty string value is “”, number 0, date !0000-00-00!, boolean False, etc. The way it is with uuid’s isn’t consistent with that. Worse, empty can be “0”*32 or “02”*16 (I seem to remember it depends on the value is new or has been filled then erased - sorry if it’s wrong). uuid isn’t consistent with that; if it’s a number, like other numbers, 0 would be easier. I’d like 4D to consider that “0”*32 means empty.

as I wrote “for me”. And UUID is not a normal type as the others. It looks like a string, but in fact it is a 128 bit integer. You cannot search with “0000…” for that.
4D is internally doing a 64 bit query on the first half and only if there is a hit there doing a second compare. That’s why a UUID is as fast as using a longint PK.

And to repeat, I wrote “for me”. It is the way I personally see it and how I think it is to be used best. UUID is for me a new field type, not an existing one, so I need to modify existing code anyway. So I can accept a different behavior. That’s my personal feeling, it is not a law.

I agree, but in a not better world, I still use classic code too :wink: