Opened 16 years ago

Closed 16 years ago

Last modified 15 years ago

#954 closed patch (fixed)

PostGIS tables with uppercase column names do not display/edit data

Reported by: smizuno Owned by: nobody
Priority: critical: causes crash or data corruption Milestone:
Component: Data Provider Version: Trunk
Keywords: Cc:
Must Fix for Release: Yes Platform: All
Platform Version: Awaiting user input: no

Description

On PostGIS/PostgreSQL tables that have uppercase and other special characters in their column names, I have noticed that:

  1. Identify, Attribute Table, MapTips don't display values for column names that have uppercase, but the column name is displayed (if appropriate)
  1. when opening Attribute Table there are messages on the console like: "column number -1 is out of range 0..7" - one message for each such attribute (the range shown varies with the number of columns in the table)
  1. couldn't add or delete such columns
  1. couldn't update such columns

So, trying my hand at fixing PostgreSQL object name quoting, I have modified qgspostgresprovider.cpp in four places as shown in the attached patch file. I have added \" before and after the affected PostgreSQL object names in the query strings being constructed.

A code enhancement would be to add a function like quoteIdentifier() that takes a string (the identifier) and adds double quotes on both ends. Then any use of an identifier in a SQL string would be like: "SELECT " + quoteIdentifier(someString) + "..." This seems like extra work but I believe it leads to fewer mistakes as adding the quotes in-line is tedious and sometimes confusing as to exactly where in the string they go. This would also give a single place to add other processing on an identifier if it were ever necessary.

I would be willing to give this a try.

Attachments (1)

patch_for_bug_954.txt (1.7 KB ) - added by smizuno 16 years ago.

Download all attachments as: .zip

Change History (4)

by smizuno, 16 years ago

Attachment: patch_for_bug_954.txt added

comment:1 by smizuno, 16 years ago

Platform: MandrivaAll
Platform Version: 2008.0 x86_64

replaced the patch attachment with a corrected file as I discovered some extra spaces were being added to the column name in the ADD column part of the patch.

Changed Platform to All as this problem affects all platforms as far as I can tell.

I failed to note that the patch fixes all of the problems listed.

comment:2 by mhugent, 16 years ago

Resolution: fixed
Status: newclosed

Thanks! The patch is applied in r8172. I also think that a function quoteIdentifier(someString) would be a good thing and looking forward for a further patch.

Marco

comment:3 by (none), 15 years ago

Milestone: Version 0.9.2

Milestone Version 0.9.2 deleted

Note: See TracTickets for help on using tickets.