... | ... |
@@ -1,4 +1,5 @@ |
1 | 1 |
0.1699 |
2 |
+ - added tag_parse attribute. |
|
2 | 3 |
- added EXPERIMENTAL order method |
3 | 4 |
- added EXPERIMENTAL DBIx::Custom::Order module |
4 | 5 |
- changed backword compatible policy |
... | ... |
@@ -56,7 +56,8 @@ has [qw/connector dsn password quote user/], |
56 | 56 |
query_builder => sub { DBIx::Custom::QueryBuilder->new }, |
57 | 57 |
result_class => 'DBIx::Custom::Result', |
58 | 58 |
safety_character => '\w', |
59 |
- stash => sub { {} }; |
|
59 |
+ stash => sub { {} }, |
|
60 |
+ tag_parse => 1; |
|
60 | 61 |
|
61 | 62 |
our $AUTOLOAD; |
62 | 63 |
sub AUTOLOAD { |
... | ... |
@@ -1138,6 +1139,7 @@ sub _create_query { |
1138 | 1139 |
|
1139 | 1140 |
# Create query |
1140 | 1141 |
my $builder = $self->query_builder; |
1142 |
+ $builder->{_tag_parse} = $self->tag_parse; |
|
1141 | 1143 |
$query = $builder->build_query($source); |
1142 | 1144 |
|
1143 | 1145 |
# Remove reserved word quote |
... | ... |
@@ -1932,6 +1934,14 @@ Result class, default to L<DBIx::Custom::Result>. |
1932 | 1934 |
Regex of safety character for table and column name, default to '\w'. |
1933 | 1935 |
Note that you don't have to specify like '[\w]'. |
1934 | 1936 |
|
1937 |
+=head2 C<tag_parse> |
|
1938 |
+ |
|
1939 |
+ my $tag_parse = $dbi->tag_parse(0); |
|
1940 |
+ $dbi = $dbi->tag_parse; |
|
1941 |
+ |
|
1942 |
+Enable DEPRECATED tag parsing functionality, default to 1. |
|
1943 |
+If you want to disable tag parsing functionality, set to 0. |
|
1944 |
+ |
|
1935 | 1945 |
=head2 C<user> |
1936 | 1946 |
|
1937 | 1947 |
my $user = $dbi->user; |
... | ... |
@@ -2948,6 +2958,7 @@ L<DBIx::Custom> |
2948 | 2958 |
dbi_options # Removed at 2017/1/1 |
2949 | 2959 |
filter_check # Removed at 2017/1/1 |
2950 | 2960 |
reserved_word_quote # Removed at 2017/1/1 |
2961 |
+ cache_method # Removed at 2017/1/1 |
|
2951 | 2962 |
|
2952 | 2963 |
# Methods |
2953 | 2964 |
create_query # Removed at 2017/1/1 |
... | ... |
@@ -2970,6 +2981,7 @@ L<DBIx::Custom> |
2970 | 2981 |
# Others |
2971 | 2982 |
execute("select * from {= title}"); # execute tag parsing functionality |
2972 | 2983 |
# Removed at 2017/1/1 |
2984 |
+ Query caching # Removed at 2017/1/1 |
|
2973 | 2985 |
|
2974 | 2986 |
L<DBIx::Custom::Model> |
2975 | 2987 |
|
... | ... |
@@ -19,7 +19,8 @@ sub build_query { |
19 | 19 |
my $query; |
20 | 20 |
|
21 | 21 |
# Parse tag. tag is DEPRECATED! |
22 |
- if ($source =~ /\{/ && $source =~ /\}/) { |
|
22 |
+ $self->{_tag_parse} = 1 unless defined $self->{_tag_parse}; |
|
23 |
+ if ($self->{_tag_parse} && $source =~ /\{/ && $source =~ /\}/) { |
|
23 | 24 |
$query = $self->_parse_tag($source); |
24 | 25 |
my $tag_count = delete $query->{tag_count}; |
25 | 26 |
warn qq/Tag system such as {? name} is DEPRECATED! / . |
... | ... |
@@ -39,9 +40,7 @@ sub build_query { |
39 | 40 |
} |
40 | 41 |
|
41 | 42 |
# Parse parameter |
42 |
- else { |
|
43 |
- $query = $self->_parse_parameter($source); |
|
44 |
- } |
|
43 |
+ else { $query = $self->_parse_parameter($source) } |
|
45 | 44 |
|
46 | 45 |
my $sql = $query->sql; |
47 | 46 |
$sql .= ';' unless $source =~ /;$/; |
... | ... |
@@ -3306,5 +3306,14 @@ $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:'); |
3306 | 3306 |
{key1 => 1, key2 => 3}, {key1 => 1, key2 => 1}]); |
3307 | 3307 |
} |
3308 | 3308 |
|
3309 |
+test 'tag_parse'; |
|
3310 |
+$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:'); |
|
3311 |
+$dbi->tag_parse(0); |
|
3312 |
+{ |
|
3313 |
+ $dbi->execute("create table table1 (key1, key2)"); |
|
3314 |
+ $dbi->insert({key1 => 1, key2 => 1}, table => 'table1'); |
|
3315 |
+ eval {$dbi->execute("select * from table1 where {= key1}", {key1 => 1})}; |
|
3316 |
+ ok($@); |
|
3317 |
+} |
|
3309 | 3318 |
|
3310 | 3319 |
=cut |