diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2018-04-10 07:30:38 +0200 |
---|---|---|
committer | Lionel Elie Mamane <lionel@mamane.lu> | 2018-04-11 10:54:23 +0200 |
commit | 0d78d17249a58d95b4aa2e8fe09f08e22f20c407 (patch) | |
tree | 4324d98ea96bcad0f6caa1bb8f29061d24f6c642 | |
parent | 060e43da66c759de2c4799131e13c5156f01d492 (diff) |
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@libreoffice.org>
Reviewed-by: Lionel Elie Mamane <lionel@mamane.lu>
-rw-r--r-- | dbaccess/source/core/api/preparedstatement.cxx | 7 |
1 files changed, 7 insertions, 0 deletions
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); } } |