fREWdiculous!
14 Jan
Yesterday I added a basic but really nice helper to DBIx::Class::Helpers. Say hello to DBIx::Class::Helper::Row::NumifyGet. The reasoning is that often we have bit fields in our database and when we serialize them with JSON we get something like the following:
1 | { 'bit_field':'0'} |
JavaScript has the whole truthy concept like Perl except that in JavaScript “0″ is true, while 0 is false. So NumifyGet will automatically “numify” columns with the is_numeric field set to true. After doing that the json above would become:
1 | { 'bit_field':0} |
Much nicer. Also I added some good docs to DBIx::Class::Helper::ResultSet::Union as well as fixing some latent bugs that were in it.
Enjoy!
One Response for "Latest additions to DBIC::Helpers"
hey,
Meant to message you and will do now before i forget again. We need a tiny tweak to randomize to make sure the storage specific subclass is loaded correctly, otherwise the dispatch table won’t work:
current:
sub _rand_order_by {
return $rand_order_by{ref shift->result_source->storage} || ‘RAND()’;
}
fixed
sub _rand_order_by {
my $self = shift @_;
$self->result_source->storage->ensure_connected;
return $rand_order_by{ref $self->result_source->storage} || ‘RAND()’;
}
Thanks! Let me know if you want a ‘real’ patch (feel free to point me at github or something.)
Leave a reply