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 | 16 ++++++++++++++++ 7 files changed, 43 insertions(+), 8 deletions(-)
New commits: commit 29aeafb25efcba6c3dab3b7842f383fcb0eab700 Author: Henry Castro <hcas...@collabora.com> AuthorDate: Wed Aug 30 10:25:51 2023 -0400 Commit: Aron Budea <aron.bu...@collabora.com> CommitDate: Fri Sep 1 23:21:01 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 <hcas...@collabora.com> Change-Id: I1faa8ff8417a0fc4996b289bd2ce0baad52fc00c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156298 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> (cherry picked from commit 0d579a1b8122eed6348ee4a512573277e2d5db77) diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx index 662a000870b7..c9733477b2bf 100644 --- a/connectivity/source/parse/sqliterator.cxx +++ b/connectivity/source/parse/sqliterator.cxx @@ -2108,7 +2108,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 c22c356cc1b7c08313a46a8269f4f43eb76ecf75 Author: Henry Castro <hcas...@collabora.com> AuthorDate: Wed Aug 30 10:23:31 2023 -0400 Commit: Aron Budea <aron.bu...@collabora.com> CommitDate: Fri Sep 1 23:20:31 2023 +0200 connectivity: add neutral context parser Signed-off-by: Henry Castro <hcas...@collabora.com> Change-Id: I12b0fe811d141873aaa64af5b6c457051c3356b0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156297 Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> (cherry picked from commit 57379b62950d5730cdd0ec2b14eaf55370a3298e) diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index 947c1ef49580..e2b1daddde9e 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 401d2dcf4fb9..6af7d64c0af9 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 a0edfd195a69..fdde2d451d17 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 b36b4910301470f861e3b7a80683cf3fa4c390c5 Author: Henry Castro <hcas...@collabora.com> AuthorDate: Wed Aug 30 10:16:37 2023 -0400 Commit: Aron Budea <aron.bu...@collabora.com> CommitDate: Fri Sep 1 23:17:45 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 <hcas...@collabora.com> Change-Id: I191b9591ad796d0dd9509c0fb10b11c16f72e1ce Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156296 Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com> (cherry picked from commit 091d74c16e33a1c4cf3e456363965528392f7033) 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 63634179142e..d231bfb3cd52 100644 --- a/svx/source/form/ParseContext.cxx +++ b/svx/source/form/ParseContext.cxx @@ -41,6 +41,11 @@ OSystemParseContext::OSystemParseContext() m_aLocalizedKeywords.push_back(SvxResId(RID_RSC_SQL_INTERNATIONAL[i])); } +OSystemParseContext::OSystemParseContext(bool /*bInit*/) + : IParseContext() +{ +} + OSystemParseContext::~OSystemParseContext() { } @@ -140,6 +145,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 46a481772040063a4207a6ec691d8ddb9529108d Author: Henry Castro <hcas...@collabora.com> AuthorDate: Wed Aug 30 10:09:05 2023 -0400 Commit: Aron Budea <aron.bu...@collabora.com> CommitDate: Fri Sep 1 22:14:22 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 <hcas...@collabora.com> Change-Id: I2b57d1dfc005711374d7ae0de66b412f4f551d89 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156295 Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com> (cherry picked from commit 985559a9d8e1e0bd0b6bddc1776c0c06fb029160) diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index 5247457d5b3d..947c1ef49580 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;