Hi there,
I just stumbled across an dnu error because of an unexpected
result of a count:where: query in Glorp.
The problem is that an expression like
myDBSession count: MyClass where: [:obj| obj id = nil]
returns nil instead of zero. So when I ask the result of this query if it is greater than zero, I get "UndefinedObject does not unterstand >" .
The funny thing is that this also returns nil if you have
something like
myDBSession count: MyClass where: [:obj| obj customer = self]
when self is a newly created, not yet saved object and therefor
doesn't have an id (or better: an id of nil). So there is not
point in replacing the = test with == (which works for nil),
because the actual situattion doesn't involve nil or some object,
but instead objects whose ID might (still) be nil.
Is this expected behavior? Does Glorp behave the same on Pharo and VW (I am non VAST)?
My current workaround is this:
---
Customer>>#hasInvoices
^(myDBSession count: Invoice where: [:inv| inv customer = self])
ifNil: [^false]
ifNotNil: [:count| count > 0]
---
but honestly, I think this smells like a bug to me.
Joachim
--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to glorp-group...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/glorp-group/1dc89285-d55b-4e40-b6bb-05ae7fe17268%40objektfabrik.de.