connectivity/source/parse/sqliterator.cxx              |    4 ++++
 connectivity/source/parse/sqlnode.cxx                  |    5 ++++-
 dbaccess/source/core/api/SingleSelectQueryComposer.cxx |    2 +-
 dbaccess/source/core/inc/SingleSelectQueryComposer.hxx |    1 +
 include/connectivity/sqlparse.hxx                      |   10 +++++++---
 5 files changed, 17 insertions(+), 5 deletions(-)

New commits:
commit 6896c46567c571a7ae6eb60268de962e3d4ae8bb
Author:     Henry Castro <[email protected]>
AuthorDate: Wed Aug 30 10:25:51 2023 -0400
Commit:     Henry Castro <[email protected]>
CommitDate: Fri Sep 1 21:39:57 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]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156425
    Tested-by: Jenkins

diff --git a/connectivity/source/parse/sqliterator.cxx 
b/connectivity/source/parse/sqliterator.cxx
index 1a205953f7aa..683391f66f6a 100644
--- a/connectivity/source/parse/sqliterator.cxx
+++ b/connectivity/source/parse/sqliterator.cxx
@@ -2109,7 +2109,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 3d910abdaa18bbd237834f412675ab25d90836bc
Author:     Henry Castro <[email protected]>
AuthorDate: Wed Aug 30 10:23:31 2023 -0400
Commit:     Henry Castro <[email protected]>
CommitDate: Fri Sep 1 21:39:46 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]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156424
    Tested-by: Jenkins

diff --git a/connectivity/source/parse/sqlnode.cxx 
b/connectivity/source/parse/sqlnode.cxx
index 782a45bf760f..7e01770d386d 100644
--- a/connectivity/source/parse/sqlnode.cxx
+++ b/connectivity/source/parse/sqlnode.cxx
@@ -1306,8 +1306,11 @@ std::unique_ptr<OSQLParseNode> 
OSQLParser::predicateTree(OUString& rErrorMessage
 }
 
 
-OSQLParser::OSQLParser(css::uno::Reference< css::uno::XComponentContext > 
xContext, const IParseContext* _pContext)
+OSQLParser::OSQLParser(css::uno::Reference< css::uno::XComponentContext > 
xContext,
+                       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 4e37188e7231..895657475f25 100644
--- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
+++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
@@ -217,7 +217,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 15400c112240..4ccd5ebbea95 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(css::uno::Reference< css::uno::XComponentContext > 
xContext, const IParseContext* _pContext = nullptr);
+        OSQLParser(css::uno::Reference< css::uno::XComponentContext > xContext,
+                   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;

Reply via email to