fixed where clause parsing bug when time(like 00:00...
...:00) contain
... | ... |
@@ -1,4 +1,5 @@ |
1 | 1 |
0.1742 |
2 |
+ - fixed where clause parsing bug when time(like 00:00:00) contain |
|
2 | 3 |
- fixed update_or_insert method bug |
3 | 4 |
- micro optimization |
4 | 5 |
0.1741 |
... | ... |
@@ -1,7 +1,7 @@ |
1 | 1 |
package DBIx::Custom; |
2 | 2 |
use Object::Simple -base; |
3 | 3 |
|
4 |
-our $VERSION = '0.1742'; |
|
4 |
+our $VERSION = '0.1743'; |
|
5 | 5 |
use 5.008001; |
6 | 6 |
|
7 | 7 |
use Carp 'croak'; |
... | ... |
@@ -109,11 +109,17 @@ sub _parse { |
109 | 109 |
my $c = $self->{_safety_character}; |
110 | 110 |
|
111 | 111 |
my $column; |
112 |
- if ($clause =~ /(\s|^)\{/ && $self->{_tag_parse}) { |
|
112 |
+ if ($self->{_tag_parse} && $clause =~ /(\s|^)\{/) { |
|
113 | 113 |
my $columns = $self->dbi->query_builder->build_query($clause)->{columns}; |
114 | 114 |
$column = $columns->[0]; |
115 | 115 |
} |
116 |
- else { ($column) = $clause =~ /:([$c\.]+)/ } |
|
116 |
+ else { |
|
117 |
+ my $sql = $clause; |
|
118 |
+ $sql =~ s/([0-9]):/$1\\:/g; |
|
119 |
+ if ($sql =~ /[^\\]:([$c\.]+)/s || $sql =~ /^:([$c\.]+)/s) { |
|
120 |
+ ($column) = $1; |
|
121 |
+ } |
|
122 |
+ } |
|
117 | 123 |
unless (defined $column) { |
118 | 124 |
push @$where, $clause; |
119 | 125 |
$pushed = 1; |
... | ... |
@@ -1788,6 +1788,23 @@ $result = $dbi->execute("select * from $table1 $where", {$key1 => [0, 1]}); |
1788 | 1788 |
$row = $result->all; |
1789 | 1789 |
is_deeply($row, [{$key1 => 1, $key2 => 2}]); |
1790 | 1790 |
|
1791 |
+ |
|
1792 |
+$dbi = DBIx::Custom->connect; |
|
1793 |
+eval { $dbi->execute("drop table $table1") }; |
|
1794 |
+$dbi->execute($create_table1); |
|
1795 |
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => '00:00:00'}); |
|
1796 |
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => '3'}); |
|
1797 |
+$where = $dbi->where |
|
1798 |
+ ->clause(['and', "$key1 = :$key1", "$key2 = '00:00:00'"]) |
|
1799 |
+ ->param({$key1 => 1}); |
|
1800 |
+ |
|
1801 |
+$result = $dbi->select( |
|
1802 |
+ table => $table1, |
|
1803 |
+ where => $where |
|
1804 |
+); |
|
1805 |
+$row = $result->all; |
|
1806 |
+is_deeply($row, [{$key1 => 1, $key2 => '00:00:00'}]); |
|
1807 |
+ |
|
1791 | 1808 |
test 'register_tag_processor'; |
1792 | 1809 |
$dbi = DBIx::Custom->connect; |
1793 | 1810 |
$dbi->register_tag_processor( |