[Libreoffice-commits] .: 2 commits - connectivity/inc dbaccess/source

Lionel Elie Mamane lmamane at kemper.freedesktop.org
Wed Jan 18 03:37:49 PST 2012


 connectivity/inc/connectivity/dbtools.hxx |    4 -
 dbaccess/source/core/api/KeySet.cxx       |   71 +++++++++++++++++++++---------
 dbaccess/source/core/api/KeySet.hxx       |    5 ++
 dbaccess/source/core/api/RowSet.hxx       |    2 
 4 files changed, 59 insertions(+), 23 deletions(-)

New commits:
commit c2567a658735423948d76992ca744a4187620928
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Wed Jan 18 12:31:06 2012 +0100

    janitorial: typo in comments

diff --git a/connectivity/inc/connectivity/dbtools.hxx b/connectivity/inc/connectivity/dbtools.hxx
index 3555025..24f39cb 100644
--- a/connectivity/inc/connectivity/dbtools.hxx
+++ b/connectivity/inc/connectivity/dbtools.hxx
@@ -615,7 +615,7 @@ namespace dbtools
                             const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& _rxHandler,
                             const ::std::vector<bool, std::allocator<bool> >& _aParametersSet = ::std::vector<bool, std::allocator<bool> >());
 
-    /** call the appropiate set method for the specific sql type @see com::sun::star::sdbc::DataType
+    /** call the appropriate set method for the specific sql type @see com::sun::star::sdbc::DataType
         @param  _xParams        the parameters where to set the value
         @param  parameterIndex  the index of the parameter, 1 based
         @param  x               the value to set
@@ -629,7 +629,7 @@ namespace dbtools
                             sal_Int32 sqlType,
                             sal_Int32 scale=0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
 
-    /** call the appropiate set method for the specific sql type @see com::sun::star::sdbc::DataType
+    /** call the appropriate set method for the specific sql type @see com::sun::star::sdbc::DataType
         @param  _xParams        the parameters where to set the value
         @param  parameterIndex  the index of the parameter, 1 based
         @param  x               the value to set
diff --git a/dbaccess/source/core/api/RowSet.hxx b/dbaccess/source/core/api/RowSet.hxx
index 40e1920..42ca4b3 100644
--- a/dbaccess/source/core/api/RowSet.hxx
+++ b/dbaccess/source/core/api/RowSet.hxx
@@ -223,7 +223,7 @@ namespace dbaccess
         void checkUpdateIterator();
         const connectivity::ORowSetValue& getInsertValue(sal_Int32 columnIndex);
         void setParameter(sal_Int32 parameterIndex, const connectivity::ORowSetValue& x);
-        // resizes the parameter vector if nescessary
+        // resizes the parameter vector if necessary
         ::connectivity::ORowSetValue& getParameterStorage( sal_Int32 parameterIndex );
 
         void updateValue(sal_Int32 columnIndex,const connectivity::ORowSetValue& x);
commit 3623701d65f92017da905f4debf5514045f502c8
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Wed Jan 18 12:30:36 2012 +0100

    fdo#44813: make the refresh query filter NULL-safe

diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx
index 6024f3f..46444e9 100644
--- a/dbaccess/source/core/api/KeySet.cxx
+++ b/dbaccess/source/core/api/KeySet.cxx
@@ -223,22 +223,56 @@ void OKeySet::findTableColumnsMatching_throw(   const Any& i_aTable,
 }
 SAL_WNODEPRECATED_DECLARATIONS_POP
 
+namespace
+{
+    void appendOneKeyColumnClause( const ::rtl::OUString &tblName, const ::rtl::OUString &colName, ::rtl::OUStringBuffer &o_buf )
+    {
+        static ::rtl::OUString s_sDot(RTL_CONSTASCII_USTRINGPARAM("."));
+        static ::rtl::OUString s_sParam0(RTL_CONSTASCII_USTRINGPARAM(" ( TRUE = ? AND "));
+        static ::rtl::OUString s_sParam1(RTL_CONSTASCII_USTRINGPARAM(" = ? OR TRUE = ? AND "));
+        static ::rtl::OUString s_sParam2(RTL_CONSTASCII_USTRINGPARAM(" IS NULL ) "));
+        o_buf.append(s_sParam0);
+        o_buf.append(tblName);
+        o_buf.append(s_sDot);
+        o_buf.append(colName);
+        o_buf.append(s_sParam1);
+        o_buf.append(tblName);
+        o_buf.append(s_sDot);
+        o_buf.append(colName);
+        o_buf.append(s_sParam2);
+    }
+}
+
+void OKeySet::setOneKeyColumnParameter( sal_Int32 &nPos, const Reference< XParameters > &_xParameter, const connectivity::ORowSetValue &_rValue, sal_Int32 _nType, sal_Int32 _nScale ) const
+{
+    if ( _rValue.isNull() )
+    {
+        _xParameter->setBoolean( nPos++, false );
+        // We do the full call so that the right sqlType is passed to setNull
+        setParameter( nPos++, _xParameter, _rValue, _nType, _nScale );
+        _xParameter->setBoolean( nPos++, true );
+    }
+    else
+    {
+        _xParameter->setBoolean( nPos++, true );
+        setParameter( nPos++, _xParameter, _rValue, _nType, _nScale );
+        _xParameter->setBoolean( nPos++, false );
+    }
+}
+
 ::rtl::OUStringBuffer OKeySet::createKeyFilter()
 {
     static ::rtl::OUString aAnd(RTL_CONSTASCII_USTRINGPARAM(" AND "));
     const ::rtl::OUString aQuote    = getIdentifierQuoteString();
     ::rtl::OUStringBuffer aFilter;
-    static ::rtl::OUString s_sDot(RTL_CONSTASCII_USTRINGPARAM("."));
-    static ::rtl::OUString s_sParam(RTL_CONSTASCII_USTRINGPARAM(" = ?"));
     // create the where clause
     Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
     SelectColumnsMetaData::iterator aPosEnd = m_pKeyColumnNames->end();
     for(SelectColumnsMetaData::iterator aPosIter = m_pKeyColumnNames->begin();aPosIter != aPosEnd;)
     {
-        aFilter.append(::dbtools::quoteTableName( xMeta,aPosIter->second.sTableName,::dbtools::eInDataManipulation));
-        aFilter.append(s_sDot);
-        aFilter.append(::dbtools::quoteName( aQuote,aPosIter->second.sRealName));
-        aFilter.append(s_sParam);
+        appendOneKeyColumnClause(::dbtools::quoteTableName( xMeta,aPosIter->second.sTableName,::dbtools::eInDataManipulation),
+                                 ::dbtools::quoteName( aQuote,aPosIter->second.sRealName),
+                                 aFilter);
         ++aPosIter;
         if(aPosIter != aPosEnd)
             aFilter.append(aAnd);
@@ -276,8 +310,6 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet,const ::rtl::O
     {
         static ::rtl::OUString aAnd(RTL_CONSTASCII_USTRINGPARAM(" AND "));
         const ::rtl::OUString aQuote    = getIdentifierQuoteString();
-        static ::rtl::OUString s_sDot(RTL_CONSTASCII_USTRINGPARAM("."));
-        static ::rtl::OUString s_sParam(RTL_CONSTASCII_USTRINGPARAM(" = ?"));
         const ::rtl::OUString* pIter = aSeq.getConstArray();
         const ::rtl::OUString* pEnd   = pIter + aSeq.getLength();
         for(;pIter != pEnd;++pIter)
@@ -296,10 +328,9 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet,const ::rtl::O
                     // look for columns not in the source columns to use them as filter as well
                     if ( aFilter.getLength() )
                         aFilter.append(aAnd);
-                    aFilter.append(::dbtools::quoteName( aQuote,sSelectTableName));
-                    aFilter.append(s_sDot);
-                    aFilter.append(::dbtools::quoteName( aQuote,aPosIter->second.sRealName));
-                    aFilter.append(s_sParam);
+                    appendOneKeyColumnClause(::dbtools::quoteName( aQuote,sSelectTableName),
+                                             ::dbtools::quoteName( aQuote,aPosIter->second.sRealName),
+                                             aFilter);
                 }
                 break;
             }
@@ -879,12 +910,12 @@ void OKeySet::tryRefetch(const ORowSetRow& _rInsertRow,bool bRefetch)
             connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aIter2 = m_aKeyIter->second.first->get().begin();
             SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin();
             SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end();
-            for(;aPosIter != aPosEnd;++aPosIter,++aIter2,++nPos)
-                setParameter(nPos,xParameter,*aIter2,aPosIter->second.nType,aPosIter->second.nScale);
+            for(;aPosIter != aPosEnd;++aPosIter,++aIter2)
+                setOneKeyColumnParameter(nPos,xParameter,*aIter2,aPosIter->second.nType,aPosIter->second.nScale);
             aPosIter = (*m_pForeignColumnNames).begin();
             aPosEnd = (*m_pForeignColumnNames).end();
-            for(;aPosIter != aPosEnd;++aPosIter,++aIter2,++nPos)
-                setParameter(nPos,xParameter,*aIter2,aPosIter->second.nType,aPosIter->second.nScale);
+            for(;aPosIter != aPosEnd;++aPosIter,++aIter2)
+                setOneKeyColumnParameter(nPos,xParameter,*aIter2,aPosIter->second.nType,aPosIter->second.nScale);
 
             m_xSet = m_xStatement->executeQuery();
             OSL_ENSURE(m_xSet.is(),"No resultset form statement!");
@@ -1340,12 +1371,12 @@ void SAL_CALL OKeySet::refreshRow() throw(SQLException, RuntimeException)
     connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aIter = m_aKeyIter->second.first->get().begin();
     SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin();
     SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end();
-    for(;aPosIter != aPosEnd;++aPosIter,++aIter,++nPos)
-        setParameter(nPos,xParameter,*aIter,aPosIter->second.nType,aPosIter->second.nScale);
+    for(;aPosIter != aPosEnd;++aPosIter,++aIter)
+        setOneKeyColumnParameter(nPos,xParameter,*aIter,aPosIter->second.nType,aPosIter->second.nScale);
     aPosIter = (*m_pForeignColumnNames).begin();
     aPosEnd = (*m_pForeignColumnNames).end();
-    for(;aPosIter != aPosEnd;++aPosIter,++aIter,++nPos)
-        setParameter(nPos,xParameter,*aIter,aPosIter->second.nType,aPosIter->second.nScale);
+    for(;aPosIter != aPosEnd;++aPosIter,++aIter)
+        setOneKeyColumnParameter(nPos,xParameter,*aIter,aPosIter->second.nType,aPosIter->second.nScale);
 
     m_xSet = m_xStatement->executeQuery();
     OSL_ENSURE(m_xSet.is(),"No resultset form statement!");
diff --git a/dbaccess/source/core/api/KeySet.hxx b/dbaccess/source/core/api/KeySet.hxx
index 30afda2..196f159 100644
--- a/dbaccess/source/core/api/KeySet.hxx
+++ b/dbaccess/source/core/api/KeySet.hxx
@@ -143,6 +143,11 @@ namespace dbaccess
                                              const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& i_xQueryColumns,
                                              ::std::auto_ptr<SelectColumnsMetaData>& o_pKeyColumnNames);
         SAL_WNODEPRECATED_DECLARATIONS_POP
+        void setOneKeyColumnParameter( sal_Int32 &nPos,
+                                       const ::com::sun::star::uno::Reference<  ::com::sun::star::sdbc::XParameters > &_xParameter,
+                                       const connectivity::ORowSetValue &_rValue,
+                                       sal_Int32 _nType,
+                                       sal_Int32 _nScale ) const;
         ::rtl::OUStringBuffer createKeyFilter();
         void tryRefetch(const ORowSetRow& _rInsertRow,bool bRefetch);
         void executeUpdate(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOrginalRow,const ::rtl::OUString& i_sSQL,const ::rtl::OUString& i_sTableName,const ::std::vector<sal_Int32>& _aIndexColumnPositions = ::std::vector<sal_Int32>());


More information about the Libreoffice-commits mailing list