From: Rafael Kitover Date: Thu, 4 Feb 2010 19:19:51 +0000 (+0000) Subject: override quoting columns for RETURNING in Firebird ODBC (where it doesn't work) and... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1ae0a36c48e132bdd9852248c4db50f889e65719;p=dbsrgits%2FDBIx-Class-Historic.git override quoting columns for RETURNING in Firebird ODBC (where it doesn't work) and generate a RETURNING clause only when necessary --- diff --git a/lib/DBIx/Class/Storage/DBI/InterBase.pm b/lib/DBIx/Class/Storage/DBI/InterBase.pm index 3d206bb..5b9ead7 100644 --- a/lib/DBIx/Class/Storage/DBI/InterBase.pm +++ b/lib/DBIx/Class/Storage/DBI/InterBase.pm @@ -19,17 +19,20 @@ sub _prep_for_execute { my ($sql, $bind) = $self->next::method (@_); if ($op eq 'insert') { - my $quote_char = $self->sql_maker->quote_char || '"'; + my @auto_inc_cols = grep { + my $inserting = $args->[0]{$_}; - my @auto_inc_cols = - grep $ident->column_info($_)->{is_auto_increment}, $ident->columns; + $ident->column_info($_)->{is_auto_increment} && ( + (not defined $inserting) + || + (ref $inserting eq 'SCALAR' && $$inserting eq 'NULL') + ) + } $ident->columns; if (@auto_inc_cols) { my $auto_inc_cols = join ', ', -# XXX quoting the columns breaks ODBC -# map qq{${quote_char}${_}${quote_char}}, - @auto_inc_cols; + map $self->_quote_column_for_returning($_), @auto_inc_cols; $sql .= " RETURNING ($auto_inc_cols)"; @@ -41,6 +44,12 @@ sub _prep_for_execute { return ($sql, $bind); } +sub _quote_column_for_returning { + my ($self, $col) = @_; + + return $self->sql_maker->_quote($col); +} + sub _execute { my $self = shift; my ($op) = @_; diff --git a/lib/DBIx/Class/Storage/DBI/ODBC/Firebird.pm b/lib/DBIx/Class/Storage/DBI/ODBC/Firebird.pm index adfc559..fd13a3b 100644 --- a/lib/DBIx/Class/Storage/DBI/ODBC/Firebird.pm +++ b/lib/DBIx/Class/Storage/DBI/ODBC/Firebird.pm @@ -5,8 +5,6 @@ use warnings; use base qw/DBIx::Class::Storage::DBI::InterBase/; use mro 'c3'; -1; - =head1 NAME DBIx::Class::Storage::DBI::ODBC::Firebird - Driver for using the Firebird RDBMS @@ -17,6 +15,15 @@ through ODBC All functionality is provided by L, see that module for details. +=cut + +# RETURNING ("foo") is broken in ODBC, but RETURNING (foo) works +sub _quote_column_for_returning { + return $_[1]; +} + +1; + =head1 AUTHOR See L and L.