... | ... |
@@ -24,9 +24,9 @@ sub parse { |
24 | 24 |
|
25 | 25 |
# Parse |
26 | 26 |
($key || '') =~ /^(?:(.+?)\.)?(.+?)(?:@(.+))?$/; |
27 |
- $self->table($1); |
|
28 |
- $self->column($2); |
|
29 |
- $self->id($3); |
|
27 |
+ $self->table($1 || ''); |
|
28 |
+ $self->column($2 || ''); |
|
29 |
+ $self->id($3 || ''); |
|
30 | 30 |
|
31 | 31 |
return $self; |
32 | 32 |
} |
... | ... |
@@ -177,7 +177,7 @@ sub _build_query { |
177 | 177 |
|
178 | 178 |
# Expand tag using tag processor |
179 | 179 |
my ($expand, $key_infos) |
180 |
- = $tag_processor->($tag_name, $tag_args, $self->table); |
|
180 |
+ = $tag_processor->($tag_name, $tag_args, $self->table || ''); |
|
181 | 181 |
|
182 | 182 |
# Check tag processor return value |
183 | 183 |
croak("Tag processor '$tag_name' must return (\$expand, \$key_infos)") |
... | ... |
@@ -53,17 +53,3 @@ $dbi = DBIx::Custom::Basic->new($NEW_ARGS->{0}); |
53 | 53 |
ok($dbi->filters->{encode_utf8}, "$test : exists default_bind_filter"); |
54 | 54 |
ok($dbi->filters->{decode_utf8}, "$test : exists default_fetch_filter"); |
55 | 55 |
|
56 |
-$ret_val = $dbi->utf8_filter_on; |
|
57 |
-is($dbi->bind_filter, $dbi->filters->{encode_utf8}, 'default bind filter'); |
|
58 |
-is($dbi->fetch_filter, $dbi->filters->{decode_utf8}, 'default fetch filter'); |
|
59 |
-is(ref $ret_val, 'DBIx::Custom::Basic', "$test : retern value"); |
|
60 |
- |
|
61 |
-$decoded_str = 'あ'; |
|
62 |
-$encoded_str = $dbi->bind_filter->($decoded_str); |
|
63 |
-is($encoded_str, encode('UTF-8', $decoded_str), "$test : encode utf8"); |
|
64 |
-is($decoded_str, $dbi->fetch_filter->($encoded_str), "$test : fetch_filter"); |
|
65 |
- |
|
66 |
-$decoded_str = 'a'; |
|
67 |
-$encoded_str = $dbi->bind_filter->($decoded_str); |
|
68 |
-is($encoded_str, encode('UTF-8', $decoded_str), "$test : upgrade and encode utf8"); |
|
69 |
-is($decoded_str, $dbi->fetch_filter->($encoded_str), "$test : fetch_filter"); |
... | ... |
@@ -25,14 +25,14 @@ $datas = [ |
25 | 25 |
tmpl => "a {? k1} b {= k2} {<> k3} {> k4} {< k5} {>= k6} {<= k7} {like k8}", , |
26 | 26 |
sql_expected => "a ? b k2 = ? k3 <> ? k4 > ? k5 < ? k6 >= ? k7 <= ? k8 like ?;", |
27 | 27 |
key_infos_expected => [ |
28 |
- {original_key => 'k1', table => '', column => 'k1', access_keys => [['k1']]}, |
|
29 |
- {original_key => 'k2', table => '', column => 'k2', access_keys => [['k2']]}, |
|
30 |
- {original_key => 'k3', table => '', column => 'k3', access_keys => [['k3']]}, |
|
31 |
- {original_key => 'k4', table => '', column => 'k4', access_keys => [['k4']]}, |
|
32 |
- {original_key => 'k5', table => '', column => 'k5', access_keys => [['k5']]}, |
|
33 |
- {original_key => 'k6', table => '', column => 'k6', access_keys => [['k6']]}, |
|
34 |
- {original_key => 'k7', table => '', column => 'k7', access_keys => [['k7']]}, |
|
35 |
- {original_key => 'k8', table => '', column => 'k8', access_keys => [['k8']]}, |
|
28 |
+ {table => '', column => 'k1', id => ''}, |
|
29 |
+ {table => '', column => 'k2', id => ''}, |
|
30 |
+ {table => '', column => 'k3', id => ''}, |
|
31 |
+ {table => '', column => 'k4', id => ''}, |
|
32 |
+ {table => '', column => 'k5', id => ''}, |
|
33 |
+ {table => '', column => 'k6', id => ''}, |
|
34 |
+ {table => '', column => 'k7', id => ''}, |
|
35 |
+ {table => '', column => 'k8', id => ''}, |
|
36 | 36 |
], |
37 | 37 |
}, |
38 | 38 |
{ |
... | ... |
@@ -40,9 +40,9 @@ $datas = [ |
40 | 40 |
tmpl => "{in k1 3};", |
41 | 41 |
sql_expected => "k1 in (?, ?, ?);", |
42 | 42 |
key_infos_expected => [ |
43 |
- {original_key => 'k1', table => '', column => 'k1', access_keys => [['k1', [0]]]}, |
|
44 |
- {original_key => 'k1', table => '', column => 'k1', access_keys => [['k1', [1]]]}, |
|
45 |
- {original_key => 'k1', table => '', column => 'k1', access_keys => [['k1', [2]]]}, |
|
43 |
+ {table => '', column => 'k1', id => '', pos => 0}, |
|
44 |
+ {table => '', column => 'k1', id => '', pos => 1}, |
|
45 |
+ {table => '', column => 'k1', id => '', pos => 2}, |
|
46 | 46 |
], |
47 | 47 |
}, |
48 | 48 |
|
... | ... |
@@ -52,8 +52,8 @@ $datas = [ |
52 | 52 |
tmpl => "{= a.k1} {= a.k2}", |
53 | 53 |
sql_expected => "a.k1 = ? a.k2 = ?;", |
54 | 54 |
key_infos_expected => [ |
55 |
- {original_key => 'a.k1', table => 'a', column => 'k1', access_keys => [['a.k1'], ['a', 'k1']]}, |
|
56 |
- {original_key => 'a.k2', table => 'a', column => 'k2', access_keys => [['a.k2'], ['a', 'k2']]}, |
|
55 |
+ {table => 'a', column => 'k1', id => ''}, |
|
56 |
+ {table => 'a', column => 'k2', id => ''}, |
|
57 | 57 |
], |
58 | 58 |
}, |
59 | 59 |
{ |
... | ... |
@@ -61,10 +61,10 @@ $datas = [ |
61 | 61 |
tmpl => "{in a.k1 2} {in b.k2 2}", |
62 | 62 |
sql_expected => "a.k1 in (?, ?) b.k2 in (?, ?);", |
63 | 63 |
key_infos_expected => [ |
64 |
- {original_key => 'a.k1', table => 'a', column => 'k1', access_keys => [['a.k1', [0]], ['a', 'k1', [0]]]}, |
|
65 |
- {original_key => 'a.k1', table => 'a', column => 'k1', access_keys => [['a.k1', [1]], ['a', 'k1', [1]]]}, |
|
66 |
- {original_key => 'b.k2', table => 'b', column => 'k2', access_keys => [['b.k2', [0]], ['b', 'k2', [0]]]}, |
|
67 |
- {original_key => 'b.k2', table => 'b', column => 'k2', access_keys => [['b.k2', [1]], ['b', 'k2', [1]]]}, |
|
64 |
+ {table => 'a', column => 'k1', id => '', pos => 0}, |
|
65 |
+ {table => 'a', column => 'k1', id => '', pos => 1}, |
|
66 |
+ {table => 'b', column => 'k2', id => '', pos => 0}, |
|
67 |
+ {table => 'b', column => 'k2', id => '', pos => 1}, |
|
68 | 68 |
], |
69 | 69 |
}, |
70 | 70 |
{ |
... | ... |
@@ -39,10 +39,9 @@ $dbi = DBIx::Custom::SQLite->new; |
39 | 39 |
$dbi->connect_memory; |
40 | 40 |
$ret_val = $dbi->do($CREATE_TABLE->{0}); |
41 | 41 |
ok(defined $ret_val, $test); |
42 |
-$dbi->utf8_filter_on; |
|
43 |
-$dbi->insert('table1', {key1 => 'あ', key2 => 2}); |
|
44 |
-$rows = $dbi->select('table1', {key1 => 'あ'})->fetch_hash_all; |
|
45 |
-is_deeply($rows, [{key1 => 'あ', key2 => 2}], "$test : select rows"); |
|
42 |
+$dbi->insert('table1', {key1 => 'a', key2 => 2}); |
|
43 |
+$rows = $dbi->select('table1', {key1 => 'a'})->fetch_hash_all; |
|
44 |
+is_deeply($rows, [{key1 => 'a', key2 => 2}], "$test : select rows"); |
|
46 | 45 |
|
47 | 46 |
test 'connect_memory error'; |
48 | 47 |
eval{$dbi->connect_memory}; |