[Bast-commits] r8544 - in
DBIx-Class/0.08/branches/storage-interbase/lib/DBIx/Class/Storage/DBI:
. ODBC
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Thu Feb 4 19:19:54 GMT 2010
Author: caelum
Date: 2010-02-04 19:19:51 +0000 (Thu, 04 Feb 2010)
New Revision: 8544
Modified:
DBIx-Class/0.08/branches/storage-interbase/lib/DBIx/Class/Storage/DBI/InterBase.pm
DBIx-Class/0.08/branches/storage-interbase/lib/DBIx/Class/Storage/DBI/ODBC/Firebird.pm
Log:
override quoting columns for RETURNING in Firebird ODBC (where it doesn't work) and generate a RETURNING clause only when necessary
Modified: DBIx-Class/0.08/branches/storage-interbase/lib/DBIx/Class/Storage/DBI/InterBase.pm
===================================================================
--- DBIx-Class/0.08/branches/storage-interbase/lib/DBIx/Class/Storage/DBI/InterBase.pm 2010-02-04 18:24:45 UTC (rev 8543)
+++ DBIx-Class/0.08/branches/storage-interbase/lib/DBIx/Class/Storage/DBI/InterBase.pm 2010-02-04 19:19:51 UTC (rev 8544)
@@ -19,17 +19,20 @@
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 @@
return ($sql, $bind);
}
+sub _quote_column_for_returning {
+ my ($self, $col) = @_;
+
+ return $self->sql_maker->_quote($col);
+}
+
sub _execute {
my $self = shift;
my ($op) = @_;
Modified: DBIx-Class/0.08/branches/storage-interbase/lib/DBIx/Class/Storage/DBI/ODBC/Firebird.pm
===================================================================
--- DBIx-Class/0.08/branches/storage-interbase/lib/DBIx/Class/Storage/DBI/ODBC/Firebird.pm 2010-02-04 18:24:45 UTC (rev 8543)
+++ DBIx-Class/0.08/branches/storage-interbase/lib/DBIx/Class/Storage/DBI/ODBC/Firebird.pm 2010-02-04 19:19:51 UTC (rev 8544)
@@ -5,8 +5,6 @@
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 @@
All functionality is provided by L<DBIx::Class::Storage::DBI::Interbase>, 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<DBIx::Class/AUTHOR> and L<DBIx::Class/CONTRIBUTORS>.
More information about the Bast-commits
mailing list