Showing 3 changed files with 16 additions and 7 deletions
+1 -1
Changes
... ...
@@ -1,5 +1,5 @@
1 1
 0.1686
2
-    - 
2
+    - set reserved_word_quote automatically from driver name
3 3
 0.1685
4 4
     - insert_at, update_at, delete_at, select_at is DEPRECATED!
5 5
       use insert, update, delete, select method and id option.
+14 -4
lib/DBIx/Custom.pm
... ...
@@ -180,7 +180,7 @@ sub column {
180 180
     # Column clause
181 181
     my @column;
182 182
     $columns ||= [];
183
-    push @column, "$q$table$q.$q$_$q as $q${table}${q}__$q$_$q" for @$columns;
183
+    push @column, "$q$table$q.$q$_$q as $q${table}__$_$q" for @$columns;
184 184
     
185 185
     return join (', ', @column);
186 186
 }
... ...
@@ -274,10 +274,20 @@ sub dbh {
274 274
             croak "connector must have dbh() method " . _subname
275 275
               unless ref $connector && $connector->can('dbh');
276 276
               
277
-            return $self->{dbh} = $connector->dbh;
277
+            $self->{dbh} = $connector->dbh;
278 278
         }
279 279
         
280
-        return $self->{dbh} ||= $self->_connect;
280
+        # Connect
281
+        $self->{dbh} ||= $self->_connect;
282
+        
283
+        # Quote
284
+        unless ($self->reserved_word_quote) {
285
+            my $driver = $self->{dbh}->{Driver}->{Name};
286
+            my $quote = $driver eq 'mysql' ? '`' : '"';
287
+            $self->reserved_word_quote($quote);
288
+        }
289
+
290
+        return $self->{dbh};
281 291
     }
282 292
 }
283 293
 
... ...
@@ -772,7 +782,7 @@ sub new {
772 782
           unless $self->can($attr);
773 783
     }
774 784
     
775
-    # Register tag
785
+    # DEPRECATED!
776 786
     $self->query_builder->{tags} = {
777 787
         '?'     => \&DBIx::Custom::Tag::placeholder,
778 788
         '='     => \&DBIx::Custom::Tag::equal,
+1 -2
t/dbix-custom-core-sqlite.t
... ...
@@ -6,7 +6,7 @@ use utf8;
6 6
 use Encode qw/encode_utf8 decode_utf8/;
7 7
 use Data::Dumper;
8 8
 
9
-#$SIG{__WARN__} = sub { warn $_[0] unless $_[0] =~ /DEPRECATED/};
9
+$SIG{__WARN__} = sub { warn $_[0] unless $_[0] =~ /DEPRECATED/};
10 10
 
11 11
 BEGIN {
12 12
     eval { require DBD::SQLite; 1 }
... ...
@@ -110,7 +110,6 @@ test 'Insert query return value';
110 110
 $dbi->execute($DROP_TABLE->{0});
111 111
 $dbi->execute($CREATE_TABLE->{0});
112 112
 $source = "insert into table1 {insert_param key1 key2}";
113
-$DB::single = 1;
114 113
 $query = $dbi->create_query($source);
115 114
 $ret_val = $dbi->execute($query, param => {key1 => 1, key2 => 2});
116 115
 ok($ret_val);