diff --git a/lib/DBIx/Class/InflateColumn.pm b/lib/DBIx/Class/InflateColumn.pm index 9214582a4..ae98d75e2 100644 --- a/lib/DBIx/Class/InflateColumn.pm +++ b/lib/DBIx/Class/InflateColumn.pm @@ -116,7 +116,15 @@ sub _deflated_column { my ($self, $col, $value) = @_; # return $value unless ref $value && blessed($value); # If it's not an object, don't touch it ## Leave scalar refs (ala SQL::Abstract literal SQL), untouched, deflate all other refs - return $value unless (ref $value && ref($value) ne 'SCALAR'); + ## Also leave ref refs if it is ARRAY + return $value + unless ( + ref $value + && !( ref($value) eq 'SCALAR' + || ( ref($value) eq 'REF' && ref($$value) eq 'ARRAY' ) + ) + ); + my $info = $self->column_info($col) or $self->throw_exception("No column info for $col"); return $value unless exists $info->{_inflate_info}; diff --git a/t/update/array_literal_bind.t b/t/update/array_literal_bind.t new file mode 100644 index 000000000..19c7e9702 --- /dev/null +++ b/t/update/array_literal_bind.t @@ -0,0 +1,35 @@ +use strict; +use warnings; + +use Test::More; +use Test::Warn; +use Try::Tiny; +use lib qw(t/lib); +use DBICTest; + +my $schema = DBICTest->init_schema(); + +my $event = $schema->resultset("Event")->find(1); + +ok( + $event->update( + { + starts_at => \[ + 'MAX(starts_at, datetime(?), datetime(?))', + '2006-04-25T22:24:33', + '2007-04-25T22:24:33', + ] + } + ), + 'update without error' +); + +$event = $event->get_from_storage(); + +is( + $event->starts_at . '', + '2007-04-25T22:24:33', + 'starts_at updated properly' +); + +done_testing;