summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorLionel Elie Mamane <lionel@mamane.lu>2013-06-28 16:12:26 +0200
committerFridrich Strba <fridrich@documentfoundation.org>2013-06-29 07:46:22 +0000
commitca0bbec3c9ce2defee96743cf63227e46cd01c11 (patch)
tree09de0dfd9dc109f259f5711c1514898a6cfaaa86 /connectivity
parent7af9fea258fe9429d0ff06a705fe294eb36d1c86 (diff)
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 <fridrich@documentfoundation.org> Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/source/parse/sqlnode.cxx2
1 files changed, 1 insertions, 1 deletions
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];