Feature request #954

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

Added by Steven Mizuno almost 17 years ago. Updated over 15 years ago.

Status:Closed
Priority:Low
Assignee:nobody -
Category:Data Provider
Pull Request or Patch supplied: Resolution:fixed
Easy fix?:No Copied to github as #:11013

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)

2. 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)

3. couldn't add or delete such columns

4. 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.

patch_for_bug_954.txt Magnifier (1.67 KB) Steven Mizuno, 2008-02-19 04:10 PM

History

#1 Updated by Steven Mizuno almost 17 years ago

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.

#2 Updated by Marco Hugentobler almost 17 years ago

  • Resolution set to fixed
  • Status changed from Open to Closed

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

Marco

#3 Updated by Anonymous over 15 years ago

Milestone Version 0.9.2 deleted

Also available in: Atom PDF