Herby,

I must admit I've never used Dictionary Mappings with Glorp, so I don't have an answer.
But I am a bit confused by your code examples. See below


Am 24.10.17 um 20:27 schrieb Herby Vojčík:
Hello!

I am using a DictionaryMapping in my code, and I wanted to use #includesKey: in #where: clause (something akin

  each tools includesKey: aToolId

What SQL expression would you expect here?

I would guess that you want to build a subquery like exists, because the way I understand the query, you want to find all instances of (whatever each is) that hold an Association in their tools dictionary where the key is aToolId.

) to select only rows for which DictionaryMapping uses certain key. It failed with the error in the lines of "#tools does not resolve to field". I had to come up with


each tools anySatisfy: [ :tool | tool id = aToolId ]
Hmm. This makes me wonder. Is #tools really a Dictionary? Inside the Block, I'd expect the :tool parameter to be an Association, and that doesn't understand #id,does it? I guess @each is the parameter within an Block like in

self session read: MyClass where: [:each| each tools ...]

If so, I have a hard time believing that anySatisfy: would work (never tried)...




Is it the bug / feature / problem in my approach? If bug, is it planned to add #includesKey: translation to DictionaryMapping?

I don't know, but would guess it is not currently on the Todo-list.

My first tip would be to try and find some slides (most likely made by Niall and presented at an ESUG) including the words "subquery", "glorp" and "exists". You won't find much, but that may be a starting point.

Not sure this helps, ;-)


Joachim


--
-----------------------------------------------------------------------
Objektfabrik Joachim Tuchel          mailto:jtuc...@objektfabrik.de
Fliederweg 1                         http://www.objektfabrik.de
D-71640 Ludwigsburg                  http://joachimtuchel.wordpress.com
Telefon: +49 7141 56 10 86 0         Fax: +49 7141 56 10 86 1


Reply via email to