From: Dagfinn Ilmari Mannsåker Date: Thu, 11 Dec 2014 11:24:38 +0000 (+0000) Subject: Clean up PostgreSQL array types recipe (amalgamation of 10e72c6e and 09380b06) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class.git;a=commitdiff_plain;h=b3f3814f4a169239e35dc55da4eda8dddc7503cb Clean up PostgreSQL array types recipe (amalgamation of 10e72c6e and 09380b06) - Prefer { -value => [ … ] } syntax over \[ '= ?', [colname => [ … ]] ] - Reference SQLA -value docs instead of array_datatypes - Add trailing comma in hashes - Remove pointless 'day' key from update example --- diff --git a/lib/DBIx/Class/Manual/Cookbook.pod b/lib/DBIx/Class/Manual/Cookbook.pod index 7c2c58e..cf80dd8 100644 --- a/lib/DBIx/Class/Manual/Cookbook.pod +++ b/lib/DBIx/Class/Manual/Cookbook.pod @@ -1737,30 +1737,30 @@ L and L family of methods: $resultset->create({ - numbers => [1, 2, 3] + numbers => [1, 2, 3], }); - $result->update( - { - numbers => [1, 2, 3] - }, - { - day => '2008-11-24' - } - ); + $result->update({ + numbers => [1, 2, 3], + }); 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] }, + }); + +Or using the more generic (and more cumbersome) literal syntax: + + $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