The problem originates in DBI drivers, so I don't think DBIC can fix it in the 
general case. You could potentially try and add smarts so that for drivers like 
Oracle and ODBC you avoid stringifying the values unnecessarily, and I suppose 
you could force numeric for other databases when you read the values rather 
than when the user asks for them. But as you said, you'd have to evaluate a lot 
of code paths. In the interim, numifying when the user asks for the value seems 
simple. If there is some other way of accessing values that needs to be trapped 
so that they are numifyed, I'll update those as well, but nobody has indicated 
that I missed anything.
As for performance, my understanding is that extracting the numeric part of a 
scalar is essentially free. If checking to see whether a column is numeric is 
expensive, then that should be cached when the column is created/configured, 
and not recalculated when extracting values. If it's really important, this can 
be reduced to one hash lookup, one comparison, and one conditional jump. This 
is admittedly not free, but it's pretty damn cheap. In all fairness, anybody 
who cares about this probably isn't going to use a heavy ORM tool in the first 
place. Hell, witness the fact that most of the database drivers haven't fixed 
this problem; nobody seems to care about performance *that much*.

Thanks-
Augustus

On Feb 26, 2015, at 5:32 AM, Peter Rabbitson <rabbit+d...@rabbit.us> wrote:

> On 02/26/2015 12:30 AM, Augustus Saunders wrote:
>> Seems a little backwards to create a helper to work around a core defect. 
>> This is something that should work transparently, and is very simple to do 
>> so.
> 
> You are correct in your overall diagnosis, you are incorrect wrt the detail 
> and the solution.
> 
> The problem is that DBIC "touches" some of the values returned from the DBD 
> (even something as innocuous as $something->{$column_value} is enough to 
> break the assumptions of a naive serializer).
> 
> The solution is to eliminate all these instances, and definitively not 
> introducing expensive operations on every single value retrieval. Some work 
> has been planned for this, but an audit of all code paths is decidedly not an 
> easy task (and having an incomplete fix in this case is worse than not having 
> any at all).
> 
> For the time being if you need proper *dependable* numeric semantics you 
> should use the ::Row::NumifyGet helper as suggested, until its documentation 
> is updated with 'DBIC now does this automatically'.
> 
> Cheers
> 
> 
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk


_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk

Reply via email to