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
From fcc72b68bbe47606b0b416c06ee43109b76fe0f7 Mon Sep 17 00:00:00 2001 From: Olivier Ploton <olivier.ploton@univ-tours.fr> Date: Wed, 12 Dec 2012 22:04:38 +0100 Subject: [PATCH] Base: fix incorrect field removal in criterion inside query design view --- connectivity/source/parse/sqlnode.cxx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index 73fd510..38f187e 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -463,8 +463,11 @@ void OSQLParseNode::impl_parseNodeToString_throw(::rtl::OUStringBuffer& rString, if (rParam.xField.is() && SQL_ISRULE(pSubTree,subquery)) aNewParam.xField = NULL; - // if there is a field given we don't display the fieldname, if there is any - if (rParam.xField.is() && SQL_ISRULE(pSubTree,column_ref)) + // Special case: if there is a field given we are building + // a criterion inside a query view (and rString is supposed + // to be initially empty). In order to simplify criterion text + // inside view, omit fieldname if it appears as 1st token. + if ((rString.getLength() == 0) && rParam.xField.is() && SQL_ISRULE(pSubTree,column_ref)) { sal_Bool bFilter = sal_False; // retrieve the fields name -- 1.7.9.5
Attachment:
pairs.odb
Description: application/vnd.oasis.opendocument.database