Just recently upgraded from 0.9.4 to the current from github on some of my
projects and running into an issue with one query that has me completely
perplexed.  Basically, it looks like the where clause is mapping values to
their intended field incorrectly.
Code:

    search = {}
    search[:region_id] = @region_id
    search[:bid]       = false
    search[:reported_at.gte] = @days.days.ago.to_date
    search[:reported_at.lt]  = Date.today
    search[:order]     = [:reported_at]

    states = OrderHistory.all(search)


DataMapper generated query:

SELECT `id`, `order_id`, `region_id`, `system_id`, `item_id`, `price`,
`volume`, `bid`, `reported_at` FROM `order_histories` WHERE 0=1 AND `bid` =
() AND `reported_at` < FALSE AND `reported_at` >= '2008-08-28' AND
`region_id` = '2008-08-21' ORDER BY `reported_at`


Should actually be:

SELECT `id`, `order_id`, `region_id`, `system_id`, `item_id`, `price`,
`volume`, `bid`, `reported_at` FROM `order_histories` WHERE `bid` = FALSE
AND `reported_at` < '2008-08-28' AND `reported_at` >= '2008-08-21' AND
`region_id` = 10000002 ORDER BY `reported_at`


Things that are incorrect:

   - where did the 0=1 come from?  Since this will always be false, no
   records will ever be returned
   - 'bid' should have been FALSE, not ( )... this actually causes a syntax
   error with the query (how I found the issue)
   - reported_at.lt got what bid should have
   - reported_at.gte got what reported_at.lt should have had
   - region_id got what reported_at.gte should have had

Code worked fine on 0.9.4, but broken with the recent upgrade.

One other odd thing... if I reload the page enough times, it seems to change
which fields the values are matching to, and eventually gets them right, but
then the 0=1 makes it so it returns no records.

Thanks,
  Ken

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