Skip Menu |

This queue is for tickets about the DBIx-Class CPAN distribution.

Report information
The Basics
Id: 99546
Status: open
Priority: 0/
Queue: DBIx-Class

People
Owner: Nobody in particular
Requestors: ether [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.08270
Fixed in: (no value)



Subject: DateTime inflation does not preserve formatter information
See also https://rt.cpan.org/Ticket/Display.html?id=99545 When inflating a DateTime using a specific DateTime::Formatter::* class, the formatter is not set on the resulting object - meaning if it is stringified again, the format is not preserved from the original. This leads to surprising results when copying column data around in an application. I propose that DBIx::Class::InflateColumn::DateTime explicitly sets the formatter when inflating, to overcome this. I've prepared a preliminary patch in branch topic/preserve_datetime_formatter.
On 2014-10-16 17:56:08, ETHER wrote: Show quoted text
> See also https://rt.cpan.org/Ticket/Display.html?id=99545 > > When inflating a DateTime using a specific DateTime::Formatter::* > class, the formatter is not set on the resulting object - meaning if > it is stringified again, the format is not preserved from the > original. This leads to surprising results when copying column data > around in an application. > > I propose that DBIx::Class::InflateColumn::DateTime explicitly sets > the formatter when inflating, to overcome this. I've prepared a > preliminary patch in branch topic/preserve_datetime_formatter.
Alternatively, if this patch (or the intent thereof) is not acceptable, can we extend _post_inflate_datetime to also set the formatter field, if defined in $info? at the moment only the timezone and locale information can be set this way. I have been unable to find any other hooks in my application to add on extra inflation logic.
On Fri Oct 17 03:00:06 2014, ETHER wrote: Show quoted text
> On 2014-10-16 17:56:08, ETHER wrote:
> > See also https://rt.cpan.org/Ticket/Display.html?id=99545 > > > > When inflating a DateTime using a specific DateTime::Formatter::* > > class, the formatter is not set on the resulting object - meaning if > > it is stringified again, the format is not preserved from the > > original. This leads to surprising results when copying column data > > around in an application.
Can you explain the issue in more detail? The only thing I can think of is using data from Result Objects in search(), which is broken by design and should remain so without extra bandaids. Show quoted text
> > > > I propose that DBIx::Class::InflateColumn::DateTime explicitly sets > > the formatter when inflating, to overcome this. I've prepared a > > preliminary patch in branch topic/preserve_datetime_formatter.
>
The patch in the branch is not acceptable for the same reason as outlined in https://rt.cpan.org/Ticket/Display.html?id=99545#txn-1421646 - it is a very strong behavioral change. Show quoted text
> Alternatively, if this patch (or the intent thereof) is not > acceptable, can we extend _post_inflate_datetime to also set the > formatter field, if defined in $info? at the moment only the timezone > and locale information can be set this way. I have been unable to > find any other hooks in my application to add on extra inflation > logic.
The general approach to augmenting IC::DT functionality is in fact to around() _post_inflate_datetime. There is a gray area of methods in DBIC which are private enough to never be called from the outside but not private enough to not be overloaded. I have not come across a good way of documenting this duality (see https://metacpan.org/pod/DBIx::Class::Ordered#METHODS-FOR-EXTENDING-ORDERED for a clumsy attempt) I am also open to add an extra column_info flag. The name is tricky because it *must* be able to accept a different formatter than the one used to talk to the database (the column info settings have to do with display, not with storage). I am thinking something like set_formatter => [class-name|1] where 1 means "use the storage formatter". But first of all - explain your actual use case for this.