| ... | ... |
@@ -1,5 +1,4 @@ |
| 1 | 1 |
0.1748 |
| 2 |
- - added EXPERIMETNAL use_version1 |
|
| 3 | 2 |
- DBIx::Custom::Query is DEPRECATED! |
| 4 | 3 |
0.1747 |
| 5 | 4 |
- fixed bug DBIx::Custom::Result fetch_hash_multi throw warnings |
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
package DBIx::Custom; |
| 2 | 2 |
use Object::Simple -base; |
| 3 | 3 |
|
| 4 |
-our $VERSION = '0.1747'; |
|
| 4 |
+our $VERSION = '0.2100'; |
|
| 5 | 5 |
use 5.008001; |
| 6 | 6 |
|
| 7 | 7 |
use Carp 'croak'; |
| ... | ... |
@@ -131,18 +131,7 @@ sub assign_clause {
|
| 131 | 131 |
my ($self, $param, $opts) = @_; |
| 132 | 132 |
|
| 133 | 133 |
my $wrap = $opts->{wrap} || {};
|
| 134 |
- my $safety = $self->{safety_character} || $self->safety_character;
|
|
| 135 |
- my $qp = $self->q('');
|
|
| 136 |
- my $q = substr($qp, 0, 1) || ''; |
|
| 137 |
- my $p = substr($qp, 1, 1) || ''; |
|
| 138 |
- |
|
| 139 |
- # Check unsafety keys |
|
| 140 |
- unless ((join('', keys %$param) || '') =~ /^[$safety\.]+$/) {
|
|
| 141 |
- for my $column (keys %$param) {
|
|
| 142 |
- croak qq{"$column" is not safety column name } . _subname
|
|
| 143 |
- unless $column =~ /^[$safety\.]+$/; |
|
| 144 |
- } |
|
| 145 |
- } |
|
| 134 |
+ my ($q, $p) = split //, $self->q('');
|
|
| 146 | 135 |
|
| 147 | 136 |
# Assign clause (performance is important) |
| 148 | 137 |
join( |
| ... | ... |
@@ -406,8 +395,17 @@ sub execute {
|
| 406 | 395 |
} |
| 407 | 396 |
else {
|
| 408 | 397 |
$query = $opt{reuse}->{$sql} if $opt{reuse};
|
| 409 |
- $query = $self->_create_query($sql,$opt{after_build_sql} || $opt{sqlfilter})
|
|
| 410 |
- unless $query; |
|
| 398 |
+ unless ($query) {
|
|
| 399 |
+ my $safety = $self->{safety_character} || $self->safety_character;
|
|
| 400 |
+ # Check unsafety keys |
|
| 401 |
+ unless ((join('', keys %$param) || '') =~ /^[$safety\.]+$/) {
|
|
| 402 |
+ for my $column (keys %$param) {
|
|
| 403 |
+ croak qq{"$column" is not safety column name } . _subname
|
|
| 404 |
+ unless $column =~ /^[$safety\.]+$/; |
|
| 405 |
+ } |
|
| 406 |
+ } |
|
| 407 |
+ $query = $self->_create_query($sql,$opt{after_build_sql} || $opt{sqlfilter});
|
|
| 408 |
+ } |
|
| 411 | 409 |
$query->statement($opt{statement} || '');
|
| 412 | 410 |
$opt{reuse}->{$sql} = $query if $opt{reuse};
|
| 413 | 411 |
} |
| ... | ... |
@@ -1183,69 +1181,13 @@ sub update_timestamp {
|
| 1183 | 1181 |
return $self->{update_timestamp};
|
| 1184 | 1182 |
} |
| 1185 | 1183 |
|
| 1186 |
-sub use_version1 {
|
|
| 1187 |
- my $self = shift; |
|
| 1188 |
- |
|
| 1189 |
- return if $VERSION >= 1; |
|
| 1190 |
- |
|
| 1191 |
- my @modules = ('', qw/::Where ::Util ::Result ::Order ::NotExists ::Model ::Mapper/);
|
|
| 1192 |
- |
|
| 1193 |
- # Replace |
|
| 1194 |
- for my $module (@modules) {
|
|
| 1195 |
- my $old = 'DBIx::Custom' . $module; |
|
| 1196 |
- my $new = 'DBIx::Custom::Next' . $module; |
|
| 1197 |
- |
|
| 1198 |
- no strict 'refs'; |
|
| 1199 |
- no warnings 'redefine'; |
|
| 1200 |
- eval "require $old"; |
|
| 1201 |
- die $@ if $@; |
|
| 1202 |
- eval "require $new"; |
|
| 1203 |
- die $@ if $@; |
|
| 1204 |
- for my $method (@{DBIx::Custom::Class::Inspector->methods( $old, 'full', 'public' )}) {
|
|
| 1205 |
- next unless $method =~ /^DBIx::Custom/; |
|
| 1206 |
- undef &{"$method"};
|
|
| 1207 |
- *{"$method"} = sub { die "$method method is removed" };
|
|
| 1208 |
- } |
|
| 1209 |
- |
|
| 1210 |
- for my $new_method (@{DBIx::Custom::Class::Inspector->methods( $new, 'full', 'public' )}) {
|
|
| 1211 |
- next unless $new_method =~ /^DBIx::Custom/; |
|
| 1212 |
- my $old_method = $new_method; |
|
| 1213 |
- $old_method =~ s/::Next//; |
|
| 1214 |
- *{"$old_method"} = \&{"$new_method"};
|
|
| 1215 |
- } |
|
| 1216 |
- } |
|
| 1217 |
- |
|
| 1218 |
- # Remove |
|
| 1219 |
- for my $module (qw/DBIx::Custom::Tag DBIx::Custom::QueryBuilder/) {
|
|
| 1220 |
- no strict 'refs'; |
|
| 1221 |
- eval "require $module"; |
|
| 1222 |
- die $@ if $@; |
|
| 1223 |
- for my $method (@{DBIx::Custom::Class::Inspector->methods( $module, 'full', 'public' )}) {
|
|
| 1224 |
- next unless $method =~ /^DBIx::Custom/; |
|
| 1225 |
- undef &{"$method"};
|
|
| 1226 |
- *{"$method"} = sub { die "$method method is removed" };
|
|
| 1227 |
- } |
|
| 1228 |
- } |
|
| 1229 |
-} |
|
| 1230 |
- |
|
| 1231 | 1184 |
sub values_clause {
|
| 1232 | 1185 |
my ($self, $param, $opts) = @_; |
| 1233 | 1186 |
|
| 1234 | 1187 |
my $wrap = $opts->{wrap} || {};
|
| 1235 | 1188 |
|
| 1236 | 1189 |
# Create insert parameter tag |
| 1237 |
- my $safety = $self->{safety_character} || $self->safety_character;
|
|
| 1238 |
- my $qp = $self->q('');
|
|
| 1239 |
- my $q = substr($qp, 0, 1) || ''; |
|
| 1240 |
- my $p = substr($qp, 1, 1) || ''; |
|
| 1241 |
- |
|
| 1242 |
- # Check unsafety keys |
|
| 1243 |
- unless ((join('', keys %$param) || '') =~ /^[$safety\.]+$/) {
|
|
| 1244 |
- for my $column (keys %$param) {
|
|
| 1245 |
- croak qq{"$column" is not safety column name } . _subname
|
|
| 1246 |
- unless $column =~ /^[$safety\.]+$/; |
|
| 1247 |
- } |
|
| 1248 |
- } |
|
| 1190 |
+ my ($q, $p) = split //, $self->q('');
|
|
| 1249 | 1191 |
|
| 1250 | 1192 |
# values clause(performance is important) |
| 1251 | 1193 |
'(' .
|
| ... | ... |
@@ -3415,13 +3357,6 @@ Show type name of the columns of specified table. |
| 3415 | 3357 |
|
| 3416 | 3358 |
This type name is used in C<type_rule>'s C<into1> and C<into2>. |
| 3417 | 3359 |
|
| 3418 |
-=head2 C<use_version1 EXPERIMENTAL> |
|
| 3419 |
- |
|
| 3420 |
- DBIx::Custom->use_version1; |
|
| 3421 |
- |
|
| 3422 |
-Upgrade L<DBIx::Custom> to major version 1 if version is lower than 1. |
|
| 3423 |
-You can't use DEPRECATED method and method performance is improved. |
|
| 3424 |
- |
|
| 3425 | 3360 |
=head2 C<values_clause> |
| 3426 | 3361 |
|
| 3427 | 3362 |
my $values_clause = $dbi->values_clause({title => 'a', age => 2});
|
| ... | ... |
@@ -2229,9 +2229,6 @@ $dbi->execute($sql, $param, table => $table1); |
| 2229 | 2229 |
is($dbi->select(table => $table1)->one->{$key1}, 1);
|
| 2230 | 2230 |
is($dbi->select(table => $table1)->one->{$key2}, 2);
|
| 2231 | 2231 |
|
| 2232 |
-eval { $dbi->values_clause({";" => 1}) };
|
|
| 2233 |
-like($@, qr/not safety/); |
|
| 2234 |
- |
|
| 2235 | 2232 |
test 'mycolumn'; |
| 2236 | 2233 |
$dbi = MyDBI8->connect; |
| 2237 | 2234 |
$dbi->user_table_info($user_table_info); |
| ... | ... |
@@ -3684,9 +3681,6 @@ is_deeply($rows, [{$key1 => 1, $key2 => 11, $key3 => 33, $key4 => 4, $key5 => 5}
|
| 3684 | 3681 |
"update param no_set"); |
| 3685 | 3682 |
|
| 3686 | 3683 |
|
| 3687 |
-eval { $dbi->assign_clause({";" => 1}) };
|
|
| 3688 |
-like($@, qr/not safety/); |
|
| 3689 |
- |
|
| 3690 | 3684 |
$dbi = DBIx::Custom->connect; |
| 3691 | 3685 |
eval { $dbi->execute("drop table $table1") };
|
| 3692 | 3686 |
$dbi->execute($create_table1_2); |