got it, tracked it down to

adapters/data_objects_adapter.rb

536             if operand.respond_to?(:operands) &&
operand.operands.size > 1
537               statement = "(#{statement})"
538             end

InclusionComparison and EqualToComparison are not  enclosed within
brackets. Do we even need this block of code ?


On Sep 7, 6:36 am, deepfryed <[email protected]> wrote:
> shouldn't composite foreign key => composite unique key work ?
>
> with code and country being a key instead of id for author, dm still
> generates the wrong sql
>
> 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"
>
> starting to look like a bug
>
> thanks
>
> On Sep 7, 3:59 am, Martin Gamsjaeger <[email protected]> wrote:
>
> > deepfryed,
>
> > I'm quite sure that dm looks for matching model *keys* when you give
> > :child_key and :parent_key options to relationship definitions. So if
> > you want :child_key => [:code, :country] you need to make sure the
> > both :code and :country are marked with :key => true. Also, :id,
> > Serial, :key => true is not necessary, :id, Serial is enough. Serial
> > properties are keys by default.
>
> > HTH
> > snusnu
>
> > On Sun, Sep 6, 2009 at 15:21, deepfryed<[email protected]> wrote:
>
> > >http://pastie.org/607656
>
> > > the code generates the following SQL
>
> > > 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.
>
> > > am I doing something incorrectly ?
>
> > > i'm using dm-core/next
--~--~---------~--~----~------------~-------~--~----~
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