... | ... |
@@ -1,4 +1,8 @@ |
1 |
+0.1702 |
|
2 |
+ - removed EXPERIMENTAL status of some methods. |
|
3 |
+ - fixed some join bug |
|
1 | 4 |
0.1701 |
5 |
+ - added DBIx::Cusotm::Order prepend method automatically quoted syntax |
|
2 | 6 |
- simplified arguments check |
3 | 7 |
- added EXPERIMENTAL each_table method |
4 | 8 |
- select method column option [COLUMN, as => ALIAS] format is DEPRECATED! |
... | ... |
@@ -1,7 +1,7 @@ |
1 | 1 |
package DBIx::Custom; |
2 | 2 |
use Object::Simple -base; |
3 | 3 |
|
4 |
-our $VERSION = '0.1701'; |
|
4 |
+our $VERSION = '0.1702'; |
|
5 | 5 |
use 5.008001; |
6 | 6 |
|
7 | 7 |
use Carp 'croak'; |
... | ... |
@@ -1314,15 +1314,21 @@ sub _push_join { |
1314 | 1314 |
|
1315 | 1315 |
# Search table in join clause |
1316 | 1316 |
my $join_clause = $join->[$i]; |
1317 |
+ my $j_clause = (split /\s+on\s+/, $join_clause)[-1]; |
|
1318 |
+ $j_clause =~ s/'.+?'//g; |
|
1317 | 1319 |
my $q_re = quotemeta($q); |
1318 |
- my $join_re = $q ? qr/\s$q_re?([^\.\s$q_re]+?)$q_re?\..+?\s$q_re?([^\.\s$q_re]+?)$q_re?\..+?$/ |
|
1319 |
- : qr/\s([^\.\s]+?)\..+?\s([^\.\s]+?)\..+?$/; |
|
1320 |
- if ($join_clause =~ $join_re) { |
|
1320 |
+ $j_clause =~ s/$q_re//g; |
|
1321 |
+ my $c = $self->safety_character; |
|
1322 |
+ my $join_re = qr/(?:^|\s)($c+)\.$c+\s+=\s+($c+)\.$c+/; |
|
1323 |
+ if ($j_clause =~ $join_re) { |
|
1321 | 1324 |
my $table1 = $1; |
1322 | 1325 |
my $table2 = $2; |
1323 | 1326 |
croak qq{right side table of "$join_clause" must be unique } |
1324 | 1327 |
. _subname |
1325 | 1328 |
if exists $tree->{$table2}; |
1329 |
+ croak qq{Same table "$table1" is specified} . _subname |
|
1330 |
+ if $table1 eq $table2; |
|
1331 |
+ |
|
1326 | 1332 |
$tree->{$table2} |
1327 | 1333 |
= {position => $i, parent => $table1, join => $join_clause}; |
1328 | 1334 |
} |
... | ... |
@@ -1878,7 +1884,7 @@ default to the following values. |
1878 | 1884 |
|
1879 | 1885 |
Filters, registered by C<register_filter> method. |
1880 | 1886 |
|
1881 |
-=head2 C<last_sql> EXPERIMENTAL |
|
1887 |
+=head2 C<last_sql> |
|
1882 | 1888 |
|
1883 | 1889 |
my $last_sql = $dbi->last_sql; |
1884 | 1890 |
$dbi = $dbi->last_sql($last_sql); |
... | ... |
@@ -2054,7 +2060,7 @@ Argument is callback when one column is found. |
2054 | 2060 |
Callback receive four arguments, dbi object, table name, |
2055 | 2061 |
column name and column information. |
2056 | 2062 |
|
2057 |
-=head2 C<each_table> EXPERIMENTAL |
|
2063 |
+=head2 C<each_table> |
|
2058 | 2064 |
|
2059 | 2065 |
$dbi->each_table( |
2060 | 2066 |
sub { |
... | ... |
@@ -2219,7 +2225,7 @@ The above is same as the followin one. |
2219 | 2225 |
|
2220 | 2226 |
$dbi->delete(where => {id1 => 4, id2 => 5}, table => 'book'); |
2221 | 2227 |
|
2222 |
-=item C<prefix> EXPERIMENTAL |
|
2228 |
+=item C<prefix> |
|
2223 | 2229 |
|
2224 | 2230 |
prefix => 'some' |
2225 | 2231 |
|
... | ... |
@@ -2315,7 +2321,7 @@ The above is same as the followin one. |
2315 | 2321 |
table => 'book' |
2316 | 2322 |
); |
2317 | 2323 |
|
2318 |
-=item C<prefix> EXPERIMENTAL |
|
2324 |
+=item C<prefix> |
|
2319 | 2325 |
|
2320 | 2326 |
prefix => 'or replace' |
2321 | 2327 |
|
... | ... |
@@ -2654,7 +2660,7 @@ if C<column> is not specified, '*' is set. |
2654 | 2660 |
|
2655 | 2661 |
column => '*' |
2656 | 2662 |
|
2657 |
-You can specify hash of array reference. This is EXPERIMENTAL. |
|
2663 |
+You can specify hash of array reference. |
|
2658 | 2664 |
|
2659 | 2665 |
column => [ |
2660 | 2666 |
{book => [qw/author title/]}, |
... | ... |
@@ -2716,7 +2722,7 @@ you can pass parameter by C<param> option. |
2716 | 2722 |
join => ['inner join (select * from table2 where table2.key3 = :table2.key3)' . |
2717 | 2723 |
' as table2 on table1.key1 = table2.key1'] |
2718 | 2724 |
|
2719 |
-=itme C<prefix> EXPERIMENTAL |
|
2725 |
+=itme C<prefix> |
|
2720 | 2726 |
|
2721 | 2727 |
prefix => 'SQL_CALC_FOUND_ROWS' |
2722 | 2728 |
|
... | ... |
@@ -2868,7 +2874,7 @@ The above is same as the followin one. |
2868 | 2874 |
table => 'book' |
2869 | 2875 |
); |
2870 | 2876 |
|
2871 |
-=item C<prefix> EXPERIMENTAL |
|
2877 |
+=item C<prefix> |
|
2872 | 2878 |
|
2873 | 2879 |
prefix => 'or replace' |
2874 | 2880 |
|
... | ... |
@@ -488,7 +488,7 @@ By default, filterin is on. |
488 | 488 |
Turn filtering by C<filter> method on. |
489 | 489 |
By default, filterin is on. |
490 | 490 |
|
491 |
-=head2 C<header> EXPERIMENTAL |
|
491 |
+=head2 C<header> |
|
492 | 492 |
|
493 | 493 |
my $header = $result->header; |
494 | 494 |
|
... | ... |
@@ -2168,6 +2168,28 @@ $rows = $dbi->select( |
2168 | 2168 |
)->all; |
2169 | 2169 |
is_deeply($rows, [{latest_table1__key1 => 1}]); |
2170 | 2170 |
|
2171 |
+$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
2172 |
+$dbi->execute($CREATE_TABLE->{0}); |
|
2173 |
+$dbi->execute($CREATE_TABLE->{2}); |
|
2174 |
+$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
2175 |
+$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 4}); |
|
2176 |
+$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 5}); |
|
2177 |
+$result = $dbi->select( |
|
2178 |
+ table => 'table1', |
|
2179 |
+ join => [ |
|
2180 |
+ "left outer join table2 on table2.key2 = '4' and table1.key1 = table2.key1" |
|
2181 |
+ ] |
|
2182 |
+); |
|
2183 |
+is_deeply($result->all, [{key1 => 1, key2 => 2}]); |
|
2184 |
+$result = $dbi->select( |
|
2185 |
+ table => 'table1', |
|
2186 |
+ column => [{table2 => ['key3']}], |
|
2187 |
+ join => [ |
|
2188 |
+ "left outer join table2 on table2.key3 = '4' and table1.key1 = table2.key1" |
|
2189 |
+ ] |
|
2190 |
+); |
|
2191 |
+is_deeply($result->all, [{'table2.key3' => 4}]); |
|
2192 |
+ |
|
2171 | 2193 |
test 'mycolumn'; |
2172 | 2194 |
$dbi = MyDBI8->connect($NEW_ARGS->{0}); |
2173 | 2195 |
$dbi->execute($CREATE_TABLE->{0}); |