Kaydet (Commit) 90b09303 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Tunnel SQLException through getPropertyValue

Regression introduced with 03a2b4a8 "fdo#82151
when constructing column object, replace m_aCurrentRow by a function," where
the other call to m_pGetValue in ORowSetDataColumn::fireValueChange appears OK,
as ORowSetBase::firePropertyChange already wraps the fireValueChange calls in a
try--catch.

Change-Id: I527cc35ae120cf083f7c69a9a23526839a2bbddb
üst b6b77711
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "dbastrings.hrc" #include "dbastrings.hrc"
#include "apitools.hxx" #include "apitools.hxx"
#include <comphelper/types.hxx> #include <comphelper/types.hxx>
#include <cppuhelper/exc_hlp.hxx>
#include <cppuhelper/typeprovider.hxx> #include <cppuhelper/typeprovider.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp>
#include <tools/debug.hxx> #include <tools/debug.hxx>
...@@ -105,7 +106,17 @@ void SAL_CALL ORowSetDataColumn::getFastPropertyValue( Any& rValue, sal_Int32 nH ...@@ -105,7 +106,17 @@ void SAL_CALL ORowSetDataColumn::getFastPropertyValue( Any& rValue, sal_Int32 nH
{ {
if ( PROPERTY_ID_VALUE == nHandle ) if ( PROPERTY_ID_VALUE == nHandle )
{ {
rValue = m_pGetValue(m_nPos).makeAny(); try
{
rValue = m_pGetValue(m_nPos).makeAny();
}
catch (css::sdbc::SQLException & e)
{
css::uno::Any a(cppu::getCaughtException());
throw css::lang::WrappedTargetException(
"wrapped css::sdbc::SQLException: " + e.Message,
css::uno::Reference<css::uno::XInterface>(), a);
}
} }
else if ( PROPERTY_ID_LABEL == nHandle && !m_sLabel.isEmpty() ) else if ( PROPERTY_ID_LABEL == nHandle && !m_sLabel.isEmpty() )
rValue <<= m_sLabel; rValue <<= m_sLabel;
......
...@@ -1506,82 +1506,83 @@ void SAL_CALL OSingleSelectQueryComposer::setStructuredHavingClause( const Seque ...@@ -1506,82 +1506,83 @@ void SAL_CALL OSingleSelectQueryComposer::setStructuredHavingClause( const Seque
void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropertySet >& column, bool andCriteria ,::std::mem_fun1_t<bool,OSingleSelectQueryComposer,const OUString& >& _aSetFunctor,sal_Int32 filterOperator) void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropertySet >& column, bool andCriteria ,::std::mem_fun1_t<bool,OSingleSelectQueryComposer,const OUString& >& _aSetFunctor,sal_Int32 filterOperator)
{ {
::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed); try
{
if ( !column.is() ::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
|| !column->getPropertySetInfo()->hasPropertyByName(PROPERTY_VALUE)
|| !column->getPropertySetInfo()->hasPropertyByName(PROPERTY_NAME)
|| !column->getPropertySetInfo()->hasPropertyByName(PROPERTY_TYPE))
throw SQLException(DBACORE_RESSTRING(RID_STR_COLUMN_NOT_VALID),*this,SQLSTATE_GENERAL,1000,Any() );
sal_Int32 nType = 0; if ( !column.is()
column->getPropertyValue(PROPERTY_TYPE) >>= nType; || !column->getPropertySetInfo()->hasPropertyByName(PROPERTY_VALUE)
sal_Int32 nSearchable = dbtools::getSearchColumnFlag(m_xConnection,nType); || !column->getPropertySetInfo()->hasPropertyByName(PROPERTY_NAME)
if(nSearchable == ColumnSearch::NONE) || !column->getPropertySetInfo()->hasPropertyByName(PROPERTY_TYPE))
throw SQLException(DBACORE_RESSTRING(RID_STR_COLUMN_NOT_SEARCHABLE),*this,SQLSTATE_GENERAL,1000,Any() ); throw SQLException(DBACORE_RESSTRING(RID_STR_COLUMN_NOT_VALID),*this,SQLSTATE_GENERAL,1000,Any() );
::osl::MutexGuard aGuard( m_aMutex ); sal_Int32 nType = 0;
column->getPropertyValue(PROPERTY_TYPE) >>= nType;
sal_Int32 nSearchable = dbtools::getSearchColumnFlag(m_xConnection,nType);
if(nSearchable == ColumnSearch::NONE)
throw SQLException(DBACORE_RESSTRING(RID_STR_COLUMN_NOT_SEARCHABLE),*this,SQLSTATE_GENERAL,1000,Any() );
OUString aName; ::osl::MutexGuard aGuard( m_aMutex );
column->getPropertyValue(PROPERTY_NAME) >>= aName;
Any aValue; OUString aName;
column->getPropertyValue(PROPERTY_VALUE) >>= aValue; column->getPropertyValue(PROPERTY_NAME) >>= aName;
OUStringBuffer aSQL; Any aValue;
const OUString aQuote = m_xMetaData->getIdentifierQuoteString(); column->getPropertyValue(PROPERTY_VALUE) >>= aValue;
getColumns();
// TODO: if this is called for HAVING, check that the column is a GROUP BY column OUStringBuffer aSQL;
// or that it is an aggregate function const OUString aQuote = m_xMetaData->getIdentifierQuoteString();
getColumns();
if ( m_aCurrentColumns[SelectColumns] && m_aCurrentColumns[SelectColumns]->hasByName(aName) ) // TODO: if this is called for HAVING, check that the column is a GROUP BY column
{ // or that it is an aggregate function
Reference<XPropertySet> xColumn;
m_aCurrentColumns[SelectColumns]->getByName(aName) >>= xColumn;
OSL_ENSURE(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_REALNAME),"Property REALNAME not available!");
OSL_ENSURE(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_TABLENAME),"Property TABLENAME not available!");
OSL_ENSURE(xColumn->getPropertySetInfo()->hasPropertyByName("AggregateFunction"),"Property AggregateFunction not available!");
OUString sRealName,sTableName; if ( m_aCurrentColumns[SelectColumns] && m_aCurrentColumns[SelectColumns]->hasByName(aName) )
xColumn->getPropertyValue(PROPERTY_REALNAME) >>= sRealName;
xColumn->getPropertyValue(PROPERTY_TABLENAME) >>= sTableName;
if(sTableName.indexOf('.',0) != -1)
{ {
OUString aCatlog,aSchema,aTable; Reference<XPropertySet> xColumn;
::dbtools::qualifiedNameComponents(m_xMetaData,sTableName,aCatlog,aSchema,aTable,::dbtools::eInDataManipulation); m_aCurrentColumns[SelectColumns]->getByName(aName) >>= xColumn;
sTableName = ::dbtools::composeTableName( m_xMetaData, aCatlog, aSchema, aTable, true, ::dbtools::eInDataManipulation ); OSL_ENSURE(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_REALNAME),"Property REALNAME not available!");
} OSL_ENSURE(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_TABLENAME),"Property TABLENAME not available!");
else OSL_ENSURE(xColumn->getPropertySetInfo()->hasPropertyByName("AggregateFunction"),"Property AggregateFunction not available!");
sTableName = ::dbtools::quoteName(aQuote,sTableName);
OUString sRealName,sTableName;
xColumn->getPropertyValue(PROPERTY_REALNAME) >>= sRealName;
xColumn->getPropertyValue(PROPERTY_TABLENAME) >>= sTableName;
if(sTableName.indexOf('.',0) != -1)
{
OUString aCatlog,aSchema,aTable;
::dbtools::qualifiedNameComponents(m_xMetaData,sTableName,aCatlog,aSchema,aTable,::dbtools::eInDataManipulation);
sTableName = ::dbtools::composeTableName( m_xMetaData, aCatlog, aSchema, aTable, true, ::dbtools::eInDataManipulation );
}
else
sTableName = ::dbtools::quoteName(aQuote,sTableName);
if ( !::comphelper::getBOOL(xColumn->getPropertyValue("Function")) ) if ( !::comphelper::getBOOL(xColumn->getPropertyValue("Function")) )
{ {
aSQL = sTableName + "." + ::dbtools::quoteName( aQuote, sRealName ); aSQL = sTableName + "." + ::dbtools::quoteName( aQuote, sRealName );
}
else
aSQL = sRealName;
} }
else else
aSQL = sRealName;
}
else
{
aSQL = getTableAlias( column ) + ::dbtools::quoteName( aQuote, aName );
}
if ( aValue.hasValue() )
{
if( !m_xTypeConverter.is() )
m_xTypeConverter.set( Converter::create(m_aContext) );
OSL_ENSURE(m_xTypeConverter.is(),"NO typeconverter!");
if ( nType != DataType::BOOLEAN && DataType::BIT != nType )
{ {
OUString sEmpty; aSQL = getTableAlias( column ) + ::dbtools::quoteName( aQuote, aName );
lcl_addFilterCriteria_throw(filterOperator,sEmpty,aSQL);
} }
switch(nType) if ( aValue.hasValue() )
{ {
if( !m_xTypeConverter.is() )
m_xTypeConverter.set( Converter::create(m_aContext) );
OSL_ENSURE(m_xTypeConverter.is(),"NO typeconverter!");
if ( nType != DataType::BOOLEAN && DataType::BIT != nType )
{
OUString sEmpty;
lcl_addFilterCriteria_throw(filterOperator,sEmpty,aSQL);
}
switch(nType)
{
case DataType::VARCHAR: case DataType::VARCHAR:
case DataType::CHAR: case DataType::CHAR:
case DataType::LONGVARCHAR: case DataType::LONGVARCHAR:
...@@ -1642,31 +1643,44 @@ void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropert ...@@ -1642,31 +1643,44 @@ void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropert
default: default:
aSQL.append( DBTypeConversion::toSQLString( nType, aValue, true, m_xTypeConverter ) ); aSQL.append( DBTypeConversion::toSQLString( nType, aValue, true, m_xTypeConverter ) );
break; break;
}
}
else
{
sal_Int32 nFilterOp = filterOperator;
if ( filterOperator != SQLFilterOperator::SQLNULL && filterOperator != SQLFilterOperator::NOT_SQLNULL )
nFilterOp = SQLFilterOperator::SQLNULL;
OUString sEmpty;
lcl_addFilterCriteria_throw(nFilterOp,sEmpty,aSQL);
} }
}
else
{
sal_Int32 nFilterOp = filterOperator;
if ( filterOperator != SQLFilterOperator::SQLNULL && filterOperator != SQLFilterOperator::NOT_SQLNULL )
nFilterOp = SQLFilterOperator::SQLNULL;
OUString sEmpty;
lcl_addFilterCriteria_throw(nFilterOp,sEmpty,aSQL);
}
// Attach filter // Attach filter
// Construct SELECT without WHERE and ORDER BY // Construct SELECT without WHERE and ORDER BY
OUString sFilter = getFilter(); OUString sFilter = getFilter();
if ( !sFilter.isEmpty() && !aSQL.isEmpty() )
{
OUString sTemp(L_BRACKET + sFilter + R_BRACKET);
sTemp += andCriteria ? OUString(STR_AND) : OUString(STR_OR);
sFilter = sTemp;
}
sFilter += aSQL.makeStringAndClear();
if ( !sFilter.isEmpty() && !aSQL.isEmpty() ) // add the filter and the sort order
_aSetFunctor(this,sFilter);
}
catch (css::lang::WrappedTargetException & e)
{ {
OUString sTemp(L_BRACKET + sFilter + R_BRACKET); if (e.TargetException.isExtractableTo(
sTemp += andCriteria ? OUString(STR_AND) : OUString(STR_OR); cppu::UnoType<css::sdbc::SQLException>::get()))
sFilter = sTemp; {
cppu::throwException(e.TargetException);
}
else
{
throw e;
}
} }
sFilter += aSQL.makeStringAndClear();
// add the filter and the sort order
_aSetFunctor(this,sFilter);
} }
Sequence< Sequence< PropertyValue > > OSingleSelectQueryComposer::getStructuredCondition( TGetParseNode& _aGetFunctor ) Sequence< Sequence< PropertyValue > > OSingleSelectQueryComposer::getStructuredCondition( TGetParseNode& _aGetFunctor )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment