Re: Altering array(composite-types) without breaking code when inserting them and similar questions - Mailing list pgsql-general

From Fede Martinez
Subject Re: Altering array(composite-types) without breaking code when inserting them and similar questions
Date
Msg-id CAO7JFFXACV5vGbxEThB32n72pd0En=833YFE1BtZTpZjw3nCdQ@mail.gmail.com
Whole thread Raw
In response to Altering array(composite-types) without breaking code when inserting them and similar questions  (Dorian Hoxha <dorian.hoxha@gmail.com>)
Responses Re: Altering array(composite-types) without breaking code when inserting them and similar questions  (Dorian Hoxha <dorian.hoxha@gmail.com>)
List pgsql-general

If you don't know the columns your type will have, you could consider using json or hstore if the data is unstructured.

El 20/04/2014 14:04, "Dorian Hoxha" <dorian.hoxha@gmail.com> escribió:
Hi list,

I have a
create type thetype(width integer, height integer);
create table mytable(thetype thetype[]);

How can i make an insert statement so if i later add fields to the composite type, the code/query doesn't break ?
Maybe by specifying the fields of the composite type in the query ?

This can be done for normal inserts(non arrays):
CREATE TABLE mytable (t thetype);
INSERT INTO mytable(t.width, t.height) VALUES (11,22);


Also how to update an whole element of an array of composites ?
Also, how to update an attribute in a specific element in an array of composites?

(so when i add columns later to the composite, my old code doesn't break)

How much overhead have the composite types beside the values and nulls?

Thanks

pgsql-general by date:

Previous
From: David G Johnston
Date:
Subject: Re: Altering array(composite-types) without breaking code when inserting them and similar questions
Next
From: Dorian Hoxha
Date:
Subject: Re: Altering array(composite-types) without breaking code when inserting them and similar questions