- table/column comments
- introspect on_update/on_delete/is_deferrable
- introspect view SQL
- - preserve_case mode
- domains
- Firebird
- table/column comments
$self->{db_schema} ||=
($self->schema->storage->dbh->selectrow_array('select user'))[0];
-
- if (not defined $self->preserve_case) {
- $self->preserve_case(0);
- }
}
sub _tables_list {
my $dbh = $self->schema->storage->dbh;
- while (my ($column, $info) = each %$result) {
+ while (my ($col, $info) = each %$result) {
my $def = $info->{default_value};
if (ref $def eq 'SCALAR' && $$def eq 'autoincrement') {
delete $info->{default_value};
$info->{is_auto_increment} = 1;
}
- my ($user_type) = $dbh->selectrow_array(<<'EOF', {}, $table, lc $column);
+ my ($user_type) = $dbh->selectrow_array(<<'EOF', {}, $table, $col);
SELECT ut.type_name
FROM systabcol tc
JOIN systab t ON tc.table_id = t.table_id
SELECT tc.width, tc.scale
FROM systabcol tc
JOIN systab t ON t.table_id = tc.table_id
-WHERE t.table_name = ? AND lower(tc.column_name) = ?
+WHERE t.table_name = ? AND tc.column_name = ?
EOF
- $sth->execute($table, lc $column);
+ $sth->execute($table, $col);
my ($width, $scale) = $sth->fetchrow_array;
$sth->finish;
elsif ($info->{data_type} =~ /^(?:n(?:varchar|char) | varbit)\z/x) {
$info->{size} = $width;
}
+ elsif ($info->{data_type} eq 'float') {
+ $info->{data_type} = 'real';
+ }
delete $info->{default_value} if ref($info->{default_value}) eq 'SCALAR' && ${ $info->{default_value} } eq 'NULL';
my @keydata;
while (my $row = $sth->fetchrow_hashref) {
- push @keydata, lc $row->{column_name};
+ push @keydata, $self->_lc($row->{column_name});
}
return \@keydata;
$sth->execute($table);
while (my ($fk, $local_col, $remote_tab, $remote_col) = $sth->fetchrow_array) {
- push @{$local_cols->{$fk}}, lc $local_col;
- push @{$remote_cols->{$fk}}, lc $remote_col;
- $remote_table->{$fk} = lc $remote_tab;
+ push @{$local_cols->{$fk}}, $self->_lc($local_col);
+ push @{$remote_cols->{$fk}}, $self->_lc($remote_col);
+ $remote_table->{$fk} = $remote_tab;
}
foreach my $fk (keys %$remote_table) {
my $constraints;
while (my ($constraint_name, $column) = $sth->fetchrow_array) {
- push @{$constraints->{$constraint_name}}, lc $column;
+ push @{$constraints->{$constraint_name}}, $self->_lc($column);
}
my @uniqs = map { [ $_ => $constraints->{$_} ] } keys %$constraints;
}
while (my ($col, $info) = each %$result) {
- if (eval { ${ $info->{default_value} } eq 'CURRENT_TIMESTAMP' }) {
+ if (eval { ${ $info->{default_value} } }||'' eq 'CURRENT_TIMESTAMP') {
${ $info->{default_value} } = 'current_timestamp';
}
}
password => $odbc_password,
} : ()),
],
+ loader_options => { preserve_case => 1 },
data_types => {
# http://infocenter.sybase.com/help/topic/com.sybase.help.sqlanywhere.11.0.1/dbreference_en11/rf-datatypes.html
#
# Numeric types
- # XXX rewrite low-precision floats to 'real'
'bit' => { data_type => 'bit' },
'tinyint' => { data_type => 'tinyint' },
'smallint' => { data_type => 'smallint' },
'int' => { data_type => 'integer' },
'integer' => { data_type => 'integer' },
'bigint' => { data_type => 'bigint' },
- 'float' => { data_type => 'float' },
- 'real' => { data_type => 'float' },
+ 'float' => { data_type => 'real' },
+ 'real' => { data_type => 'real' },
'double' => { data_type => 'double precision' },
'double precision' =>
{ data_type => 'double precision' },
- 'float(2)' => { data_type => 'float' },
- 'float(24)' => { data_type => 'float' },
+ 'float(2)' => { data_type => 'real' },
+ 'float(24)' => { data_type => 'real' },
'float(25)' => { data_type => 'double precision' },
'float(53)' => { data_type => 'double precision' },
my $file_count = grep /CREATE (?:TABLE|VIEW)/i, @{ $self->{extra}{create} || [] };
$file_count++; # schema
- $file_count++ if $self->{data_type_tests}{ddl};
+ $file_count++ for @{ $self->{data_type_tests}{table_names} || [] };
my $schema_class = $self->setup_schema($info, $file_count);
my ($monikers, $classes) = $self->monikers_and_classes($schema_class);
my $standard_sources = not defined $expected_count;
if ($standard_sources) {
- $expected_count = 36 + ($self->{data_type_tests}{test_count} ? 1 : 0);
+ $expected_count = 36;
+ $expected_count++ for @{ $self->{data_type_tests}{table_names} || [] };
$expected_count += grep /CREATE (?:TABLE|VIEW)/i,
@{ $self->{extra}{create} || [] };
my $tests = $self->{data_type_tests} = {};
# split types into tables based on overrides
- my @types = keys %$types;
- my @split_off_types = grep /$DATA_TYPE_MULTI_TABLE_OVERRIDES{lc($self->{vendor})}/i, @types;
- my @first_table_types = grep !/$DATA_TYPE_MULTI_TABLE_OVERRIDES{lc($self->{vendor})}/i, @types;
+ my (@types, @split_off_types, @first_table_types);
+ {
+ no warnings 'uninitialized';
+
+ @types = keys %$types;
+ @split_off_types = grep /$DATA_TYPE_MULTI_TABLE_OVERRIDES{lc($self->{vendor})}/i, @types;
+ @first_table_types = grep !/$DATA_TYPE_MULTI_TABLE_OVERRIDES{lc($self->{vendor})}/i, @types;
+ }
@types = +{ map +($_, $types->{$_}), @first_table_types },
map +{ $_, $types->{$_} }, @split_off_types;