Today (pun intended) when we generate SQL for DateTime.Now.Date, for example, we generate this:
strftime('%Y-%m-%d %H:%M:%f', strftime('%Y-%m-%d %H:%M:%f', 'now', 'localtime'), 'start of day')
However, it can simplify to just this: (not surprisingly the same SQL we generate for DateTime.Today)
strftime('%Y-%m-%d %H:%M:%f', 'now', 'localtime', 'start of day')
The logic to do this is fairly simple. Whenever we generate a strftime(format, timestring, modifier...) call, if the timestring argument is another strftime() call:
format parametertimestring parameter directly in its placemodifier arguments (if any) to the current call@bricelam Threw together a PR for this, it's not super slick but it does the job. Let me know if you have any thoughts on ways of making less verbose.
It's more robust than I would've made it. (probably a good thing) 馃槈 Thanks! Will merge when I get a chance...
The rtrim calls force it to be a bit verbose. I can't think of any obvious ways to simplify it.
Thanks, @Muppets! There's just something cool about seeing an O/RM generate such tidy SQL...