From ca0bbec3c9ce2defee96743cf63227e46cd01c11 Mon Sep 17 00:00:00 2001 From: Lionel Elie Mamane Date: Fri, 28 Jun 2013 16:12:26 +0200 Subject: fdo#66130 correct "skip column name" condition for LIKE predicate When converting a parse tree to SQL snippet for a predicate in the context of a column, we skip the name of the same column in 'simple' cases. This is used mainly in the "Criterion" lines of query design, and in the search/filter dialogs of forms, tables, etc. In all other cases (such as when creating a full SQL command, or for references to *other* columns than the context one), the column name must be printed out. In this respect, the condition "should we skip the column name?" in impl_parseLikeNodeToString_throw was buggy, and different from the one in the general case (in impl_parseNodeToString_throw), leading to generating invalid SQL like: SELECT foo, bar FROM baz LEFT JOIN qux ON LIKE qux.quu instead of SELECT foo, bar FROM baz LEFT JOIN qux ON baz.baa LIKE qux.quu Change-Id: Ie14fce319554a66feb0fd0ce1a03d947a46a820a Reviewed-on: https://gerrit.libreoffice.org/4606 Reviewed-by: Fridrich Strba Tested-by: Fridrich Strba --- connectivity/source/parse/sqlnode.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index 272deb1a3eb0..c6799bba547a 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -756,7 +756,7 @@ void OSQLParseNode::impl_parseLikeNodeToString_throw( OUStringBuffer& rString, c SQLParseNodeParameter aNewParam(rParam); //aNewParam.bQuote = sal_True; // why setting this to true? @see http://www.openoffice.org/issues/show_bug.cgi?id=75557 - if (bSimple && (!rParam.xField.is() || !columnMatchP(m_aChildren[0], rParam))) + if ( !(bSimple && rParam.bPredicate && rParam.xField.is() && SQL_ISRULE(m_aChildren[0],column_ref) && columnMatchP(m_aChildren[0], rParam)) ) m_aChildren[0]->impl_parseNodeToString_throw( rString, aNewParam, bSimple ); const OSQLParseNode* pPart2 = m_aChildren[1]; -- cgit v1.2.3