Subject: | default CURRENT_TIMESTAMP in mysql produces faulty sql |
When using MySQL builtin function CURRENT_TIMESTAMP for default values,
Schema::Loader translates this into (see Test.pm):
default_value => "CURRENT_TIMESTAMP"
instead of:
default_value => \'CURRENT_TIMESTAMP'
attached files:
test.sql : SQL used to produce MySQL table
dumpdeploy.pl : test script
dumpdeploy.stdout : standard output of dumpdeploy.pl
Test.pm : perl file as generated by dumpdeploy.pl
using dump_to_dir
Tested on a Debian 5 i386 using perl 5.10.0
Subject: | Test.pm |
package Some::Schema::Loader::Test;
use strict;
use warnings;
use base 'DBIx::Class';
__PACKAGE__->load_components("Core");
__PACKAGE__->table("test");
__PACKAGE__->add_columns(
"id",
{
data_type => "INT",
default_value => undef,
extra => { unsigned => 1 },
is_nullable => 0,
size => 10,
},
"somedate",
{
data_type => "TIMESTAMP",
default_value => "CURRENT_TIMESTAMP",
is_nullable => 0,
size => 14,
},
);
__PACKAGE__->set_primary_key("id");
# Created by DBIx::Class::Schema::Loader v0.04999_07 @ 2009-08-11 23:59:00
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:F0wJy+6R+SlGV5J51x9nmA
# You can replace this text with custom content, and it will be preserved on regeneration
1;
Subject: | dumpdeploy.stdout |
Message body not shown because it is not plain text.
Subject: | dumpdeploy.pl |
#!/usr/bin/perl
use strict;
use warnings;
package Some::Schema::Loader;
use base qw/DBIx::Class::Schema::Loader/;
__PACKAGE__ -> loader_options (
dump_directory => '/tmp',
constraint => '^(test)$',
);
# Constants
our $dbname = "ABC";
our $dburo = "DEF";
our $dbpro = "GHI";
our $dbhost = "jkl";
sub new {
my $self = shift;
$self->connect(
"dbi:mysql:dbname=$dbname:host=$dbhost",
$dburo,
$dbpro,
);
}
1;
package main;
my $schema = Some::Schema::Loader -> new();
$schema -> dump_to_dir;
print $schema -> deployment_statements, "\n";
1;
Subject: | test.sql |
Message body not shown because it is not plain text.