my %implied = %{$self->_remove_alias($collapsed_cond, $alias)};
while ( my($col, $value) = each %implied ) {
- if (ref($value) eq 'HASH' && keys(%$value) && (keys %$value)[0] eq '=') {
+ my $vref = ref $value;
+ if ($vref eq 'HASH' && keys(%$value) && (keys %$value)[0] eq '=') {
$new_data{$col} = $value->{'='};
- next;
}
- $new_data{$col} = $value if $self->_is_deterministic_value($value);
+ elsif( !$vref or $vref eq 'SCALAR' or blessed($value) ) {
+ $new_data{$col} = $value;
+ }
}
}
return (\%new_data, \@cols_from_relations);
}
-# _is_deterministic_value
-#
-# Make an effor to strip non-deterministic values from the condition,
-# to make sure new_result chokes less
-
-sub _is_deterministic_value {
- my $self = shift;
- my $value = shift;
- my $ref_type = ref $value;
- return 1 if $ref_type eq '' || $ref_type eq 'SCALAR';
- return 1 if blessed $value;
- return 0;
-}
-
# _has_resolved_attr
#
# determines if the resultset defines at least one
arrayfield => [5, 6],
});
+ my $afield_rs = $schema->resultset('ArrayTest')->search({
+ arrayfield => \[ '= ?' => [arrayfield => [3, 4]] ], #Todo anything less ugly than this?
+ });
+
my $count;
lives_ok {
- $count = $schema->resultset('ArrayTest')->search({
- arrayfield => \[ '= ?' => [arrayfield => [3, 4]] ], #Todo anything less ugly than this?
- })->count;
+ $count = $afield_rs->count
} 'comparing arrayref to pg array data does not blow up';
is($count, 1, 'comparing arrayref to pg array data gives correct result');
+
+ TODO: {
+ local $TODO = 'No introspection of scalarref conditions :(';
+ my $row = $afield_rs->create({});
+ is_deeply ($row->arrayfield, [3,4], 'Array value taken from $rs condition');
+ $row->discard_changes;
+ is_deeply ($row->arrayfield, [3,4], 'Array value made it to storage');
+ }
}
plan skip_all => 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test'
unless ($dsn && $dbuser);
-plan tests => 6;
-
my $schema = DBICTest::Schema->connection($dsn, $dbuser, $dbpass, { AutoCommit => 1 });
my $dbh = $schema->storage->dbh;
$schema->txn_rollback;
});
}
+
+ # create with blob from $rs
+ $new = $rs->create({});
+ is($new->bytea, $big_long_string, 'Object has bytea value from $rs');
+ $new->discard_changes;
+ is($new->bytea, $big_long_string, 'bytea value made it to db');
}
-$dbh->do("DROP TABLE bindtype_test");
+done_testing;
+
+eval { $dbh->do("DROP TABLE bindtype_test") };
+