Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default values on a PG table: type cast appended #21880

Closed
qgib opened this issue Nov 19, 2015 · 14 comments
Closed

Default values on a PG table: type cast appended #21880

qgib opened this issue Nov 19, 2015 · 14 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Data Provider Related to specific vector, raster or mesh data providers

Comments

@qgib
Copy link
Contributor

qgib commented Nov 19, 2015

Author Name: Paolo Cavallini (@pcav)
Original Redmine Issue: 13857
Affected QGIS version: 2.8.3
Redmine category:data_provider/postgis
Assignee: Jürgen Fischer


If the table has a default value, this is used in QGIS, but quotes and a type cast is added to it, e.g.:

'test123'::character varying

instead of:

test123


Related issue(s): #20565 (duplicates), #21782 (relates)
Redmine related issue(s): 12391, 13755


@qgib
Copy link
Contributor Author

qgib commented Nov 19, 2015

Author Name: Jürgen Fischer (@jef-n)


Defaults values are kept verbatim (not only for @'test123'::character varying@, but also @nextval('foo_id_seq'::regclass)@). What's the problem with it?


  • status_id was changed from Open to Feedback

@qgib
Copy link
Contributor Author

qgib commented Nov 19, 2015

Author Name: Paolo Cavallini (@pcav)


e.g. if I insert a path to a photo, and set the field widget to photo, the image itself fails to be displayed because of the additional text added.

@qgib
Copy link
Contributor Author

qgib commented Nov 22, 2015

Author Name: Paolo Cavallini (@pcav)


If the table does not have a PK, and only one field, apparently the cast is not added.

@qgib
Copy link
Contributor Author

qgib commented Nov 23, 2015

Author Name: Jürgen Fischer (@jef-n)


Paolo Cavallini wrote:

If the table does not have a PK, and only one field, apparently the cast is not added.

Can't reproduce that with:

qgis=> create table issue13857(file varchar default '/tmp/foo.png');
CREATE TABLE
qgis=> \\d issue13857
                       Table "public.issue13857"
 Column |       Type        |                 Modifiers                 
--------+-------------------+-------------------------------------------
 file   | character varying | default '/tmp/foo.png'::character varying


@qgib
Copy link
Contributor Author

qgib commented Nov 23, 2015

Author Name: Paolo Cavallini (@pcav)


OK, so last think must have been a local mistake. Sorry about the noise.

@qgib
Copy link
Contributor Author

qgib commented Dec 19, 2015

Author Name: Giovanni Manghi (@gioman)


  • resolution was changed from to invalid
  • status_id was changed from Feedback to Closed

@qgib
Copy link
Contributor Author

qgib commented Dec 19, 2015

Author Name: Paolo Cavallini (@pcav)


Giovanni, please don't close valid issues. Thanks.


  • status_id was changed from Closed to Reopened

@qgib
Copy link
Contributor Author

qgib commented Dec 20, 2015

Author Name: Giovanni Manghi (@gioman)


Paolo Cavallini wrote:

Giovanni, please don't close valid issues. Thanks.

didn't you stated it was a 'local mistake'?


  • resolution was changed from invalid to

@qgib
Copy link
Contributor Author

qgib commented Dec 20, 2015

Author Name: Giovanni Manghi (@gioman)


  • status_id was changed from Reopened to Feedback

@qgib
Copy link
Contributor Author

qgib commented Dec 22, 2015

Author Name: Paolo Cavallini (@pcav)


This refers to the PK issue, not to the main one, which is still valid.


  • status_id was changed from Feedback to Open

@qgib
Copy link
Contributor Author

qgib commented Dec 24, 2015

Author Name: Giovanni Manghi (@gioman)


I cannot confirm the specific issue described here, a default defined as

'test123'::character varying

returns as expected

test123

after adding new records and saving.

On the other hand a default defined as

('now'::text)::date

(in a date column of course), works if adding a record in pgadmin (and other backends) but in QGIS does not work and it returns always NULL.

QGIS 2.8.4, pgsql 9.3 and postgis 2.1


  • status_id was changed from Open to Feedback

@qgib
Copy link
Contributor Author

qgib commented Dec 24, 2015

Author Name: Jürgen Fischer (@jef-n)


Giovanni Manghi wrote:

('now'::text)::date

(in a date column of course), works if adding a record in pgadmin (and other backhands) but in QGIS does not work and it returns always NULL
QGIS 2.8.4, pgsql 9.3 and postgis 2.1

works fine for me in master too (PostgreSQL 9.4)

@qgib
Copy link
Contributor Author

qgib commented Dec 25, 2015

Author Name: Giovanni Manghi (@gioman)


Jürgen Fischer wrote:

Giovanni Manghi wrote:

('now'::text)::date

(in a date column of course), works if adding a record in pgadmin (and other backhands) but in QGIS does not work and it returns always NULL
QGIS 2.8.4, pgsql 9.3 and postgis 2.1

works fine for me in master too (PostgreSQL 9.4)

confirmed also in another platform that on master

('now'::text)::date

works ok but not on 2.8.5, while

'test123'::character varying

works as expected on both.

@qgib
Copy link
Contributor Author

qgib commented Dec 26, 2015

Author Name: Jürgen Fischer (@jef-n)


Fixed in changeset "4c3cf64f01af32511ef5fc56b0b13aa705c00dd6".


  • status_id was changed from Feedback to Closed

@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! Data Provider Related to specific vector, raster or mesh data providers labels May 25, 2019
@qgib qgib closed this as completed May 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Data Provider Related to specific vector, raster or mesh data providers
Projects
None yet
Development

No branches or pull requests

1 participant