From: Rafael Kitover Date: Wed, 10 Feb 2010 12:05:21 +0000 (+0000) Subject: default to sql dialect 3 unless overridden X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9633951d0f542434fc4f50b23248094d2ac35836;p=dbsrgits%2FDBIx-Class-Historic.git default to sql dialect 3 unless overridden --- diff --git a/lib/DBIx/Class/Storage/DBI/InterBase.pm b/lib/DBIx/Class/Storage/DBI/InterBase.pm index 4baa26c..2908519 100644 --- a/lib/DBIx/Class/Storage/DBI/InterBase.pm +++ b/lib/DBIx/Class/Storage/DBI/InterBase.pm @@ -140,6 +140,29 @@ sub _ping { return $@ ? 0 : 1; } +# We want dialect 3 for new features and quoting to work, DBD::InterBase uses +# dialect 1 (interbase compat) by default. +sub _init { + my $self = shift; + $self->_set_sql_dialect(3); +} + +sub _set_sql_dialect { + my $self = shift; + my $val = shift || 3; + + my $dsn = $self->_dbi_connect_info->[0]; + + return if ref($dsn) eq 'CODE'; + + if ($dsn !~ /ib_dialect=/) { + $self->_dbi_connect_info->[0] = "$dsn;ib_dialect=$val"; + my $connected = defined $self->_dbh; + $self->disconnect; + $self->ensure_connected if $connected; + } +} + =head2 connect_call_datetime_setup Used as: diff --git a/lib/DBIx/Class/Storage/DBI/ODBC/Firebird.pm b/lib/DBIx/Class/Storage/DBI/ODBC/Firebird.pm index 58a3675..16f0ec9 100644 --- a/lib/DBIx/Class/Storage/DBI/ODBC/Firebird.pm +++ b/lib/DBIx/Class/Storage/DBI/ODBC/Firebird.pm @@ -37,6 +37,12 @@ sub build_datetime_parser { ); } +# we don't need DBD::InterBase-specific initialization +sub _init { 1 } + +# ODBC uses dialect 3 by default, good +sub _set_sql_dialect { 1 } + 1; =head1 CAVEATS diff --git a/t/750firebird.t b/t/750firebird.t index b6a845d..981da1e 100644 --- a/t/750firebird.t +++ b/t/750firebird.t @@ -25,7 +25,7 @@ my @info = ( my $schema; foreach my $conn_idx (0..1) { - my ($dsn, $user, $pass) = @{ $info[$conn_idx] }; + my ($dsn, $user, $pass) = @{ $info[$conn_idx] || [] }; next unless $dsn; @@ -211,8 +211,8 @@ sub cleanup { eval { $dbh->do('DROP GENERATOR "gen_artist_artistid"') }; diag $@ if $@; - foreach my $table (qw/"artist" "bindtype_test"/) { - eval { $dbh->do(q[DROP TABLE "$table"]) }; + foreach my $table (qw/artist bindtype_test/) { + eval { $dbh->do(qq[DROP TABLE "$table"]) }; #diag $@ if $@; } }