[Libreoffice-commits] core.git: Branch 'libreoffice-6-0' - dbaccess/source

Julien Nabet serval2412 at yahoo.fr
Wed Apr 11 08:54:44 UTC 2018


 dbaccess/source/core/api/preparedstatement.cxx |    7 +++++++
 1 file changed, 7 insertions(+)

New commits:
commit 0d78d17249a58d95b4aa2e8fe09f08e22f20c407
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Tue Apr 10 07:30:38 2018 +0200

    tdf#116890: make unique column names in prepared statement
    
    ...like we do resultset.
    
    Thanks to Lionel for this solution
    
    Reviewed-on: https://gerrit.libreoffice.org/52662
    (cherry picked from commit dc823f5fa4a5d2eca56297b9045e5962536c00f9)
    
    Change-Id: I44f307cd6bddf76716d7c73b8783070abe43bdf3
    Reviewed-on: https://gerrit.libreoffice.org/52698
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Lionel Elie Mamane <lionel at mamane.lu>

diff --git a/dbaccess/source/core/api/preparedstatement.cxx b/dbaccess/source/core/api/preparedstatement.cxx
index 74a8edbf1cd8..3eeb339a5a4c 100644
--- a/dbaccess/source/core/api/preparedstatement.cxx
+++ b/dbaccess/source/core/api/preparedstatement.cxx
@@ -26,6 +26,7 @@
 
 #include <comphelper/property.hxx>
 #include <comphelper/sequence.hxx>
+#include <connectivity/dbtools.hxx>
 #include <cppuhelper/supportsservice.hxx>
 #include <cppuhelper/queryinterface.hxx>
 #include <cppuhelper/typeprovider.hxx>
@@ -160,6 +161,12 @@ Reference< css::container::XNameAccess > OPreparedStatement::getColumns()
                 // retrieve the name of the column
                 OUString aName = xMetaData->getColumnName(i + 1);
                 OResultColumn* pColumn = new OResultColumn(xMetaData, i + 1, xDBMeta);
+                // don't silently assume that the name is unique - preparedStatement implementations
+                // are allowed to return duplicate names, but we are required to have
+                // unique column names
+                if ( m_pColumns->hasByName( aName ) )
+                    aName = ::dbtools::createUniqueName( m_pColumns, aName );
+
                 m_pColumns->append(aName, pColumn);
             }
         }


More information about the Libreoffice-commits mailing list