... | ... |
@@ -406,7 +406,7 @@ sub execute { |
406 | 406 |
} |
407 | 407 |
$query = $self->_create_query($sql,$opt{after_build_sql} || $opt{sqlfilter}); |
408 | 408 |
} |
409 |
- $query->statement($opt{statement} || ''); |
|
409 |
+ $query->{statement} = $opt{statement} || ''; |
|
410 | 410 |
$opt{reuse}->{$sql} = $query if $opt{reuse}; |
411 | 411 |
} |
412 | 412 |
|
... | ... |
@@ -425,7 +425,7 @@ sub execute { |
425 | 425 |
|
426 | 426 |
# Merge id to parameter |
427 | 427 |
if (defined $opt{id}) { |
428 |
- my $statement = $query->statement; |
|
428 |
+ my $statement = $query->{statement}; |
|
429 | 429 |
warn "execute method id option is DEPRECATED!" unless $statement; |
430 | 430 |
croak "execute id option must be specified with primary_key option" |
431 | 431 |
unless $opt{primary_key}; |
... | ... |
@@ -497,7 +497,7 @@ sub execute { |
497 | 497 |
} |
498 | 498 |
|
499 | 499 |
# Create bind values |
500 |
- my ($bind, $bind_types) = $self->_create_bind_values($param, $query->columns, |
|
500 |
+ my ($bind, $bind_types) = $self->_create_bind_values($param, $query->{columns}, |
|
501 | 501 |
$filter, $type_filters, $opt{bind_type} || $opt{type} || {}); |
502 | 502 |
|
503 | 503 |
# Execute |
... | ... |
@@ -523,7 +523,7 @@ sub execute { |
523 | 523 |
|
524 | 524 |
# DEBUG message |
525 | 525 |
if ($ENV{DBIX_CUSTOM_DEBUG}) { |
526 |
- warn "SQL:\n" . $query->sql . "\n"; |
|
526 |
+ warn "SQL:\n" . $query->{sql} . "\n"; |
|
527 | 527 |
my @output; |
528 | 528 |
for my $value (@$bind) { |
529 | 529 |
$value = 'undef' unless defined $value; |
... | ... |
@@ -1242,15 +1242,15 @@ sub _create_query { |
1242 | 1242 |
# Remove reserved word quote |
1243 | 1243 |
if (my $q = $self->_quote) { |
1244 | 1244 |
$q = quotemeta($q); |
1245 |
- $_ =~ s/[$q]//g for @{$query->columns} |
|
1245 |
+ $_ =~ s/[$q]//g for @{$query->{columns}} |
|
1246 | 1246 |
} |
1247 | 1247 |
|
1248 | 1248 |
# Save query to cache |
1249 | 1249 |
$self->cache_method->( |
1250 | 1250 |
$self, $source, |
1251 | 1251 |
{ |
1252 |
- sql => $query->sql, |
|
1253 |
- columns => $query->columns, |
|
1252 |
+ sql => $query->{sql}, |
|
1253 |
+ columns => $query->{columns}, |
|
1254 | 1254 |
tables => $query->{tables} || [] |
1255 | 1255 |
} |
1256 | 1256 |
) if $cache; |
... | ... |
@@ -1258,13 +1258,13 @@ sub _create_query { |
1258 | 1258 |
|
1259 | 1259 |
# Filter SQL |
1260 | 1260 |
if ($after_build_sql) { |
1261 |
- my $sql = $query->sql; |
|
1261 |
+ my $sql = $query->{sql}; |
|
1262 | 1262 |
$sql = $after_build_sql->($sql); |
1263 |
- $query->sql($sql); |
|
1263 |
+ $query->{sql} = $sql; |
|
1264 | 1264 |
} |
1265 | 1265 |
|
1266 | 1266 |
# Save sql |
1267 |
- $self->last_sql($query->sql); |
|
1267 |
+ $self->{last_sql} = $query->{sql}; |
|
1268 | 1268 |
|
1269 | 1269 |
# Prepare statement handle |
1270 | 1270 |
my $sth; |
... | ... |
@@ -1276,7 +1276,7 @@ sub _create_query { |
1276 | 1276 |
} |
1277 | 1277 |
|
1278 | 1278 |
# Set statement handle |
1279 |
- $query->sth($sth); |
|
1279 |
+ $query->{sth} = $sth; |
|
1280 | 1280 |
|
1281 | 1281 |
# Set filters |
1282 | 1282 |
$query->{filters} = $self->filters; |
... | ... |
@@ -52,7 +52,7 @@ sub build_query { |
52 | 52 |
$sql =~ s/\\:/:/g if index($sql, "\\:") != -1; |
53 | 53 |
|
54 | 54 |
# Create query |
55 |
- bless {sql => $sql, columns => $columns}, 'DBIx::Custom::Query'; |
|
55 |
+ return {sql => $sql, columns => $columns}; |
|
56 | 56 |
} |
57 | 57 |
|
58 | 58 |
# DEPRECATED! |
... | ... |
@@ -1552,13 +1552,13 @@ $dbi = DBIx::Custom->connect; |
1552 | 1552 |
eval { $dbi->execute("drop table $table1") }; |
1553 | 1553 |
$dbi->execute($create_table1); |
1554 | 1554 |
$query = $dbi->insert({$key1 => 1, $key2 => 2}, table => $table1, query => 1); |
1555 |
-is(ref $query, 'DBIx::Custom::Query'); |
|
1555 |
+ok(ref $query); |
|
1556 | 1556 |
$query = $dbi->update({$key2 => 2}, table => $table1, where => {$key1 => 1}, query => 1); |
1557 |
-is(ref $query, 'DBIx::Custom::Query'); |
|
1557 |
+ok(ref $query); |
|
1558 | 1558 |
$query = $dbi->delete(table => $table1, where => {$key1 => 1}, query => 1); |
1559 |
-is(ref $query, 'DBIx::Custom::Query'); |
|
1559 |
+ok(ref $query); |
|
1560 | 1560 |
$query = $dbi->select(table => $table1, where => {$key1 => 1, $key2 => 2}, query => 1); |
1561 |
-is(ref $query, 'DBIx::Custom::Query'); |
|
1561 |
+ok(ref $query); |
|
1562 | 1562 |
|
1563 | 1563 |
test 'where'; |
1564 | 1564 |
$dbi = DBIx::Custom->connect; |
... | ... |
@@ -2509,7 +2509,7 @@ $query = $dbi->insert( |
2509 | 2509 |
id => [1, 2], |
2510 | 2510 |
query => 1 |
2511 | 2511 |
); |
2512 |
-is(ref $query, 'DBIx::Custom::Query'); |
|
2512 |
+ok(ref $query); |
|
2513 | 2513 |
is_deeply($param, {$key3 => 3, $key2 => 4}); |
2514 | 2514 |
|
2515 | 2515 |
test 'model insert id and primary_key option'; |
... | ... |
@@ -3148,7 +3148,7 @@ $rows = [ |
3148 | 3148 |
my $sth; |
3149 | 3149 |
for my $row (@$rows) { |
3150 | 3150 |
$query ||= $dbi->insert($row, table => $table1, query => 1); |
3151 |
- $sth ||= $query->sth; |
|
3151 |
+ $sth ||= $query->{sth}; |
|
3152 | 3152 |
$sth->execute(map { $row->{$_} } sort keys %$row); |
3153 | 3153 |
} |
3154 | 3154 |
is_deeply($dbi->select(table => $table1)->all, |
... | ... |
@@ -3387,7 +3387,7 @@ for (my $i = 0; $i < @$datas; $i++) { |
3387 | 3387 |
my $builder = $dbi->query_builder; |
3388 | 3388 |
my $query = $builder->build_query($data->{source}); |
3389 | 3389 |
is($query->{sql}, $data->{sql_expected}, "$data->{name} : sql"); |
3390 |
- is_deeply($query->columns, $data->{columns_expected}, "$data->{name} : columns"); |
|
3390 |
+ is_deeply($query->{columns}, $data->{columns_expected}, "$data->{name} : columns"); |
|
3391 | 3391 |
} |
3392 | 3392 |
|
3393 | 3393 |
$dbi = DBIx::Custom->new; |
... | ... |
@@ -3460,15 +3460,15 @@ is($query->sql, 'a b = ? c { } { = ? } = ? d', "basic : 1"); |
3460 | 3460 |
|
3461 | 3461 |
$source = "abc"; |
3462 | 3462 |
$query = $builder->build_query($source); |
3463 |
-is($query->sql, 'abc', "basic : 2"); |
|
3463 |
+is($query->{sql}, 'abc', "basic : 2"); |
|
3464 | 3464 |
|
3465 | 3465 |
$source = "{= a}"; |
3466 | 3466 |
$query = $builder->build_query($source); |
3467 |
-is($query->sql, 'a = ?', "only tag"); |
|
3467 |
+is($query->{sql}, 'a = ?', "only tag"); |
|
3468 | 3468 |
|
3469 | 3469 |
$source = "000"; |
3470 | 3470 |
$query = $builder->build_query($source); |
3471 |
-is($query->sql, '000', "contain 0 value"); |
|
3471 |
+is($query->{sql}, '000', "contain 0 value"); |
|
3472 | 3472 |
|
3473 | 3473 |
$source = "a {= b} }"; |
3474 | 3474 |
eval{$builder->build_query($source)}; |