[Qgis-user] Postgres arrays in QGIS and form widget
Bernhard Ströbl
bernhard.stroebl at jena.de
Thu Jan 15 22:50:38 PST 2015
Hi Olivier,
about editing arrays: Your request made me extent my plugin
DataDrivenInputMask so it supports array field types. Currently this
extended version is in a separate branch [1]. It supports arrays of type
char, varchar, integer, decimal, date and boolean. Please test and
report any issues in [2].
Bernhard
[1] https://github.com/bstroebl/DataDrivenInputMask/tree/supportArray
[2] http://hub.qgis.org/issues/11978
Am 15.01.2015 20:22, schrieb Olivier Dalang:
> Hi,
>
> Thanks for your answers.
>
> Of course, I could do that with relations, but in my specific case I
> prefer to keep everything in one table (I have some fairly complex
> triggers to keep versions history and restrict some operations and have
> no need for separate tables).
>
> But I'll have a look at the link you provided, and I also found this in
> the meantime :
> https://woostuff.wordpress.com/2011/09/05/qgis-tips-custom-feature-forms-with-python-logic/
>
> It seems that with this, there's no limit ;)
>
> Bests,
>
> Olivier
>
>
> 2015-01-12 8:51 GMT+00:00 Matthias Kuhn <matthias.kuhn at gmx.ch
> <mailto:matthias.kuhn at gmx.ch>>:
>
> Hi Olivier,
>
> There is some support for this in the value relation widget. If you
> allow multiple selections, it will make use of the array notation,
> storing multiple foreign keys ( { fk1, fk2, fk3 } ).
>
> If you want to get further support for this, you could write your
> own form elements which is possible for some time (although I
> haven't seen it widely used).
> http://blog.vitu.ch/10142013-1847/write-your-own-qgis-form-elements
>
> For your last use-case "same number of items" you should consider to
> normalize your database and and have two tables linked with a
> foreign key.
>
> CREATE TABLE lots(
> id serial,
> common_data text
> )
>
> CREATE TABLE person(
> id serial,
> first_names text,
> last_names text,
> age int,
> group integer REFERENCES lots(id)
> )
>
> Matthias
>
>
> On 01/11/2015 03:17 PM, Olivier Dalang wrote:
>> Hi !
>>
>> Postgres' arrays are a great feature. They allow store several
>> values in one field :
>>
>> CREATE TABLE lots(
>> id serial,
>> owners text[]
>> );
>> INSERT INTO lots(owners) VALUES( ARRAY['john','mike','jenny'] );
>>
>> But is there a way to edit this cleanly in QGIS with the forms ?
>> Natively, the form widget will be a plain text input, and the
>> value will display like this
>> {"john","mike","jenny"}
>> This is more or less usable for text fields, but not really clean,
>> since the user needs to escape some characters, and it's not very
>> readable. But then it's impossible to use with other widgets
>> (checkbox, range, etc.)
>>
>> I'd love to have a dynamic input where the user could add and
>> remove fields, and where QGIS widget types could be used.
>>
>> Actually, I'd even need a form where I'd have the same number of
>> items for several arrays, and where adding/removing an item would
>> work on several field at once, to work on a table like this :
>> CREATE TABLE lots(
>> id serial,
>> first_names text[],
>> last_names text[],
>> age int[]
>> );
>>
>>
>> Is there a way to do it ?
>> Maybe with python ?
>> Has anyone of you already done this and would agree to share ?
>> Any pointer in the right direction would be very welcome !
>>
>> Thanks a lot in advance,
>>
>>
>> Olivier
>>
>>
__________ Information from ESET Mail Security, version of virus signature database 11023 (20150116) __________
The message was checked by ESET Mail Security.
http://www.eset.com
More information about the Qgis-user
mailing list