numeric fields and null content

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

numeric fields and null content

Erik Colson
Hi,

In method ‘_eq_column_values’ in DBIx::Class::Row the change comparison is done numerically (==) if the column is ‘_is_column_numeric’. However this will fail if either the $old or $new value is NULL. A check on the ‘is_nullable’ info provided in the schema could check for this before the numeric comparison…

Or am I missing something ?

best
--
erik colson




_______________________________________________
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@...
Reply | Threaded
Open this post in threaded view
|

Re: numeric fields and null content

Peter Rabbitson-2
On Fri, Jun 13, 2014 at 12:45:39AM +0200, Erik Colson wrote:
> Hi,
>
> In method ‘_eq_column_values’ in DBIx::Class::Row the change comparison is done numerically (==) if the column is ‘_is_column_numeric’. However this will fail if either the $old or $new value is NULL. A check on the ‘is_nullable’ info provided in the schema could check for this before the numeric comparison…
>
> Or am I missing something ?

No you aren't. It is in fact a bug. Could you please write me a test that shows the issue?

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@...
Reply | Threaded
Open this post in threaded view
|

Re: numeric fields and null content

Erik Colson

On 13 Jun 2014, at 12:31, Peter Rabbitson <[hidden email]> wrote:

> No you aren't. It is in fact a bug. Could you please write me a test that shows the issue?

Yes I was! I pushed the undef into a wxPerl widget which, when retrieved, returned ''. So when pushing into the DBIx::Class::Row field, I didn’t put undef but ''. So when _eq_column_values was called it executed a numeric comparison which of course fails with ‘’.

The only (documented) issue that could be checked in DBIx::Class is to not allow '' (or any other string) when 'is_numeric' is true ?

best
--
erik colson




_______________________________________________
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@...