| ... | ... |
@@ -1,3 +1,11 @@ |
| 1 |
+0.0605 |
|
| 2 |
+ fix encode_utf8 filter |
|
| 3 |
+0.0604 |
|
| 4 |
+ fix timeformat tests |
|
| 5 |
+0.0603 |
|
| 6 |
+ fix cache system bug |
|
| 7 |
+0.0602 |
|
| 8 |
+ update document |
|
| 1 | 9 |
0.0601 |
| 2 | 10 |
bind_filter argument is changed to ($value, $key, $dbi, $infos) (not backword compatible) |
| 3 | 11 |
fetch_filter argument is changed to ($value, $key, $dbi, $infos) (not backword compatible) |
| ... | ... |
@@ -3,7 +3,7 @@ use 5.008001; |
| 3 | 3 |
package DBIx::Custom; |
| 4 | 4 |
use Object::Simple; |
| 5 | 5 |
|
| 6 |
-our $VERSION = '0.0602'; |
|
| 6 |
+our $VERSION = '0.0605'; |
|
| 7 | 7 |
|
| 8 | 8 |
use Carp 'croak'; |
| 9 | 9 |
use DBI; |
| ... | ... |
@@ -198,10 +198,15 @@ sub create_query {
|
| 198 | 198 |
my $sql_template = $self->sql_template; |
| 199 | 199 |
|
| 200 | 200 |
# Try to get cached query |
| 201 |
- my $query = $class->_query_caches->{$template};
|
|
| 201 |
+ my $cached_query = $class->_query_caches->{$template};
|
|
| 202 | 202 |
|
| 203 | 203 |
# Create query |
| 204 |
- unless ($query) {
|
|
| 204 |
+ my $query; |
|
| 205 |
+ if ($query) {
|
|
| 206 |
+ $query = $self->new(sql => $cached_query->sql, |
|
| 207 |
+ key_infos => $cached_query->key_infos); |
|
| 208 |
+ } |
|
| 209 |
+ else {
|
|
| 205 | 210 |
$query = eval{$sql_template->create_query($template)};
|
| 206 | 211 |
croak($@) if $@; |
| 207 | 212 |
|
| ... | ... |
@@ -10,6 +10,7 @@ my $class = __PACKAGE__; |
| 10 | 10 |
$class->add_filter( |
| 11 | 11 |
encode_utf8 => sub {
|
| 12 | 12 |
my $value = shift; |
| 13 |
+ return $value unless defined $value; |
|
| 13 | 14 |
utf8::upgrade($value) unless Encode::is_utf8($value); |
| 14 | 15 |
return encode('UTF-8', $value);
|
| 15 | 16 |
}, |
| ... | ... |
@@ -741,8 +741,18 @@ is_deeply(DBIx::Custom->_query_cache_keys, [@tmpls[1, 2]], "$test : cache key th |
| 741 | 741 |
$queries[1] = $dbi->create_query($tmpls[1]); |
| 742 | 742 |
ok(!exists DBIx::Custom->_query_caches->{$tmpls[0]}, "$test : cache overflow deleted key");
|
| 743 | 743 |
is(DBIx::Custom->_query_caches->{$tmpls[1]}{sql}, $queries[1]->sql, "$test : sql cache overflow deleted key");
|
| 744 |
-is(DBIx::Custom->_query_caches->{$tmpls[1]}{key_infos}, $queries[1]->key_infos, "$test : key_infos cache overflow deleted key");
|
|
| 744 |
+is_deeply(DBIx::Custom->_query_caches->{$tmpls[1]}{key_infos}, $queries[1]->key_infos, "$test : key_infos cache overflow deleted key");
|
|
| 745 |
+isnt(DBIx::Custom->_query_caches->{$tmpls[1]}{key_infos}, $queries[1]->key_infos, "$test : key_infos cache overflow deleted key");
|
|
| 745 | 746 |
is(DBIx::Custom->_query_caches->{$tmpls[2]}{sql}, $queries[2]->sql, "$test : sql cache overflow deleted key");
|
| 746 |
-is(DBIx::Custom->_query_caches->{$tmpls[2]}{key_infos}, $queries[2]->key_infos, "$test : key_infos cache overflow deleted key");
|
|
| 747 |
+is_deeply(DBIx::Custom->_query_caches->{$tmpls[2]}{key_infos}, $queries[2]->key_infos, "$test : key_infos cache overflow deleted key");
|
|
| 747 | 748 |
is_deeply(DBIx::Custom->_query_cache_keys, [@tmpls[1, 2]], "$test : cache key third"); |
| 748 | 749 |
|
| 750 |
+$query = $dbi->create_query($tmpls[0]); |
|
| 751 |
+$query->bind_filter('aaa');
|
|
| 752 |
+$query = $dbi->create_query($tmpls[0]); |
|
| 753 |
+ok(!$query->bind_filter, "$test : only cached sql and key_infos"); |
|
| 754 |
+$query->bind_filter('bbb');
|
|
| 755 |
+$query = $dbi->create_query($tmpls[0]); |
|
| 756 |
+ok(!$query->bind_filter, "$test : only cached sql and key_infos"); |
|
| 757 |
+ |
|
| 758 |
+ |
| ... | ... |
@@ -34,52 +34,52 @@ $dbi = DBIx::Custom::MySQL->new; |
| 34 | 34 |
$data = '2009-01-02 03:04:05'; |
| 35 | 35 |
$format = $dbi->formats->{'SQL99_datetime'};
|
| 36 | 36 |
$timepiece = Time::Piece->strptime($data, $format); |
| 37 |
-is($timepiece->strftime('%F'), '2009-01-02', "$test : datetime date");
|
|
| 38 |
-is($timepiece->strftime('%T'), '03:04:05', "$test : datetime time");
|
|
| 37 |
+is($timepiece->strftime('%Y-%m-%d'), '2009-01-02', "$test : datetime date");
|
|
| 38 |
+is($timepiece->strftime('%H:%M:%S'), '03:04:05', "$test : datetime time");
|
|
| 39 | 39 |
|
| 40 | 40 |
$data = '2009-01-02'; |
| 41 | 41 |
$format = $dbi->formats->{'SQL99_date'};
|
| 42 | 42 |
$timepiece = Time::Piece->strptime($data, $format); |
| 43 |
-is($timepiece->strftime('%F'), '2009-01-02', "$test : date");
|
|
| 43 |
+is($timepiece->strftime('%Y-%m-%d'), '2009-01-02', "$test : date");
|
|
| 44 | 44 |
|
| 45 | 45 |
$data = '03:04:05'; |
| 46 | 46 |
$format = $dbi->formats->{'SQL99_time'};
|
| 47 | 47 |
$timepiece = Time::Piece->strptime($data, $format); |
| 48 |
-is($timepiece->strftime('%T'), '03:04:05', "$test : time");
|
|
| 48 |
+is($timepiece->strftime('%H:%M:%S'), '03:04:05', "$test : time");
|
|
| 49 | 49 |
|
| 50 | 50 |
|
| 51 | 51 |
test 'ISO-8601 format'; |
| 52 | 52 |
$data = '2009-01-02T03:04:05'; |
| 53 | 53 |
$format = $dbi->formats->{'ISO-8601_datetime'};
|
| 54 | 54 |
$timepiece = Time::Piece->strptime($data, $format); |
| 55 |
-is($timepiece->strftime('%F'), '2009-01-02', "$test : datetime date");
|
|
| 56 |
-is($timepiece->strftime('%T'), '03:04:05', "$test : datetime time");
|
|
| 55 |
+is($timepiece->strftime('%Y-%m-%d'), '2009-01-02', "$test : datetime date");
|
|
| 56 |
+is($timepiece->strftime('%H:%M:%S'), '03:04:05', "$test : datetime time");
|
|
| 57 | 57 |
|
| 58 | 58 |
$data = '2009-01-02'; |
| 59 | 59 |
$format = $dbi->formats->{'ISO-8601_date'};
|
| 60 | 60 |
$timepiece = Time::Piece->strptime($data, $format); |
| 61 |
-is($timepiece->strftime('%F'), '2009-01-02', "$test : date");
|
|
| 61 |
+is($timepiece->strftime('%Y-%m-%d'), '2009-01-02', "$test : date");
|
|
| 62 | 62 |
|
| 63 | 63 |
$data = '03:04:05'; |
| 64 | 64 |
$format = $dbi->formats->{'ISO-8601_time'};
|
| 65 | 65 |
$timepiece = Time::Piece->strptime($data, $format); |
| 66 |
-is($timepiece->strftime('%T'), '03:04:05', "$test : time");
|
|
| 66 |
+is($timepiece->strftime('%H:%M:%S'), '03:04:05', "$test : time");
|
|
| 67 | 67 |
|
| 68 | 68 |
|
| 69 | 69 |
test 'default format'; |
| 70 | 70 |
$data = '2009-01-02 03:04:05'; |
| 71 | 71 |
$format = $dbi->formats->{'datetime'};
|
| 72 | 72 |
$timepiece = Time::Piece->strptime($data, $format); |
| 73 |
-is($timepiece->strftime('%F'), '2009-01-02', "$test : datetime date");
|
|
| 74 |
-is($timepiece->strftime('%T'), '03:04:05', "$test : datetime time");
|
|
| 73 |
+is($timepiece->strftime('%Y-%m-%d'), '2009-01-02', "$test : datetime date");
|
|
| 74 |
+is($timepiece->strftime('%H:%M:%S'), '03:04:05', "$test : datetime time");
|
|
| 75 | 75 |
|
| 76 | 76 |
$data = '2009-01-02'; |
| 77 | 77 |
$format = $dbi->formats->{'date'};
|
| 78 | 78 |
$timepiece = Time::Piece->strptime($data, $format); |
| 79 |
-is($timepiece->strftime('%F'), '2009-01-02', "$test : date");
|
|
| 79 |
+is($timepiece->strftime('%Y-%m-%d'), '2009-01-02', "$test : date");
|
|
| 80 | 80 |
|
| 81 | 81 |
$data = '03:04:05'; |
| 82 | 82 |
$format = $dbi->formats->{'time'};
|
| 83 | 83 |
$timepiece = Time::Piece->strptime($data, $format); |
| 84 |
-is($timepiece->strftime('%T'), '03:04:05', "$test : time");
|
|
| 84 |
+is($timepiece->strftime('%H:%M:%S'), '03:04:05', "$test : time");
|
|
| 85 | 85 |
|
| ... | ... |
@@ -34,52 +34,52 @@ $dbi = DBIx::Custom::SQLite->new; |
| 34 | 34 |
$data = '2009-01-02 03:04:05'; |
| 35 | 35 |
$format = $dbi->formats->{'SQL99_datetime'};
|
| 36 | 36 |
$timepiece = Time::Piece->strptime($data, $format); |
| 37 |
-is($timepiece->strftime('%F'), '2009-01-02', "$test : datetime date");
|
|
| 38 |
-is($timepiece->strftime('%T'), '03:04:05', "$test : datetime time");
|
|
| 37 |
+is($timepiece->strftime('%Y-%m-%d'), '2009-01-02', "$test : datetime date");
|
|
| 38 |
+is($timepiece->strftime('%H:%M:%S'), '03:04:05', "$test : datetime time");
|
|
| 39 | 39 |
|
| 40 | 40 |
$data = '2009-01-02'; |
| 41 | 41 |
$format = $dbi->formats->{'SQL99_date'};
|
| 42 | 42 |
$timepiece = Time::Piece->strptime($data, $format); |
| 43 |
-is($timepiece->strftime('%F'), '2009-01-02', "$test : date");
|
|
| 43 |
+is($timepiece->strftime('%Y-%m-%d'), '2009-01-02', "$test : date");
|
|
| 44 | 44 |
|
| 45 | 45 |
$data = '03:04:05'; |
| 46 | 46 |
$format = $dbi->formats->{'SQL99_time'};
|
| 47 | 47 |
$timepiece = Time::Piece->strptime($data, $format); |
| 48 |
-is($timepiece->strftime('%T'), '03:04:05', "$test : time");
|
|
| 48 |
+is($timepiece->strftime('%H:%M:%S'), '03:04:05', "$test : time");
|
|
| 49 | 49 |
|
| 50 | 50 |
|
| 51 | 51 |
test 'ISO-8601 format'; |
| 52 | 52 |
$data = '2009-01-02T03:04:05'; |
| 53 | 53 |
$format = $dbi->formats->{'ISO-8601_datetime'};
|
| 54 | 54 |
$timepiece = Time::Piece->strptime($data, $format); |
| 55 |
-is($timepiece->strftime('%F'), '2009-01-02', "$test : datetime date");
|
|
| 56 |
-is($timepiece->strftime('%T'), '03:04:05', "$test : datetime time");
|
|
| 55 |
+is($timepiece->strftime('%Y-%m-%d'), '2009-01-02', "$test : datetime date");
|
|
| 56 |
+is($timepiece->strftime('%H:%M:%S'), '03:04:05', "$test : datetime time");
|
|
| 57 | 57 |
|
| 58 | 58 |
$data = '2009-01-02'; |
| 59 | 59 |
$format = $dbi->formats->{'ISO-8601_date'};
|
| 60 | 60 |
$timepiece = Time::Piece->strptime($data, $format); |
| 61 |
-is($timepiece->strftime('%F'), '2009-01-02', "$test : date");
|
|
| 61 |
+is($timepiece->strftime('%Y-%m-%d'), '2009-01-02', "$test : date");
|
|
| 62 | 62 |
|
| 63 | 63 |
$data = '03:04:05'; |
| 64 | 64 |
$format = $dbi->formats->{'ISO-8601_time'};
|
| 65 | 65 |
$timepiece = Time::Piece->strptime($data, $format); |
| 66 |
-is($timepiece->strftime('%T'), '03:04:05', "$test : time");
|
|
| 66 |
+is($timepiece->strftime('%H:%M:%S'), '03:04:05', "$test : time");
|
|
| 67 | 67 |
|
| 68 | 68 |
|
| 69 | 69 |
test 'default format'; |
| 70 | 70 |
$data = '2009-01-02 03:04:05'; |
| 71 | 71 |
$format = $dbi->formats->{'datetime'};
|
| 72 | 72 |
$timepiece = Time::Piece->strptime($data, $format); |
| 73 |
-is($timepiece->strftime('%F'), '2009-01-02', "$test : datetime date");
|
|
| 74 |
-is($timepiece->strftime('%T'), '03:04:05', "$test : datetime time");
|
|
| 73 |
+is($timepiece->strftime('%Y-%m-%d'), '2009-01-02', "$test : datetime date");
|
|
| 74 |
+is($timepiece->strftime('%H:%M:%S'), '03:04:05', "$test : datetime time");
|
|
| 75 | 75 |
|
| 76 | 76 |
$data = '2009-01-02'; |
| 77 | 77 |
$format = $dbi->formats->{'date'};
|
| 78 | 78 |
$timepiece = Time::Piece->strptime($data, $format); |
| 79 |
-is($timepiece->strftime('%F'), '2009-01-02', "$test : date");
|
|
| 79 |
+is($timepiece->strftime('%Y-%m-%d'), '2009-01-02', "$test : date");
|
|
| 80 | 80 |
|
| 81 | 81 |
$data = '03:04:05'; |
| 82 | 82 |
$format = $dbi->formats->{'time'};
|
| 83 | 83 |
$timepiece = Time::Piece->strptime($data, $format); |
| 84 |
-is($timepiece->strftime('%T'), '03:04:05', "$test : time");
|
|
| 84 |
+is($timepiece->strftime('%H:%M:%S'), '03:04:05', "$test : time");
|
|
| 85 | 85 |
|
| ... | ... |
@@ -34,34 +34,34 @@ $dbi = DBIx::Custom::Basic->new; |
| 34 | 34 |
$data = '2009-01-02 03:04:05'; |
| 35 | 35 |
$format = $dbi->formats->{'SQL99_datetime'};
|
| 36 | 36 |
$timepiece = Time::Piece->strptime($data, $format); |
| 37 |
-is($timepiece->strftime('%F'), '2009-01-02', "$test : datetime date");
|
|
| 38 |
-is($timepiece->strftime('%T'), '03:04:05', "$test : datetime time");
|
|
| 37 |
+is($timepiece->strftime('%Y-%m-%d'), '2009-01-02', "$test : datetime date");
|
|
| 38 |
+is($timepiece->strftime('%H:%M:%S'), '03:04:05', "$test : datetime time");
|
|
| 39 | 39 |
|
| 40 | 40 |
$data = '2009-01-02'; |
| 41 | 41 |
$format = $dbi->formats->{'SQL99_date'};
|
| 42 | 42 |
$timepiece = Time::Piece->strptime($data, $format); |
| 43 |
-is($timepiece->strftime('%F'), '2009-01-02', "$test : date");
|
|
| 43 |
+is($timepiece->strftime('%Y-%m-%d'), '2009-01-02', "$test : date");
|
|
| 44 | 44 |
|
| 45 | 45 |
$data = '03:04:05'; |
| 46 | 46 |
$format = $dbi->formats->{'SQL99_time'};
|
| 47 | 47 |
$timepiece = Time::Piece->strptime($data, $format); |
| 48 |
-is($timepiece->strftime('%T'), '03:04:05', "$test : time");
|
|
| 48 |
+is($timepiece->strftime('%H:%M:%S'), '03:04:05', "$test : time");
|
|
| 49 | 49 |
|
| 50 | 50 |
|
| 51 | 51 |
test 'ISO-8601 format'; |
| 52 | 52 |
$data = '2009-01-02T03:04:05'; |
| 53 | 53 |
$format = $dbi->formats->{'ISO-8601_datetime'};
|
| 54 | 54 |
$timepiece = Time::Piece->strptime($data, $format); |
| 55 |
-is($timepiece->strftime('%F'), '2009-01-02', "$test : datetime date");
|
|
| 56 |
-is($timepiece->strftime('%T'), '03:04:05', "$test : datetime time");
|
|
| 55 |
+is($timepiece->strftime('%Y-%m-%d'), '2009-01-02', "$test : datetime date");
|
|
| 56 |
+is($timepiece->strftime('%H:%M:%S'), '03:04:05', "$test : datetime time");
|
|
| 57 | 57 |
|
| 58 | 58 |
$data = '2009-01-02'; |
| 59 | 59 |
$format = $dbi->formats->{'ISO-8601_date'};
|
| 60 | 60 |
$timepiece = Time::Piece->strptime($data, $format); |
| 61 |
-is($timepiece->strftime('%F'), '2009-01-02', "$test : date");
|
|
| 61 |
+is($timepiece->strftime('%Y-%m-%d'), '2009-01-02', "$test : date");
|
|
| 62 | 62 |
|
| 63 | 63 |
$data = '03:04:05'; |
| 64 | 64 |
$format = $dbi->formats->{'ISO-8601_time'};
|
| 65 | 65 |
$timepiece = Time::Piece->strptime($data, $format); |
| 66 |
-is($timepiece->strftime('%T'), '03:04:05', "$test : time");
|
|
| 66 |
+is($timepiece->strftime('%H:%M:%S'), '03:04:05', "$test : time");
|
|
| 67 | 67 |
|