dresende/node-orm — Issue #19: Date Support
Author: tingham
Created: 2011-12-03 03:38:41+00:00
State: open

I'm adding an issue here rather than in my own fork because my timeline on the current project is ridiculously short and I probably won't have time to circle around on this until later this month during the break.

I also did not look at the Postgress library but I'd imagine it has the same capability and subsequent issue.

I was attempting to query a date based on date parts; which in php-land is fairly common when you know exactly how the query data is getting to you and you want a specific date. e.g.

select * from log where YEAR(datefield) = 2011;

In the orm this is being expressed as:

Log.find( { "YEAR(`datefield`) =" : 2011 } );

However, previously the orm was back-ticking the code which confused mysql. No biggie, I just added an exception to the number conditions[k] interpretation to allow for a straight pass-thru. I like that the back ticks are getting added for me; but in this case they are not in the right spot. The way I'm doing it now seemed like the least intrusive but it just occurred to me that if I know I'm going to be sending back ticks in my literals anyway; I could probably just skip on those. Have to think about that.

Here's my commit:

https://github.com/tingham/node-orm/commit/54db369b2922e8d818eeef1110bba150622b52e6