Showing 3 changed files with 25 additions and 5 deletions
+3 -1
Changes
... ...
@@ -1,5 +1,7 @@
1
+0.1726
2
+    - improved join clause parsing
1 3
 0.1725
2
-    - improved join clause parsing.
4
+    - improved join clause parsing
3 5
 0.1724
4 6
     - added EXPERIMENTAL like_value method to DBIx::Custom
5 7
     - sqlfilter option is renamed to after_build_sql, sqlfilter is DEPRECATED!
+4 -4
lib/DBIx/Custom.pm
... ...
@@ -1,7 +1,7 @@
1 1
 package DBIx::Custom;
2 2
 use Object::Simple -base;
3 3
 
4
-our $VERSION = '0.1725';
4
+our $VERSION = '0.1726';
5 5
 use 5.008001;
6 6
 
7 7
 use Carp 'croak';
... ...
@@ -1460,7 +1460,7 @@ sub _push_join {
1460 1460
             
1461 1461
             my @j_clauses = reverse split /\s(and|on)\s/, $j_clause;
1462 1462
             my $c = $self->safety_character;
1463
-            my $join_re = qr/(?:^|\s)($c+)\.$c+\s.+\s($c+)\.$c+/;
1463
+            my $join_re = qr/(?:^|\s)($c+)\.$c+[^$c]+($c+)\.$c+/;
1464 1464
             for my $clause (@j_clauses) {
1465 1465
                 if ($clause =~ $join_re) {
1466 1466
                     $table1 = $1;
... ...
@@ -2205,14 +2205,14 @@ User name, used when C<connect> method is executed.
2205 2205
     my $user_column_info = $dbi->user_column_info;
2206 2206
     $dbi = $dbi->user_column_info($user_column_info);
2207 2207
 
2208
-You can set the following data.
2208
+You can set the date like the following one.
2209 2209
 
2210 2210
     [
2211 2211
         {table => 'book', column => 'title', info => {...}},
2212 2212
         {table => 'author', column => 'name', info => {...}}
2213 2213
     ]
2214 2214
 
2215
-Usually, you can set return value of C<get_column_info>.
2215
+Usually, you set return value of C<get_column_info>.
2216 2216
 
2217 2217
     my $user_column_info
2218 2218
       = $dbi->get_column_info(exclude_table => qr/^system/);
+18
t/sqlite.t
... ...
@@ -268,3 +268,21 @@ $rows = $dbi->select(
268 268
   append => "order by key2 {limit 1}"
269 269
 )->all;
270 270
 is_deeply($rows, [{key1 => 1, key2 => 2}]);
271
+
272
+test 'join function';
273
+$dbi = DBIx::Custom->connect;
274
+eval { $dbi->execute("drop table table1") };
275
+eval { $dbi->execute("drop table table2") };
276
+$dbi->execute($create_table1);
277
+$dbi->execute("create table table2 (key1, key3)");
278
+$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
279
+$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 4});
280
+$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 1});
281
+$result = $dbi->select(
282
+    table => 'table1',
283
+    column => [{table2 => ['key3']}],
284
+    join => [
285
+        "left outer join table2 on coalesce(table2.key3, 0) > '3' and table1.key1 = table2.key1"
286
+    ]
287
+);
288
+is_deeply($result->all, [{"table2.key3" => 4}]);