Opened 16 years ago

Closed 16 years ago

Last modified 15 years ago

#938 closed bug (fixed)

table editor can't search in varchar columns of PostGIS layers

Reported by: msieczka Owned by: nobody
Priority: major: does not work as expected Milestone:
Component: Vectors Version: Trunk
Keywords: patch Cc:
Must Fix for Release: Yes Platform: Debian
Platform Version: Awaiting user input: no

Description

  1. Add a PostGIS layer with varchar field.
  1. "Open Table"
  1. The varchar column name is not available in the combo box with column names in the bottom. An empty slot there instead.
  1. If you select this empty one, enter a string in "Search for:" field ann press search, a "Search string parsing error:" windows pops up which reads:
syntax error, unexpected COMPARISON

BTW - why is the "varchar(30)" forced in the add column dialog? If the lenght can't be made optional easily, why not force "varchar(256)" instead and not force the user to use "text" for anything longer than 30 chars?

SVN r8110, built and running against QT 4.3.3 and QT 4.3.2 on the other machine.

Attachments (1)

patch_for_bug_938.txt (753 bytes ) - added by smizuno 16 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 by smizuno, 16 years ago

I find that there is a blank item in the drop-down list AND the last column in the table is missing from the list. This doesn't occur for all tables. The missing column may be of any type.

The blank list item follows a column used by QGIS for the feature id (the primary key or unique index, SERIAL4/INT4 type in the table) and that the last column is not in the list. If the feature id is last there is no blank item.

The number of items in the list matches the number of columns that should be listed (the geometry column is not listed).

I am using Mandriva 2008.0 x86_64, QGIS r8155 built against Qt 4.3.3, PostgreSQL 8.2.6/PostGIS 1.3.2

Also have checked with 0.9.1 (same building and on Windows XP, binary package) and it has the same problem.

comment:2 by smizuno, 16 years ago

I just realized that I wasn't paying attention to the position of the geometry column. It is at the position of the geometry column that the blank list item occurs, not following the feature id column.

This can be shown by building a table where the feature id column is first, then a column of a type other than geometry, the geometry column, then two more columns of a type other than geometry.

The drop-down list for this table will be blank in the position where the geometry column is, then the first column after the geometry column is present, and the last column is missing.

by smizuno, 16 years ago

Attachment: patch_for_bug_938.txt added

comment:3 by smizuno, 16 years ago

Keywords: patch added

On a further look at this problem: in QgsAttributeTableDisplay constructor where mSearchColumns is loaded the original code uses a standard C 'for' loop using an index counter and the number of fields as a terminating condition. Then, the fields variable is accessed by index, resulting in the blank at the position the geometry column is at and not accessing the last field.

I noticed that in qgsattributetable.cpp where the table header is loaded that an Iterator on a Map is used. I tried this idea to load mSearchColumns and it works.

Refer to the attached patch for the changes.

I have tested the patch on PostGIS layers as well as shapefile layers.

comment:4 by mhugent, 16 years ago

Resolution: fixed
Status: newclosed

Thanks for this patch, smizuno! It is applied to svn now (r8166) with minor modifications (some additional consts).

Marco

comment:5 by (none), 15 years ago

Milestone: Version 0.9.2

Milestone Version 0.9.2 deleted

Note: See TracTickets for help on using tickets.