my $colinfo = $result{$col};
my $type_num = $colinfo->{data_type};
my $type_name;
- if(defined $type_num && $dbh->can('type_info')) {
+ if(defined $type_num && $type_num =~ /^\d+\z/ && $dbh->can('type_info')) {
my $type_info = $dbh->type_info($type_num);
$type_name = $type_info->{TYPE_NAME} if $type_info;
$colinfo->{data_type} = $type_name if $type_name;
use strict;
use warnings;
+use namespace::autoclean;
use Class::C3;
use base qw/DBIx::Class::Schema::Loader::DBI/;
use Carp::Clan qw/^DBIx::Class/;
+use List::Util 'first';
our $VERSION = '0.05003';
FROM rdb$triggers t
WHERE t.rdb$relation_name = ?
EOF
-
$sth->execute($table);
while (my ($trigger) = $sth->fetchrow_array) {
- my ($trig_col, $generator) = $trigger =~
-/new\s*.\s*(\w+) \s* = \s* gen_id\s* \( \s* (\w+)/ix;
+ my @trig_cols = $trigger =~ /new\."?(\w+)/ig;
+
+ my ($generator) = $trigger =~
+/(?:gen_id\s* \( \s* |next \s* value \s* for \s*)(\w+)/ix;
- if ($trig_col eq $column) {
+ if (first { lc($_) eq lc($column) } @trig_cols) {
$extra_info{is_auto_increment} = 1;
$extra_info{sequence} = $generator;
}
}
+# fix up DT types, no idea which other types are fucked
+ if ($info->{data_type} eq '11') {
+ $extra_info{data_type} = 'TIMESTAMP';
+ }
+ elsif ($info->{data_type} eq '9') {
+ $extra_info{data_type} = 'DATE';
+ }
+
+# get default
+ $sth = $dbh->prepare(<<'EOF');
+SELECT rf.rdb$default_source
+FROM rdb$relation_fields rf
+WHERE rf.rdb$relation_name = ?
+AND rf.rdb$field_name = ?
+EOF
+ $sth->execute($table, uc $column);
+ my ($default_src) = $sth->fetchrow_array;
+
+ if ($default_src && (my ($def) = $default_src =~ /^DEFAULT \s+ (\S+)/ix)) {
+ if (my ($quoted) = $def =~ /^'(.*?)'\z/) {
+ $extra_info{default_value} = $quoted;
+ }
+ else {
+ $extra_info{default_value} = $def =~ /^\d/ ? $def : \$def;
+ }
+ }
+
return \%extra_info;
}
$tester->skip_tests('You need to set the DBICTEST_FIREBIRD_DSN, _USER, and _PASS environment variables');
}
else {
+ # get rid of stupid warning from InterBase/GetInfo.pm
+ {
+ local $SIG{__WARN__} = sub {};
+ require DBD::InterBase;
+ require DBD::InterBase::GetInfo;
+ }
$tester->run_tests();
}
is( $rsobj1->loader_test1_rsmeth, 'all is still well', 'Result set method' );
}
- ok( $class1->column_info('id')->{is_auto_increment}, 'is_auto_incrment detection' );
+ ok( $class1->column_info('id')->{is_auto_increment}, 'is_auto_increment detection' );
my $obj = $rsobj1->find(1);
is( $obj->id, 1, "Find got the right row" );