[Libreoffice-commits] core.git: dbaccess/source
Julien Nabet
serval2412 at yahoo.fr
Tue Apr 10 21:56:21 UTC 2018
dbaccess/source/core/api/preparedstatement.cxx | 7 +++++++
1 file changed, 7 insertions(+)
New commits:
commit dc823f5fa4a5d2eca56297b9045e5962536c00f9
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
Change-Id: I44f307cd6bddf76716d7c73b8783070abe43bdf3
Reviewed-on: https://gerrit.libreoffice.org/52662
Reviewed-by: Lionel Elie Mamane <lionel at mamane.lu>
Tested-by: Jenkins <ci at libreoffice.org>
diff --git a/dbaccess/source/core/api/preparedstatement.cxx b/dbaccess/source/core/api/preparedstatement.cxx
index 7080fe32b087..69e5138d689a 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>
@@ -158,6 +159,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.get(), aName );
+
m_pColumns->append(aName, pColumn);
}
}
More information about the Libreoffice-commits
mailing list