From: Dagfinn Ilmari Mannsåker Date: Thu, 11 Dec 2014 11:24:38 +0000 (+0000) Subject: Clean up PostgreSQL array types recipe X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=10e72c6e2d60efceb8c64ef008a9fbdeb1f43852;p=dbsrgits%2FDBIx-Class.git Clean up PostgreSQL array types recipe - Prefer { -value => [ … ] } syntax over \[ '= ?', [colname => [ … ]] ] - Reference SQLA -value docs instead of array_datatypes --- diff --git a/lib/DBIx/Class/Manual/Cookbook.pod b/lib/DBIx/Class/Manual/Cookbook.pod index 7c2c58e..3270f03 100644 --- a/lib/DBIx/Class/Manual/Cookbook.pod +++ b/lib/DBIx/Class/Manual/Cookbook.pod @@ -1740,27 +1740,28 @@ methods: numbers => [1, 2, 3] }); - $result->update( - { - numbers => [1, 2, 3] - }, - { - day => '2008-11-24' - } - ); + $result->update({ + numbers => [1, 2, 3] + day => '2008-11-24' + }); In conditions (e.g. C<\%cond> in the L family of methods) you cannot directly use array references (since this is interpreted as a list of values to be Ced), but you can use the following syntax to force passing them as bind values: - $resultset->search( - { - numbers => \[ '= ?', [numbers => [1, 2, 3]] ] - } - ); + $resultset->search({ + numbers => { -value => [1, 2, 3] }, + }); + +Alternatively: + + $resultset->search({ + numbers => \[ '= ?', [numbers => [1, 2, 3]] ] + }); + -See L and L and L for more explanation. Note that L sets L to C, so you must pass the bind values (the C<[1, 2, 3]> arrayref in the above example) wrapped in