... | ... |
@@ -1,5 +1,6 @@ |
1 | 1 |
0.1733 |
2 |
- |
|
2 |
+ - update method where_param option is DEPRECATED! |
|
3 |
+ - update method param option is DEPRECATED! |
|
3 | 4 |
- insert method param option is DEPRECATED! |
4 | 5 |
- removed argument checking logic because in database performance is more |
5 | 6 |
important. |
... | ... |
@@ -233,23 +233,12 @@ sub delete { |
233 | 233 |
my ($self, %opt) = @_; |
234 | 234 |
|
235 | 235 |
# Arguments |
236 |
- my $table = $opt{table} || ''; |
|
237 |
- croak qq{"table" option must be specified. } . _subname |
|
238 |
- unless $table; |
|
239 | 236 |
my $where = $opt{where} || {}; |
240 |
- my $allow_delete_all = $opt{allow_delete_all}; |
|
241 | 237 |
my $where_param = $opt{where_param} || {}; |
242 |
- my $id = $opt{id}; |
|
243 |
- my $primary_key = $opt{primary_key}; |
|
244 |
- croak "update method primary_key option " . |
|
245 |
- "must be specified when id is specified " . _subname |
|
246 |
- if defined $id && !defined $primary_key; |
|
247 |
- $primary_key = [$primary_key] unless ref $primary_key eq 'ARRAY'; |
|
248 |
- my $prefix = $opt{prefix}; |
|
249 | 238 |
|
250 | 239 |
# Where |
251 |
- $where = $self->_id_to_param($id, $primary_key, $table) |
|
252 |
- if defined $id; |
|
240 |
+ $where = $self->_id_to_param($opt{id}, $opt{primary_key}, $opt{table}) |
|
241 |
+ if defined $opt{id}; |
|
253 | 242 |
my $where_clause = ''; |
254 | 243 |
if (ref $where eq 'ARRAY' && !ref $where->[0]) { |
255 | 244 |
$where_clause = "where " . $where->[0]; |
... | ... |
@@ -266,13 +255,13 @@ sub delete { |
266 | 255 |
} |
267 | 256 |
elsif ($where) { $where_clause = "where $where" } |
268 | 257 |
croak qq{"where" must be specified } . _subname |
269 |
- if $where_clause eq '' && !$allow_delete_all; |
|
258 |
+ if $where_clause eq '' && !$opt{allow_delete_all}; |
|
270 | 259 |
|
271 | 260 |
# Delete statement |
272 | 261 |
my $sql; |
273 | 262 |
$sql .= "delete "; |
274 |
- $sql .= "$prefix " if defined $prefix; |
|
275 |
- $sql .= "from " . $self->_q($table) . " $where_clause "; |
|
263 |
+ $sql .= "$opt{prefix} " if defined $opt{prefix}; |
|
264 |
+ $sql .= "from " . $self->_q($opt{table}) . " $where_clause "; |
|
276 | 265 |
|
277 | 266 |
# Execute query |
278 | 267 |
return $self->execute($sql, $where_param, %opt); |
... | ... |
@@ -1084,6 +1073,11 @@ sub type_rule { |
1084 | 1073 |
return $self->{type_rule} || {}; |
1085 | 1074 |
} |
1086 | 1075 |
|
1076 |
+sub _create_where { |
|
1077 |
+ my $self = shift; |
|
1078 |
+ |
|
1079 |
+} |
|
1080 |
+ |
|
1087 | 1081 |
sub update { |
1088 | 1082 |
my $self = shift; |
1089 | 1083 |
|
... | ... |
@@ -1091,6 +1085,8 @@ sub update { |
1091 | 1085 |
my $param = @_ % 2 ? shift : undef; |
1092 | 1086 |
my %opt = @_; |
1093 | 1087 |
warn "update param option is DEPRECATED!" if $opt{param}; |
1088 |
+ warn "update method where_param option is DEPRECATED!" |
|
1089 |
+ if $opt{where_param}; |
|
1094 | 1090 |
$param ||= $opt{param} || {}; |
1095 | 1091 |
my $where = $opt{where} || {}; |
1096 | 1092 |
my $where_param = $opt{where_param} || {}; |
... | ... |
@@ -1128,7 +1124,7 @@ sub update { |
1128 | 1124 |
croak qq{"where" must be specified } . _subname |
1129 | 1125 |
if "$where_clause" eq '' && !$opt{allow_update_all}; |
1130 | 1126 |
|
1131 |
- # Merge param |
|
1127 |
+ # Merge where parameter to parameter |
|
1132 | 1128 |
$param = $self->merge_param($param, $where_param) if keys %$where_param; |
1133 | 1129 |
|
1134 | 1130 |
# Update statement |
... | ... |
@@ -3431,6 +3427,7 @@ L<DBIx::Custom> |
3431 | 3427 |
update_param_tag # will be removed at 2017/1/1 |
3432 | 3428 |
|
3433 | 3429 |
# Options |
3430 |
+ update method where_param option # will be removed 2017/1/1 |
|
3434 | 3431 |
insert method param option # will be removed at 2017/1/1 |
3435 | 3432 |
insert method id option # will be removed at 2017/1/1 |
3436 | 3433 |
select method relation option # will be removed at 2017/1/1 |
... | ... |
@@ -118,7 +118,7 @@ require MyDBI1; |
118 | 118 |
sub insert { |
119 | 119 |
my ($self, $param) = @_; |
120 | 120 |
|
121 |
- return $self->SUPER::insert(param => $param); |
|
121 |
+ return $self->SUPER::insert($param); |
|
122 | 122 |
} |
123 | 123 |
|
124 | 124 |
sub list { shift->select; } |
... | ... |
@@ -133,7 +133,7 @@ require MyDBI1; |
133 | 133 |
sub insert { |
134 | 134 |
my ($self, $param) = @_; |
135 | 135 |
|
136 |
- return $self->SUPER::insert(param => $param); |
|
136 |
+ return $self->SUPER::insert($param); |
|
137 | 137 |
} |
138 | 138 |
|
139 | 139 |
sub list { shift->select; } |
... | ... |
@@ -148,7 +148,7 @@ require MyDBI1; |
148 | 148 |
sub insert { |
149 | 149 |
my ($self, $param) = @_; |
150 | 150 |
|
151 |
- return $self->SUPER::insert(param => $param); |
|
151 |
+ return $self->SUPER::insert($param); |
|
152 | 152 |
} |
153 | 153 |
|
154 | 154 |
sub list { shift->select; } |
... | ... |
@@ -163,7 +163,7 @@ require MyDBI1; |
163 | 163 |
sub insert { |
164 | 164 |
my ($self, $param) = @_; |
165 | 165 |
|
166 |
- return $self->SUPER::insert(param => $param); |
|
166 |
+ return $self->SUPER::insert($param); |
|
167 | 167 |
} |
168 | 168 |
|
169 | 169 |
sub list { shift->select; } |
... | ... |
@@ -258,7 +258,7 @@ is_deeply($model->select->all, [{$key1 => 1, $key2 => 2}]); |
258 | 258 |
test 'DBIx::Custom::Result test'; |
259 | 259 |
$dbi->delete_all(table => $table1); |
260 | 260 |
$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2}); |
261 |
-$dbi->insert(table => $table1, param => {$key1 => 3, $key2 => 4}); |
|
261 |
+$dbi->insert({$key1 => 3, $key2 => 4}, table => $table1); |
|
262 | 262 |
$source = "select $key1, $key2 from $table1"; |
263 | 263 |
$query = $dbi->create_query($source); |
264 | 264 |
$result = $dbi->execute($query); |
... | ... |
@@ -1664,8 +1664,6 @@ is($dbi->{_tags}->{b}->(), 2); |
1664 | 1664 |
|
1665 | 1665 |
test 'table not specify exception'; |
1666 | 1666 |
$dbi = DBIx::Custom->connect; |
1667 |
-eval {$dbi->delete}; |
|
1668 |
-like($@, qr/table/); |
|
1669 | 1667 |
eval {$dbi->select}; |
1670 | 1668 |
like($@, qr/table/); |
1671 | 1669 |
|