[Dbix-class] patch for InflateColumn::DateTime

Matt S Trout dbix-class at trout.me.uk
Sat Aug 5 18:22:49 CEST 2006


Mark Hedges wrote:
> 
> On Sat, 5 Aug 2006, Dan Horne wrote:
>>> I could not create an object and set the date field to \q{ NOW() }.
>>>
>>> deflate->() should not do anything if the value is a scalar ref,
>>> but should pass it through as-is so it gets turned into raw SQL.
>>>
>> On a related note I wonder what people think about a db-generic version of
>> "now()" which would be replaced with "now" or "sysdate" or whatever the
>> db-specific implementation should be. It means that you wouldn't need to
>> create a DateTime object in advance just to get the current date for your
>> record.

Yes. But we need a saner SQL generator first.

> I'm thinking 'nevermind' on this anyway.  If you create it this 
> way, then the value in the object is \q{ NOW() } and bombs when 
> you try to access it, unless you re-select from the database.

$obj->discard_changes will do that

I've been pondering some sort of hook that allows us to say "re-select this 
field" - should be a fairly simple resultset op - but it always seems easier 
to just do it on the perl side.

> Sounds too complex to fix it this way.  It's a lot easier to 
> create the field with DateTime->now() than with \q{ NOW() }, and 
> with NTP it's probably about the same anyway.

"Depends". But usually, yes. And I'm not sure having a re-SELECT on every 
INSERT isn't going to be more painful than keeping NTP maintained.



More information about the Dbix-class mailing list