Hi!

If I have 2 models (Sentence, Word), which have a Many-to-Many
relationship, and Word has a field 'word', the following query:

Sentence.all(:words => { :word => "Hello" })

Tries to match "sentences.id" to "words.id" (live example at
http://pastebin.ca/2097242 ) :

SELECT "id", "text", "book_id"
FROM "sentences"
WHERE "id" IN
    (SELECT "words"."id"    # Query result will be a single words.id,
which will be used as sentence id
     FROM "words"
     INNER JOIN "sentence_words" ON "words"."id" =
"sentence_words"."word_id"
     INNER JOIN "sentences" ON "sentence_words"."sentence_id" =
"sentences"."id"
     WHERE "words"."word" = 'Hello')
ORDER BY "id"

Note that I haven't even heard of DataMapper until today, so I might
doing something bad, but this seems to be definiately wrong (the inner
query should be SELECT "sentences"."id" FROM "words" INNER JOIN...).

Thanks!

Adam

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.

Reply via email to