Skip Menu |

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

Report information
The Basics
Id: 45191
Status: new
Priority: 0/
Queue: DBIx-Class-HTMLWidget

People
Owner: Nobody in particular
Requestors: samborsky_d [...] yahoo.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.16
Fixed in: (no value)



Subject: several bugs with MySQL DBIx driver
Hi! I use DBIx-Class-HTMLWidget with MySQL and I had to fix several issues. See the attached patch file. There were three problems: 1) fill_widget() - I had to comment out line 20: #next if ($element->value()); Otherwise, hidden 'id' field gets value=1 instead of the real one. 2) It's necessary to ignore DBIx columns that have no corresponding widget in the form, so I added this after line 27: next if !exists($result->params->{$col}); 3) Apparently, MySQL driver has different names for some column types, 'int' and 'decimal' were added to the list in line 47: if ($col_info->{data_type} and $col_info->{data_type} =~ m/^timestamp|date|int|integer|numeric|decimal/i Regards, Dmitry
Subject: fix.patch
--- DBIx-Class-HTMLWidget-0.16/lib/DBIx/Class/HTMLWidget.pm.ORIG 2008-02-06 13:52:36.000000000 +0300 +++ DBIx-Class-HTMLWidget-0.16/lib/DBIx/Class/HTMLWidget.pm 2009-04-21 19:05:45.000000000 +0400 @@ -17,7 +17,7 @@ foreach my $element ( @real_elements ) { my $name=$element->name; next unless $name && $dbic->can($name) && $element->can('value'); - next if ($element->value()); + #next if ($element->value()); if($element->isa('HTML::Widget::Element::Checkbox')) { $element->checked($dbic->$name?1:0); } else { @@ -42,9 +42,10 @@ $result->find_elements; foreach my $col ( $dbic->result_source->columns ) { + next if !exists($result->params->{$col}); my $col_info = $dbic->column_info($col); my $value = scalar($result->param($col)); - if ($col_info->{data_type} and $col_info->{data_type} =~ m/^timestamp|date|integer|numeric/i + if ($col_info->{data_type} and $col_info->{data_type} =~ m/^timestamp|date|int|integer|numeric|decimal/i and defined $value and $value eq '') { $value = undef; $dbic->$col(undef);