I'm finding that if I pass conditions on a query in DM, upon calling first and last on the resulting DataMapper::Collection object, the conditions successively will *double* in the final SQL string, as follows:
locations = Location.all(:conditions => ["id > 0"]) locations.first yields: SELECT `id` FROM `locations` WHERE id > 0 ORDER BY `id` LIMIT 1 then calling locations.last: SELECT `id` FROM `locations` WHERE id > 0 AND id > 0 ORDER BY `id` DESC LIMIT 1 I am writing a plugin[1] for DM that adds conditions to the query when a certain operator is called. It all works fine, even when .first and .last and called successively, but the condition is actually pretty intense, so if I can avoid doubling it that would be ideal. Can anyone replicate this? I want to make sure I'm not doing anything funky in the plugin that is causing this. If you're wondering about the exact code, check out the spec[2] -Matt [1] <http://github.com/mattking17/dm-geokit/tree/master> [2] <http://github.com/mattking17/dm-geokit/blob/944703adce544954fac9cd9dbf84d808dd590a84/spec/dm_geokit_spec.rb#L102 > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
