[PATCH] Base: fix incorrect field removal in criterion inside query design view

Olivier Ploton olivier.ploton at univ-tours.fr
Wed Dec 12 13:53:07 PST 2012


Problem: you cannot type a field name inside a criterion
if the field name is also the column name, even if it is qualified.

For example (see attached file: pairs.odb), 
Query pairs_SQL can not be generated using query design view :
Inside first column, named "name", typing in something like
   < [Table_1].[name]
or
   < "Table_1"."name"
inside a criterion leads to an error.

I prepared a patch. I hope it is correct and useful.
Here is my idea about it:

When you change a criterion and validate, Base calls
OSelectionBrowseBox::SaveModified() in "SelectionBrowseBox.cxx".
There is a big "switch" statement. Criterion is default case.
The text is parsed to a syntax tree (OSQLParseNode*) an back to text
via OSQLParseNode::parseNodeToPredicateStr
calling  OSQLParseNode::impl_parseNodeToString_throw in "sqlnode.cxx".
impl_parseNodeToString_throw simplifies output by removing
column name, but it should be removed only at the very beginning.

The output is written in a string buffer.
The patch relies on the buffer being initially empty.
Actually, the patch would also transform 
[name][name]text      into     text,
but this kind of input is impossible (syntax error).

--
Olivier Ploton
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Base-fix-incorrect-field-removal-in-criterion-inside.patch
Type: text/x-diff
Size: 1463 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20121212/a3e219a6/attachment-0001.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pairs.odb
Type: application/vnd.oasis.opendocument.database
Size: 4167 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20121212/a3e219a6/attachment-0001.odb>


More information about the LibreOffice mailing list