[Libreoffice-commits] core.git: connectivity/source
Andrzej J.R. Hunt
andrzej at ahunt.org
Mon Sep 9 03:05:06 PDT 2013
connectivity/source/drivers/firebird/ResultSet.cxx | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
New commits:
commit 8c204276a438c718bd2eed6c59189dcfb24032be
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date: Mon Sep 9 08:48:56 2013 +0100
Cleanup findColumn. (firebird-sdbc)
Change-Id: I0458892d9688a8618789652caf67251a61cc63aa
Reviewed-on: https://gerrit.libreoffice.org/5884
Reviewed-by: Andrzej J.R. Hunt <andrzej at ahunt.org>
Tested-by: Andrzej J.R. Hunt <andrzej at ahunt.org>
diff --git a/connectivity/source/drivers/firebird/ResultSet.cxx b/connectivity/source/drivers/firebird/ResultSet.cxx
index a33460b..113ba5f 100644
--- a/connectivity/source/drivers/firebird/ResultSet.cxx
+++ b/connectivity/source/drivers/firebird/ResultSet.cxx
@@ -311,7 +311,7 @@ Any SAL_CALL OResultSet::queryInterface( const Type & rType ) throw(RuntimeExcep
return concatSequences(OPropertySetHelper::getTypes(), OResultSet_BASE::getTypes());
}
// ---- XColumnLocate ---------------------------------------------------------
-sal_Int32 SAL_CALL OResultSet::findColumn(const OUString& columnName)
+sal_Int32 SAL_CALL OResultSet::findColumn(const OUString& rColumnName)
throw(SQLException, RuntimeException)
{
MutexGuard aGuard(m_pConnection->getMutex());
@@ -325,15 +325,19 @@ sal_Int32 SAL_CALL OResultSet::findColumn(const OUString& columnName)
{
// We assume case sensitive, otherwise you'd have to test
// xMeta->isCaseSensitive and use qualsIgnoreAsciiCase as needed.
- if (columnName == xMeta->getColumnName(i))
- break;
+ if (rColumnName == xMeta->getColumnName(i))
+ return i;
}
- // TODO: add appropriate error
- if (i > nLen)
- throw SQLException();
-
- return i;
+ // The API documentation (XRowLocate) doesn't specify what should happen
+ // if the column name isn't found. The JDBC api specifies that an SQLException
+ // should be thrown. Most drivers return either -1 (some don't check for this
+ // case and just return nLen), however the JDBC specification seems more
+ // correct (in the case of the JDBC/HSQLDB drivers the SQLException is
+ // just propagated from the JDBC call, hence should be expected by any
+ // SDBC user too).
+ ::dbtools::throwSQLException("Invalid column name", SQL_COLUMN_NOT_FOUND, *this);
+ return -1; // Never reached
}
// -------------------------------------------------------------------------
uno::Reference< XInputStream > SAL_CALL OResultSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
More information about the Libreoffice-commits
mailing list