connectivity/source/parse/sqliterator.cxx | 4 ++++ connectivity/source/parse/sqlnode.cxx | 7 +++++-- dbaccess/source/core/api/SingleSelectQueryComposer.cxx | 2 +- dbaccess/source/core/inc/SingleSelectQueryComposer.hxx | 1 + include/connectivity/sqlparse.hxx | 10 +++++++--- include/svx/ParseContext.hxx | 11 +++++++++-- svx/source/form/ParseContext.cxx | 17 +++++++++++++++++ 7 files changed, 44 insertions(+), 8 deletions(-)
New commits: commit 17186d0da18c54b4ad9aea05a2643fb95a125a4f Author: Henry Castro <[email protected]> AuthorDate: Wed Aug 30 10:25:51 2023 -0400 Commit: Aron Budea <[email protected]> CommitDate: Sat Sep 2 02:09:09 2023 +0200 connectiviy: fix to detect column data type if Base SQL query: SELECT COUNT("test"."id") from Test If changed to Spanish UI, detect the column type from a neutral context parser. Signed-off-by: Henry Castro <[email protected]> Change-Id: I1faa8ff8417a0fc4996b289bd2ce0baad52fc00c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156298 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Caolán McNamara <[email protected]> (cherry picked from commit 0d579a1b8122eed6348ee4a512573277e2d5db77) (cherry picked from commit 29aeafb25efcba6c3dab3b7842f383fcb0eab700) diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx index 94df96d39628..7478300c4e3f 100644 --- a/connectivity/source/parse/sqliterator.cxx +++ b/connectivity/source/parse/sqliterator.cxx @@ -2101,7 +2101,11 @@ sal_Int32 OSQLParseTreeIterator::getFunctionReturnType(const OSQLParseNode* _pNo nType = DataType::DOUBLE; } else + { nType = ::connectivity::OSQLParser::getFunctionReturnType( sFunctionName, &m_rParser.getContext() ); + if (nType == DataType::SQLNULL) + nType = ::connectivity::OSQLParser::getFunctionReturnType( sFunctionName, m_rParser.getNeutral() ); + } } return nType; commit 06e4d7d2ad6b9343603f33d740bf3b30432dc483 Author: Henry Castro <[email protected]> AuthorDate: Wed Aug 30 10:23:31 2023 -0400 Commit: Aron Budea <[email protected]> CommitDate: Sat Sep 2 02:08:59 2023 +0200 connectivity: add neutral context parser Signed-off-by: Henry Castro <[email protected]> Change-Id: I12b0fe811d141873aaa64af5b6c457051c3356b0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156297 Tested-by: Caolán McNamara <[email protected]> Reviewed-by: Caolán McNamara <[email protected]> (cherry picked from commit 57379b62950d5730cdd0ec2b14eaf55370a3298e) (cherry picked from commit c22c356cc1b7c08313a46a8269f4f43eb76ecf75) diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index 0321f827a8e7..7c8f1ea8da2b 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -1316,8 +1316,11 @@ std::unique_ptr<OSQLParseNode> OSQLParser::predicateTree(OUString& rErrorMessage } -OSQLParser::OSQLParser(const css::uno::Reference< css::uno::XComponentContext >& rxContext, const IParseContext* _pContext) +OSQLParser::OSQLParser(const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const IParseContext* _pContext, + const IParseContext* _pNeutral) :m_pContext(_pContext) + ,m_pNeutral(_pNeutral) ,m_pData( new OSQLParser_Data ) ,m_nFormatKey(0) ,m_nDateFormatKey(0) diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx index 2284f1db3e3f..31a78012f0f0 100644 --- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx +++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx @@ -216,7 +216,7 @@ OSingleSelectQueryComposer::OSingleSelectQueryComposer(const Reference< XNameAcc const Reference<XComponentContext>& _rContext ) :OSubComponent(m_aMutex,_xConnection) ,OPropertyContainer(m_aBHelper) - ,m_aSqlParser( _rContext, &m_aParseContext ) + ,m_aSqlParser( _rContext, &m_aParseContext, &m_aNeutralContext ) ,m_aSqlIterator( _xConnection, _rxTables, m_aSqlParser ) ,m_aAdditiveIterator( _xConnection, _rxTables, m_aSqlParser ) ,m_aElementaryParts( size_t(SQLPartCount) ) diff --git a/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx b/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx index 356d00aafdb0..2366d3c39943 100644 --- a/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx +++ b/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx @@ -76,6 +76,7 @@ namespace dbaccess typedef std::function<const ::connectivity::OSQLParseNode*(::connectivity::OSQLParseTreeIterator *)> TGetParseNode; ::svxform::OSystemParseContext m_aParseContext; + ::svxform::ONeutralParseContext m_aNeutralContext; ::connectivity::OSQLParser m_aSqlParser; ::connectivity::OSQLParseTreeIterator m_aSqlIterator; // the iterator for the complete statement ::connectivity::OSQLParseTreeIterator m_aAdditiveIterator; // the iterator for the "additive statement" (means without the clauses of the elementary statement) diff --git a/include/connectivity/sqlparse.hxx b/include/connectivity/sqlparse.hxx index b92ff3b1c7c0..cbfd3dfaf557 100644 --- a/include/connectivity/sqlparse.hxx +++ b/include/connectivity/sqlparse.hxx @@ -124,7 +124,8 @@ namespace connectivity static sal_Int32 s_nRefCount; // information on the current parse action - const IParseContext* m_pContext; + const IParseContext* m_pContext; + const IParseContext* m_pNeutral; std::unique_ptr<OSQLParseNode> m_pParseTree; // result from parsing ::std::unique_ptr< OSQLParser_Data > m_pData; @@ -156,7 +157,9 @@ namespace connectivity public: // if NULL, a default context will be used // the context must live as long as the parser - OSQLParser(const css::uno::Reference< css::uno::XComponentContext >& rxContext, const IParseContext* _pContext = nullptr); + OSQLParser(const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const IParseContext* _pContext = nullptr, + const IParseContext* _pNeutral = nullptr); ~OSQLParser(); // Parsing an SQLStatement @@ -173,7 +176,8 @@ namespace connectivity bool bUseRealName = true); // Access to the context - const IParseContext& getContext() const {return *m_pContext;} + const IParseContext& getContext() const { return *m_pContext; } + const IParseContext* getNeutral() const { return m_pNeutral; } /// access to the SQLError instance owned by this parser const SQLError& getErrorHelper() const; commit cb61e0c751e1078e62cce673cd1114be7426981d Author: Henry Castro <[email protected]> AuthorDate: Wed Aug 30 10:16:37 2023 -0400 Commit: Aron Budea <[email protected]> CommitDate: Sat Sep 2 02:08:15 2023 +0200 svx: add class "ONeutralParseContext" If Base SQL query: SELECT COUNT("test"."id") FROM Test Then changed to Spanish interface, it is required to have a neutral keyword localized, the "COUNT" will fail to detect column type, because the keyword in Spanish is "RECUENTO" Signed-off-by: Henry Castro <[email protected]> Change-Id: I191b9591ad796d0dd9509c0fb10b11c16f72e1ce Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156296 Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Caolán McNamara <[email protected]> (cherry picked from commit 091d74c16e33a1c4cf3e456363965528392f7033) (cherry picked from commit b36b4910301470f861e3b7a80683cf3fa4c390c5) diff --git a/include/svx/ParseContext.hxx b/include/svx/ParseContext.hxx index 18c23ad209ed..60344a7d9b66 100644 --- a/include/svx/ParseContext.hxx +++ b/include/svx/ParseContext.hxx @@ -31,11 +31,12 @@ namespace svxform //= OSystemParseContext - class SVXCORE_DLLPUBLIC OSystemParseContext final : public ::connectivity::IParseContext + class SVXCORE_DLLPUBLIC OSystemParseContext : public ::connectivity::IParseContext { - private: + protected: ::std::vector< OUString > m_aLocalizedKeywords; + OSystemParseContext(bool bInit); public: OSystemParseContext(); @@ -57,6 +58,12 @@ namespace svxform }; + class SAL_DLLPUBLIC_RTTI ONeutralParseContext final : public OSystemParseContext + { + public: + SVXCORE_DLLPUBLIC ONeutralParseContext(); + SVXCORE_DLLPUBLIC virtual ~ONeutralParseContext(); + }; //= OParseContextClient diff --git a/svx/source/form/ParseContext.cxx b/svx/source/form/ParseContext.cxx index d86892ac804a..3481f8d36b72 100644 --- a/svx/source/form/ParseContext.cxx +++ b/svx/source/form/ParseContext.cxx @@ -25,6 +25,7 @@ #include <svx/dialmgr.hxx> #include <i18nlangtag/languagetag.hxx> +#include <unotools/resmgr.hxx> #include <unotools/syslocale.hxx> #include <vcl/svapp.hxx> #include <osl/diagnose.h> @@ -41,6 +42,11 @@ OSystemParseContext::OSystemParseContext() m_aLocalizedKeywords.push_back(SvxResId(RID_RSC_SQL_INTERNATIONAL[i])); } +OSystemParseContext::OSystemParseContext(bool /*bInit*/) + : IParseContext() +{ +} + OSystemParseContext::~OSystemParseContext() { } @@ -140,6 +146,17 @@ IParseContext::InternationalKeyCode OSystemParseContext::getIntlKeyCode(const OS return InternationalKeyCode::None; } +ONeutralParseContext::ONeutralParseContext() + : OSystemParseContext(false) +{ + std::locale aLocale = Translate::Create("svx", LanguageTag("en-US")); + for (size_t i = 0; i < SAL_N_ELEMENTS(RID_RSC_SQL_INTERNATIONAL); ++i) + m_aLocalizedKeywords.push_back(Translate::get(RID_RSC_SQL_INTERNATIONAL[i], aLocale)); +} + +ONeutralParseContext::~ONeutralParseContext() +{ +} namespace { commit e652fa445594cfae56151502c2c2859f52b64811 Author: Henry Castro <[email protected]> AuthorDate: Wed Aug 30 10:09:05 2023 -0400 Commit: Aron Budea <[email protected]> CommitDate: Sat Sep 2 00:28:25 2023 +0200 connectivity: fix return column type "DataType::SQLNULL" The Base SQL query: SELECT COUNT( "Test"."id" ) FROM "Test" And the UI language is set to Spanish, the function "getFunctionReturnType" returns misleading column type. Signed-off-by: Henry Castro <[email protected]> Change-Id: I2b57d1dfc005711374d7ae0de66b412f4f551d89 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156295 Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Caolán McNamara <[email protected]> (cherry picked from commit 985559a9d8e1e0bd0b6bddc1776c0c06fb029160) (cherry picked from commit 46a481772040063a4207a6ec691d8ddb9529108d) diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index c4c28dc4a822..0321f827a8e7 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -2511,7 +2511,7 @@ void OSQLParseNode::parseLeaf(OUStringBuffer& rString, const SQLParseNodeParamet sal_Int32 OSQLParser::getFunctionReturnType(std::u16string_view _sFunctionName, const IParseContext* pContext) { - sal_Int32 nType = DataType::VARCHAR; + sal_Int32 nType = DataType::SQLNULL; OString sFunctionName(OUStringToOString(_sFunctionName,RTL_TEXTENCODING_UTF8)); if(sFunctionName.equalsIgnoreAsciiCase(TokenIDToStr(SQL_TOKEN_ASCII,pContext))) nType = DataType::INTEGER;
