Skip Menu |

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

Report information
The Basics
Id: 57225
Status: resolved
Priority: 0/
Queue: DBIx-Class-Schema-Loader

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

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



Subject: wrong default values from MySQL
Loading a schema from MySQL can result in columns like this: "id_foo", { data_type => "integer", default_value => "", ... }, ...which doesn't make much sense: Integer columns cannot have a string as defalt value. What I do to fix this is to pre-process the column info, before running "deploy()" on the schema: for my $source_name ($schema->sources) { my $source = $schema->source($source_name); my @pk = $source->primary_columns; for my $col_name ($source->columns) { my $col_info = $source->column_info($col_name) or next; unless($col_info->{'data_type'} =~ /varchar/i) { if(defined $col_info->{'default_value'} and $col_info- Show quoted text
>{'default_value'} eq '') {
delete $col_info->{'default_value'}; } } } } $schema->deploy; This seems to happen if a column has "NOT NULL" but no "DEFAULT": CREATE TABLE bar ( id_foo int(10) NOT NULL, );
Subject: Re: [rt.cpan.org #57225] wrong default values from MySQL
Date: Wed, 5 May 2010 17:36:06 -0400
To: Jan Henning Thorsen via RT <bug-DBIx-Class-Schema-Loader [...] rt.cpan.org>
From: Rafael Kitover <rkitover [...] cpan.org>
I couldn't reproduce this, but hopefully I have a fix in git: git://git.shadowcat.co.uk/dbsrgits/DBIx-Class-Schema-Loader.git please try it and let me know. Also, what version of MySQL are you using? On Wed, May 05, 2010 at 09:21:00AM -0400, Jan Henning Thorsen via RT wrote: Show quoted text
> Wed May 05 09:20:58 2010: Request 57225 was acted upon. > Transaction: Ticket created by JHTHORSEN > Queue: DBIx-Class-Schema-Loader > Subject: wrong default values from MySQL > Broken in: 0.06001 > Severity: (no value) > Owner: Nobody > Requestors: JHTHORSEN@cpan.org > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=57225 > > > > Loading a schema from MySQL can result in columns like this: > > "id_foo", { data_type => "integer", default_value => "", ... }, > > ...which doesn't make much sense: Integer columns cannot have a string > as defalt value. What I do to fix this is to pre-process the column > info, before running "deploy()" on the schema: > > for my $source_name ($schema->sources) { > my $source = $schema->source($source_name); > my @pk = $source->primary_columns; > > for my $col_name ($source->columns) { > my $col_info = $source->column_info($col_name) or next; > > unless($col_info->{'data_type'} =~ /varchar/i) { > if(defined $col_info->{'default_value'} and $col_info-
> >{'default_value'} eq '') {
> delete $col_info->{'default_value'}; > } > } > } > } > > $schema->deploy; > > This seems to happen if a column has "NOT NULL" but no "DEFAULT": > > CREATE TABLE bar ( > id_foo int(10) NOT NULL, > ); >
Hopefully fixed in 0.07000, reopen if not.