It's weird that you have to query the cb3_id twice, that's definitely a
bug.  If you have a chance, could you produce a snippet for this case? Just
something with a simplified schema and the query

On Fri, Oct 2, 2009 at 3:13 PM, ZHHZ <[email protected]> wrote:

>
> Brian,
>
> Thanks for explain. But to achieve the same goal, in 0.9, it is one
> query, but in 0.10, the best way I can figure out is like:
>
> PurchaseOrder.first(:completed => 'yes', :order =>
> [:closed_date.desc], 'items.cb3_id' => 1763).items.first(:cb3_id =>
> 1763)
>
> That is two-query to do the job.
>
> Anyway, I can live with it. Again, thanks for help. Have a nice
> weekend.
>
> --Bruce
>
>
>
> On Oct 2, 4:03 pm, Brian Smith <[email protected]> wrote:
> > I don't know specifically, but most of the stuff in the 0.10 version was
> > rewritten for stability. So I'm guessing there were some cases where it
> > would 'splode. Also it really does make more sense to run the query on
> the
> > model you're actually querying and then call the association. It will
> > actually chain the queries so I'm guessing it will do the same query as
> what
> > you were doing before, but it will be a bit more readable. I always
> strive
> > for readable code since its easier to get people up to speed on it. The
> > previous way requires a fairly adept knowledge of dm
> >
> >
> >
> > On Fri, Oct 2, 2009 at 2:44 PM, ZHHZ <[email protected]> wrote:
> >
> > > Brian,
> >
> > > Thanks for your email. You are right, I am working on a very 'huge'
> > > legacy DB.
> >
> > > I just wondering, is there a good reason why DataMapper changed the
> > > behavior of the "options[:order]".
> >
> > > Thanks.
> >
> > > --Bruce
> >
> > > On Oct 2, 3:14 pm, Brian Smith <[email protected]> wrote:
> > > > I think you might be better off running the query like
> >
> > > > PurchaseOrder.all(:completed => 'yes', :order =>
> > > [:closed_date.desc]).items
> >
> > > > Also, personally, if completed is just a string of yes or no, I'd use
> a
> > > > boolean column (unless its a legacy db)
> >
> > > > On Fri, Oct 2, 2009 at 9:07 AM, ZHHZ <[email protected]> wrote:
> >
> > > > > Hi,
> >
> > > > > 0.10.0 breaks some of my code, here is my models:
> >
> > > > > class PurchaseOrder
> > > > >  include ...
> >
> > > > >  property :closed_date, ...
> >
> > > > >  has n, items
> > > > > end
> >
> > > > > class PurchaseOrderLineItem
> > > > >  ...
> > > > >  belongs_to :po
> > > > > end
> >
> > > > > In 0.9, I was able to to something like:
> > > > >  order_by =
> [DataMapper::Query::Direction.new(PurchaseOrder.properties
> > > > > [:closed_date], :desc)]
> > > > >  result = PurchaseOrderLineItem.first( 'po.completed.eql' =>
> > > > > 'yes', :order => order_by)
> >
> > > > > But in 0.10, it's broken, I got:
> > > > >  +options[:order]+ entry :closed_date does not map to a property in
> > > > > PurchaseOrderLineItem
> >
> > > > > I must do it wrong in 0.10 or I missed something here, it seems
> like
> > > > > all the properties in the :order option must be a valid property in
> > > > > the model now( here is the PurchaseOrderLineItem), not a property
> of
> > > > > the association. I know I can get a work around by query against on
> > > > > the PurchaseOrder, I just curious is this the desired feature in
> > > > > 0.10.0?
> >
> > > > > Thanks.
> >
> > > > > --Bruce
> >
>

--~--~---------~--~----~------------~-------~--~----~
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