[Dbix-class] How to use arrays in database

Jens Thoms Toerring jt at toerring.de
Sun May 25 10:34:32 BST 2008


On Sun, May 25, 2008 at 01:01:59PM +0800, Lee Standen wrote:
> Jens Thoms Toerring wrote:
>> I have a table in a database where
>> some columns are arrays. I have been looking for some time for
>> a way to access these arrays, idealy in a way that I can query
>> or set a certain element of the array but haven't be able to
>> find anything like that.
>
> The problem, I think you'll find, is that the ARRAY columns supported by 
> Postgres are very specific to Postgres.  I've not seen support for an array 
> data type in any other database, and a quick google seems to confirm that 
> it's a very Postgres specific feature.

I see. I only checked that it seems to be in the SQL standard
since 99 and then wrongly assumed that nearly everybody would
already have had support for it before it got standardized or
would at least strive to implement it ASAP;-)

> If you need to store an array in a column, then you probably need to 
> rethink your schema...

It is actually for a banally simple thing: storing a sum of how
many user selected one (or more) of N alternatives by incremen-
ting the corresponding array element(s). That looked to me like
something where an array comes rather handy instead of creating
a new table. But, of course, if there's no support for arrays in
almost all databases using them isn't such a great idea...

                   Thank you and best regards, Jens
-- 
  \   Jens Thoms Toerring  ________      jt at toerring.de
   \_______________________________      http://toerring.de



More information about the DBIx-Class mailing list