SimpleQuery does not understand #asSymbol for to-be-generated isEmpty subquery

Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

SimpleQuery does not understand #asSymbol for to-be-generated isEmpty subquery

jtuchel
Dear Glorp Community

I am unable to find my error given a seemingly simple query:

mySession read: Invoice where: [:inv| inv claim payments isEmpty].

(Invoice 1:1 Claim 0:n Payments)

Glorp cannot generate the correct NOT EXISTS subquery, although I can read and navigate claims and invoices and payments without any problems in our application (so I guess the OneToManyMapping and its OneToOneMapping counterpart as well as their JOIN expression are correct).

The Exception I am getting is:

SimpleQuery does not understand #asSymbol.

The exception is thrown in MappingExpression(ObjectExpression)>>#get:


get: aSymbol
    "Return the mapping expression corresponding to the named attribute"

    | reallyASymbol functionExpression |
    reallyASymbol := aSymbol asSymbol.
    functionExpression := self getFunction: aSymbol withArguments: #().
    functionExpression isNil ifFalse: [^functionExpression].
    ^self mappingExpressions at: reallyASymbol
        ifAbsentPut: [MappingExpression named: reallyASymbol basedOn: self]


aSymbol, however, is not a Symbol, but "a SimpleQuery for Payment".

What can I do now? Any tips where to look, what to change?

Thanks in advance

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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: SimpleQuery does not understand #asSymbol for to-be-generated isEmpty subquery

jtuchel
Nevermind, I found a "solution"


mySession read: Invoice where: [:inv| inv claim payments sqlCount = 0].


But looking at Slide 13 of http://www.esug.org/data/ESUG2007/Wed/glorpesug2007.pdf I thought isEmpty/notEmpty  yields the same query. But it doesn't.
Is this a bug or am I wrong about this isEmpty/notEmpty thing?


Joachim



Am Donnerstag, 12. April 2018 10:23:30 UTC+2 schrieb jtuchel:
Dear Glorp Community

I am unable to find my error given a seemingly simple query:

mySession read: Invoice where: [:inv| inv claim payments isEmpty].

(Invoice 1:1 Claim 0:n Payments)

Glorp cannot generate the correct NOT EXISTS subquery, although I can read and navigate claims and invoices and payments without any problems in our application (so I guess the OneToManyMapping and its OneToOneMapping counterpart as well as their JOIN expression are correct).

The Exception I am getting is:

SimpleQuery does not understand #asSymbol.

The exception is thrown in MappingExpression(ObjectExpression)>>#get:


get: aSymbol
    "Return the mapping expression corresponding to the named attribute"

    | reallyASymbol functionExpression |
    reallyASymbol := aSymbol asSymbol.
    functionExpression := self getFunction: aSymbol withArguments: #().
    functionExpression isNil ifFalse: [^functionExpression].
    ^self mappingExpressions at: reallyASymbol
        ifAbsentPut: [MappingExpression named: reallyASymbol basedOn: self]


aSymbol, however, is not a Symbol, but "a SimpleQuery for Payment".

What can I do now? Any tips where to look, what to change?

Thanks in advance

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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: SimpleQuery does not understand #asSymbol for to-be-generated isEmpty subquery

jtuchel
So while the result of

sqlCount=0 is equivalent to an isEmpty, the queries are of course different. One creates a subquery that does a COUNT(*) = 0, while I would expect the other to create a WHERE NOT EXISTS subquery. I am not an SQL expert, so I cannot say anything useful if any of these is more efficient. At first sight, I'd guess a COUNT(*) is slower, comparable to Smalltalk's (select: [:each| ...]) isEmpty as compared to anySatisfy: or detect:

Still wondering if my expectations towards isEmpty are wrong.

Joachim



Am Donnerstag, 12. April 2018 11:21:46 UTC+2 schrieb jtuchel:
Nevermind, I found a "solution"


mySession read: Invoice where: [:inv| inv claim payments sqlCount = 0].


But looking at Slide 13 of <a href="http://www.esug.org/data/ESUG2007/Wed/glorpesug2007.pdf" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.esug.org%2Fdata%2FESUG2007%2FWed%2Fglorpesug2007.pdf\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGiZ5FHsqbVO0krVC4yQsYR9JiUTQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.esug.org%2Fdata%2FESUG2007%2FWed%2Fglorpesug2007.pdf\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGiZ5FHsqbVO0krVC4yQsYR9JiUTQ&#39;;return true;">http://www.esug.org/data/ESUG2007/Wed/glorpesug2007.pdf I thought isEmpty/notEmpty  yields the same query. But it doesn't.
Is this a bug or am I wrong about this isEmpty/notEmpty thing?


Joachim



Am Donnerstag, 12. April 2018 10:23:30 UTC+2 schrieb jtuchel:
Dear Glorp Community

I am unable to find my error given a seemingly simple query:

mySession read: Invoice where: [:inv| inv claim payments isEmpty].

(Invoice 1:1 Claim 0:n Payments)

Glorp cannot generate the correct NOT EXISTS subquery, although I can read and navigate claims and invoices and payments without any problems in our application (so I guess the OneToManyMapping and its OneToOneMapping counterpart as well as their JOIN expression are correct).

The Exception I am getting is:

SimpleQuery does not understand #asSymbol.

The exception is thrown in MappingExpression(ObjectExpression)>>#get:


get: aSymbol
    "Return the mapping expression corresponding to the named attribute"

    | reallyASymbol functionExpression |
    reallyASymbol := aSymbol asSymbol.
    functionExpression := self getFunction: aSymbol withArguments: #().
    functionExpression isNil ifFalse: [^functionExpression].
    ^self mappingExpressions at: reallyASymbol
        ifAbsentPut: [MappingExpression named: reallyASymbol basedOn: self]


aSymbol, however, is not a Symbol, but "a SimpleQuery for Payment".

What can I do now? Any tips where to look, what to change?

Thanks in advance

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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/d/optout.