The AND, OR operators are not properly scoped
SELECT "id", "name", "type", "code", "country" FROM "books" WHERE
"type" = 'fiction' AND ("code" = '1' AND "country" = 'au') OR ("code"
= '2' AND "country" = 'au') ORDER BY "id"
should be
SELECT "id", "name", "type", "code", "country" FROM "books" WHERE
("type" = 'fiction') AND (("code" = '1' AND "country" = 'au') OR
("code" = '2' AND "country" = 'au')) ORDER BY "id"
maybe the example i gave was not the best one :)
On Sep 7, 7:43 am, "Dan Kubb (dkubb)" <[email protected]> wrote:
> deepfryed,
>
> > i'm using dm-core/next
>
> You can use dm-core/master now if you wish. I merged them together a
> few days ago.
>
> > SELECT "id", "name", "type", "code", "country" FROM "books" WHERE
> > "type" = 'fiction' AND ("code" = '1' AND "country" = 'au') OR ("code"
> > = '2' AND "country" = 'au') ORDER BY "id"
>
> > which is incorrect.
>
> That's the SQL query I would expect to see generated from that query.
> What were you expecting?
>
> DM should work fine with relationships between non-key properties.
> Although the general convention is for the child side (the one that
> defines the belongs_to) that the FK would be pointing to the parent
> PK. It's not strictly enforced anywhere, but it is the default way
> models are related.
>
> I updated the example a tiny bit to see better logger output, and
> remove some redundant options, and I ended up with:
>
> http://pastie.org/607983
>
> It returns what I would expect, 1 matching book for the first author,
> and 0 for the second. Do you think this is wrong?
>
> --
>
> Dan
> (dkubb)
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---