... | ... |
@@ -1263,15 +1263,18 @@ sub _create_query { |
1263 | 1263 |
my $duplicate; |
1264 | 1264 |
# Parameter regex |
1265 | 1265 |
$sql =~ s/([0-9]):/$1\\:/g; |
1266 |
- while ($sql =~ /(.*?[^\\]):([$c\.]+)(?:\{(.*?)\})?(.*)/sg) { |
|
1266 |
+ my $new_sql = ''; |
|
1267 |
+ while ($sql =~ /(.*?[^\\]):([$c\.]+)(?:\{(.*?)\})?(.*)/s) { |
|
1267 | 1268 |
push @columns, $2; |
1268 | 1269 |
$duplicate = 1 if ++$duplicate{$columns[-1]} > 1; |
1269 |
- $sql = defined $3 ? "$1$2 $3 ?$4" : "$1?$4"; |
|
1270 |
+ ($new_sql, $sql) = defined $3 ? |
|
1271 |
+ ($new_sql . "$1$2 $3 ?", " $4") : ($new_sql . "$1?", " $4"); |
|
1270 | 1272 |
} |
1271 |
- $sql =~ s/\\:/:/g if index($sql, "\\:") != -1; |
|
1273 |
+ $new_sql .= $sql; |
|
1274 |
+ $new_sql =~ s/\\:/:/g if index($new_sql, "\\:") != -1; |
|
1272 | 1275 |
|
1273 | 1276 |
# Create query |
1274 |
- $query = {sql => $sql, columns => \@columns, duplicate => $duplicate}; |
|
1277 |
+ $query = {sql => $new_sql, columns => \@columns, duplicate => $duplicate}; |
|
1275 | 1278 |
} |
1276 | 1279 |
|
1277 | 1280 |
# Save query to cache |
... | ... |
@@ -243,6 +243,7 @@ test 'execute reuse option'; |
243 | 243 |
eval { $dbi->execute("drop table $table1") }; |
244 | 244 |
$dbi->execute($create_table1); |
245 | 245 |
$reuse = {}; |
246 |
+$DB::single = 1; |
|
246 | 247 |
for my $i (1 .. 2) { |
247 | 248 |
$dbi->insert({$key1 => 1, $key2 => 2}, table => $table1, reuse => $reuse); |
248 | 249 |
} |
... | ... |
@@ -1270,7 +1271,7 @@ $dbi->execute($create_table1); |
1270 | 1271 |
$source = "select * from $table1 where $key1 = :$key1 and $key2 = :$key2"; |
1271 | 1272 |
$dbi->execute($source, {}, query => 1); |
1272 | 1273 |
is_deeply($dbi->{_cached}->{$source}, |
1273 |
- {sql => " select * from $table1 where $key1 = ? and $key2 = ?", columns => [$key1, $key2], tables => []}, "cache"); |
|
1274 |
+ {sql => " select * from $table1 where $key1 = ? and $key2 = ? ", columns => [$key1, $key2], tables => []}, "cache"); |
|
1274 | 1275 |
|
1275 | 1276 |
eval { $dbi->execute("drop table $table1") }; |
1276 | 1277 |
$dbi->execute($create_table1); |