... | ... |
@@ -1,3 +1,6 @@ |
1 |
+0.1640 |
|
2 |
+ removed experimental DBIx::Custom::Table base() method |
|
3 |
+ table created by tabled method can call base_$method correponding to base_table's one |
|
1 | 4 |
0.1641 |
2 | 5 |
select() where can't receive array reference to prevend SQL injection easily(not backward compatible. sorry. use where() instead) |
3 | 6 |
added experimental safety_column_name attribute |
... | ... |
@@ -1,6 +1,6 @@ |
1 | 1 |
package DBIx::Custom; |
2 | 2 |
|
3 |
-our $VERSION = '0.1641'; |
|
3 |
+our $VERSION = '0.1642'; |
|
4 | 4 |
|
5 | 5 |
use 5.008001; |
6 | 6 |
use strict; |
... | ... |
@@ -590,14 +590,15 @@ sub table { |
590 | 590 |
# Copy Methods |
591 | 591 |
my $methods = {}; |
592 | 592 |
$methods->{$_} = $bmethods->{$_} for keys %$bmethods; |
593 |
+ $methods->{"base_$_"} = $bmethods->{$_} for keys %$bmethods; |
|
593 | 594 |
|
594 | 595 |
# Create table |
595 | 596 |
my $table = $base_table->new( |
596 | 597 |
dbi => $self, |
597 | 598 |
name => $name, |
598 |
- base => $base_table, |
|
599 |
- _methods => $methods |
|
600 | 599 |
); |
600 |
+ $table->method($methods); |
|
601 |
+ |
|
601 | 602 |
$self->{_tables}->{$name} = $table; |
602 | 603 |
} |
603 | 604 |
|
... | ... |
@@ -10,7 +10,7 @@ use Carp 'croak'; |
10 | 10 |
# Carp trust relationship |
11 | 11 |
push @DBIx::Custom::CARP_NOT, __PACKAGE__; |
12 | 12 |
|
13 |
-__PACKAGE__->attr(['dbi', 'name', 'base']); |
|
13 |
+__PACKAGE__->attr(['dbi', 'name']); |
|
14 | 14 |
|
15 | 15 |
our $AUTOLOAD; |
16 | 16 |
|
... | ... |
@@ -1245,30 +1245,22 @@ is($result->stash->{foo}, 1, 'get and set'); |
1245 | 1245 |
test 'base_table'; |
1246 | 1246 |
$dbi = DBIx::Custom->new; |
1247 | 1247 |
$dbi->base_table->method( |
1248 |
- one => sub { 1 } |
|
1248 |
+ twice => sub { |
|
1249 |
+ my $self = shift; |
|
1250 |
+ |
|
1251 |
+ return $_[0] * 2; |
|
1252 |
+ } |
|
1249 | 1253 |
); |
1250 | 1254 |
$table = $dbi->table('book'); |
1251 | 1255 |
$table->method( |
1252 |
- two => sub { 2 } |
|
1256 |
+ three_times => sub { |
|
1257 |
+ my $self = shift; |
|
1258 |
+ return $_[0] * 3; |
|
1259 |
+ } |
|
1253 | 1260 |
); |
1254 |
-is($dbi->base_table->one, 1, 'method'); |
|
1255 |
-is($table->one, 1, 'inherit method'); |
|
1256 |
-is($table->two, 2, 'child table method'); |
|
1257 |
-eval {$dbi->base_table->two}; |
|
1261 |
+is($table->base_twice(1), 2, 'method'); |
|
1262 |
+is($table->twice(1), 2, 'inherit method'); |
|
1263 |
+is($table->three_times(1), 3, 'child table method'); |
|
1264 |
+eval {$dbi->base_two}; |
|
1258 | 1265 |
ok($@); |
1259 | 1266 |
|
1260 |
-$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
1261 |
-$dbi->execute($CREATE_TABLE->{0}); |
|
1262 |
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
1263 |
-$result = $dbi->base_table->execute("select * from table1"); |
|
1264 |
-is_deeply($result->fetch_hash_all, [{key1 => 1, key2 => 2}], 'dbi method from base_table'); |
|
1265 |
-$result = $dbi->table('table1')->execute("select * from table1"); |
|
1266 |
-is_deeply($result->fetch_hash_all, [{key1 => 1, key2 => 2}], 'dbi method from table'); |
|
1267 |
- |
|
1268 |
-$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
1269 |
-$dbi->method( |
|
1270 |
- one => sub { 1 } |
|
1271 |
-); |
|
1272 |
-is($dbi->base_table->one, 1, 'use dbi method'); |
|
1273 |
-is($dbi->table('table1')->one, 1, 'use dbi method'); |
|
1274 |
- |