Opened 13 years ago

Closed 8 years ago

#4280 closed enhancement (fixed)

[PATCH] SQL parser : differentiate quoting of string literals from identifiers

Reported by: Even Rouault Owned by: warmerdam
Priority: normal Milestone: 2.0.0
Component: OGR_SF Version: unspecified
Severity: normal Keywords: sql
Cc: rhaubourg


To avoid any ambiguities and more conformant to SQL, string literals should be single-quoted, and identifiers (column/table names) unquoted or surrounded by double-quote charachter if conflicting with reserved keywords.

The attached patch implements this, as well as the necesserary fixes in the test suite. This obviously shows the impact of the patch to user practices...

Attachments (1)

ticket_4280.patch (41.8 KB ) - added by Even Rouault 13 years ago.

Download all attachments as: .zip

Change History (6)

by Even Rouault, 13 years ago

Attachment: ticket_4280.patch added

comment:1 by Even Rouault, 10 years ago

Cc: rhaubourg added
Milestone: 2.0

Also reported as #5428

comment:2 by rhaubourg, 10 years ago

thanks! Sorry if I didn't find previous issue in the tracker.

Just some precisions please. I understand that " and ' are currently confusing delimiters for text or identifier. So that explains why "myfield" = 'myfield' returns always true. But why "myfield" = 'another_value' is working correctly then? Cheers, Régis

comment:3 by Even Rouault, 10 years ago

'another_value' matching no field name it is treated as a litteral value (as it should in SQL). But if 'another_value' is in fact 'a_valid_field_name' the SQL engine wrongly assumes that it was the quoting of a_valid_field_name. The quoting of identifiers should be double quotes, and not single quotes, but the SQL engine does not make that difference right now.

comment:4 by Even Rouault, 9 years ago

Milestone: 2.0

Removing obsolete milestone

comment:5 by Even Rouault, 8 years ago

Milestone: 2.0.0
Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.