diff options
author | Ocke Janssen [oj] <Ocke.Janssen@oracle.com> | 2011-01-10 14:23:31 +0100 |
---|---|---|
committer | Ocke Janssen [oj] <Ocke.Janssen@oracle.com> | 2011-01-10 14:23:31 +0100 |
commit | 5813b6702c7bb97e63bc6648a23942935eadda96 (patch) | |
tree | eed5aca64ddfb8f2e0f2d79fd75bcdde4ef8ad6d /dbaccess | |
parent | 8162ad59bec02814af20eb87131d46201f23d764 (diff) | |
parent | 897ade45672a36ffd278b1cb9ba21694c0ee45c7 (diff) |
Automated merge with ssh://hg.services.openoffice.org/cws/dba34c
Diffstat (limited to 'dbaccess')
-rwxr-xr-x | dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java | 84 | ||||
-rw-r--r-- | dbaccess/source/core/api/KeySet.cxx | 23 | ||||
-rw-r--r-- | dbaccess/source/core/api/KeySet.hxx | 4 | ||||
-rw-r--r-- | dbaccess/source/core/api/OptimisticSet.cxx | 5 | ||||
-rw-r--r-- | dbaccess/source/core/api/OptimisticSet.hxx | 3 | ||||
-rw-r--r-- | dbaccess/source/core/api/RowSetCache.cxx | 8 | ||||
-rw-r--r-- | dbaccess/source/core/api/SingleSelectQueryComposer.cxx | 28 | ||||
-rw-r--r-- | dbaccess/source/core/inc/SingleSelectQueryComposer.hxx | 30 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/unodatbr.cxx | 58 |
9 files changed, 124 insertions, 119 deletions
diff --git a/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java b/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java index 89d107ed5bb1..4823f5d50e4c 100755 --- a/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java +++ b/dbaccess/qa/complex/dbaccess/SingleSelectQueryComposer.java @@ -55,11 +55,12 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase { private XSingleSelectQueryComposer m_composer = null; - private final static String COMPLEXFILTER = "( \"ID\" = 1 AND \"Postal\" = '4' )" + - " OR ( \"ID\" = 2 AND \"Postal\" = '5' )" + - " OR ( \"ID\" = '3' AND \"Postal\" = '6' AND \"Address\" = '7' )" + - " OR ( \"Address\" = '8' )" + - " OR ( \"Postal\" = '9' )"; + private final static String COMPLEXFILTER = "( \"ID\" = 1 AND \"Postal\" = '4' )" + + " OR ( \"ID\" = 2 AND \"Postal\" = '5' )" + + " OR ( \"ID\" = 3 AND \"Postal\" = '6' AND \"Address\" = '7' )" + + " OR ( \"Address\" = '8' )" + + " OR ( \"Postal\" = '9' )" + + " OR ( NOW( ) = {D '2010-01-01' } )"; private final static String INNERPRODUCTSQUERY = "products (inner)"; // -------------------------------------------------------------------------------------------------------- @@ -135,15 +136,15 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase try { final String table = "SELECT * FROM \"customers\""; - m_composer.setCommand("customers",CommandType.TABLE); + m_composer.setCommand("customers", CommandType.TABLE); assertTrue("setCommand/getQuery TABLE inconsistent", m_composer.getQuery().equals(table)); m_database.getDatabase().getDataSource().createQuery("set command test", "SELECT * FROM \"orders for customer\" \"a\", \"customers\" \"b\" WHERE \"a\".\"Product Name\" = \"b\".\"Name\""); - m_composer.setCommand("set command test",CommandType.QUERY); + m_composer.setCommand("set command test", CommandType.QUERY); assertTrue("setCommand/getQuery QUERY inconsistent", m_composer.getQuery().equals(m_database.getDatabase().getDataSource().getQueryDefinition("set command test").getCommand())); final String sql = "SELECT * FROM \"orders for customer\" WHERE \"Product Name\" = 'test'"; - m_composer.setCommand(sql,CommandType.COMMAND); + m_composer.setCommand(sql, CommandType.COMMAND); assertTrue("setCommand/getQuery COMMAND inconsistent", m_composer.getQuery().equals(sql)); } catch (Exception e) @@ -151,6 +152,7 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase fail("Exception caught: " + e); } } + /** tests accessing attributes of the composer (order, filter, group by, having) */ @Test @@ -161,6 +163,7 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase try { System.out.println("check setElementaryQuery"); + final String simpleQuery2 = "SELECT * FROM \"customers\" WHERE \"Name\" = 'oranges'"; m_composer.setElementaryQuery(simpleQuery2); assertTrue("setElementaryQuery/getQuery inconsistent", m_composer.getQuery().equals(simpleQuery2)); @@ -177,16 +180,16 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase final XIndexAccess orderColumns = m_composer.getOrderColumns(); assertTrue("Order columns doesn't exist: \"Address\"", - orderColumns != null && orderColumns.getCount() == 1 && orderColumns.getByIndex(0) != null); + orderColumns != null && orderColumns.getCount() == 1 && orderColumns.getByIndex(0) != null); final XIndexAccess groupColumns = m_composer.getGroupColumns(); assertTrue("Group columns doesn't exist: \"City\"", - groupColumns != null && groupColumns.getCount() == 1 && groupColumns.getByIndex(0) != null); + groupColumns != null && groupColumns.getCount() == 1 && groupColumns.getByIndex(0) != null); // XColumnsSupplier final XColumnsSupplier xSelectColumns = UnoRuntime.queryInterface(XColumnsSupplier.class, m_composer); assertTrue("no select columns, or wrong number of select columns", - xSelectColumns != null && xSelectColumns.getColumns() != null && xSelectColumns.getColumns().getElementNames().length == 6); + xSelectColumns != null && xSelectColumns.getColumns() != null && xSelectColumns.getColumns().getElementNames().length == 6); // structured filter m_composer.setQuery("SELECT \"ID\", \"Postal\", \"Address\" FROM \"customers\""); @@ -194,6 +197,11 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase final PropertyValue[][] aStructuredFilter = m_composer.getStructuredFilter(); m_composer.setFilter(""); m_composer.setStructuredFilter(aStructuredFilter); + if (!m_composer.getFilter().equals(COMPLEXFILTER)) + { + System.out.println(COMPLEXFILTER); + System.out.println(m_composer.getFilter()); + } assertTrue("Structured Filter not identical", m_composer.getFilter().equals(COMPLEXFILTER)); // structured having clause @@ -244,6 +252,7 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase final XIndexAccess parameters = suppParams.getParameters(); final String expectedParamNames[] = + { "cname", "Product Name" @@ -276,6 +285,7 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase m_composer.setQuery("SELECT * FROM \"customers\""); final Object initArgs[] = + { new NamedValue("AutomaticAddition", Boolean.valueOf(true)) }; @@ -288,8 +298,8 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase filter.addProperty("Type", PropertyAttribute.MAYBEVOID, Integer.valueOf(DataType.LONGVARCHAR)); final XPropertySet column = UnoRuntime.queryInterface(XPropertySet.class, filter); - m_composer.appendFilterByColumn(column, true,SQLFilterOperator.LIKE); - assertTrue("At least one row should exist",m_database.getConnection().createStatement().executeQuery(m_composer.getQuery()).next()); + m_composer.appendFilterByColumn(column, true, SQLFilterOperator.LIKE); + assertTrue("At least one row should exist", m_database.getConnection().createStatement().executeQuery(m_composer.getQuery()).next()); } catch (Exception e) @@ -333,16 +343,16 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase { // a simple case: WHERE clause simply is a combination of predicates knitted with AND String query = - "SELECT \"customers\".\"Name\", " + - "\"customers\".\"Address\", " + - "\"customers\".\"City\", " + - "\"customers\".\"Postal\", " + - "\"products\".\"Name\" " + - "FROM \"orders\", \"customers\", \"orders_details\", \"products\" " + - "WHERE ( \"orders\".\"CustomerID\" = \"customers\".\"ID\" " + - "AND \"orders_details\".\"OrderID\" = \"orders\".\"ID\" " + - "AND \"orders_details\".\"ProductID\" = \"products\".\"ID\" " + - ") "; + "SELECT \"customers\".\"Name\", " + + "\"customers\".\"Address\", " + + "\"customers\".\"City\", " + + "\"customers\".\"Postal\", " + + "\"products\".\"Name\" " + + "FROM \"orders\", \"customers\", \"orders_details\", \"products\" " + + "WHERE ( \"orders\".\"CustomerID\" = \"customers\".\"ID\" " + + "AND \"orders_details\".\"OrderID\" = \"orders\".\"ID\" " + + "AND \"orders_details\".\"ProductID\" = \"products\".\"ID\" " + + ") "; impl_testDisjunctiveNormalForm(query, new PropertyValue[][] { @@ -356,20 +366,20 @@ public class SingleSelectQueryComposer extends CRMBasedTestCase // somewhat more challenging: One of the conjunction terms is a disjunction itself query = - "SELECT \"customers\".\"Name\", " + - "\"customers\".\"Address\", " + - "\"customers\".\"City\", " + - "\"customers\".\"Postal\", " + - "\"products\".\"Name\" " + - "FROM \"orders\", \"customers\", \"orders_details\", \"products\" " + - "WHERE ( \"orders\".\"CustomerID\" = \"customers\".\"ID\" " + - "AND \"orders_details\".\"OrderID\" = \"orders\".\"ID\" " + - "AND \"orders_details\".\"ProductID\" = \"products\".\"ID\" " + - ") " + - "AND " + - "( \"products\".\"Name\" = 'Apples' " + - "OR \"products\".\"ID\" = 2 " + - ")"; + "SELECT \"customers\".\"Name\", " + + "\"customers\".\"Address\", " + + "\"customers\".\"City\", " + + "\"customers\".\"Postal\", " + + "\"products\".\"Name\" " + + "FROM \"orders\", \"customers\", \"orders_details\", \"products\" " + + "WHERE ( \"orders\".\"CustomerID\" = \"customers\".\"ID\" " + + "AND \"orders_details\".\"OrderID\" = \"orders\".\"ID\" " + + "AND \"orders_details\".\"ProductID\" = \"products\".\"ID\" " + + ") " + + "AND " + + "( \"products\".\"Name\" = 'Apples' " + + "OR \"products\".\"ID\" = 2 " + + ")"; impl_testDisjunctiveNormalForm(query, new PropertyValue[][] { diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx index 932314b72fbe..21dc7d8443e6 100644 --- a/dbaccess/source/core/api/KeySet.cxx +++ b/dbaccess/source/core/api/KeySet.cxx @@ -154,7 +154,8 @@ OKeySet::OKeySet(const connectivity::OSQLTable& _xTable, const ::rtl::OUString& _rUpdateTableName, // this can be the alias or the full qualified name const Reference< XSingleSelectQueryAnalyzer >& _xComposer, const ORowSetValueVector& _aParameterValueForCache, - sal_Int32 i_nMaxRows) + sal_Int32 i_nMaxRows, + sal_Int32& o_nRowCount) :OCacheSet(i_nMaxRows) ,m_aParameterValueForCache(_aParameterValueForCache) ,m_pKeyColumnNames(NULL) @@ -165,6 +166,7 @@ OKeySet::OKeySet(const connectivity::OSQLTable& _xTable, ,m_xTableKeys(_xTableKeys) ,m_xComposer(_xComposer) ,m_sUpdateTableName(_rUpdateTableName) + ,m_rRowCount(o_nRowCount) ,m_bRowCountFinal(sal_False) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::OKeySet" ); @@ -1239,8 +1241,8 @@ sal_Bool SAL_CALL OKeySet::first( ) throw(SQLException, RuntimeException) ++m_aKeyIter; if(m_aKeyIter == m_aKeyMap.end() && !fetchRow()) m_aKeyIter = m_aKeyMap.end(); - - refreshRow(); + else + refreshRow(); return m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin(); } // ----------------------------------------------------------------------------- @@ -1403,9 +1405,18 @@ void SAL_CALL OKeySet::refreshRow() throw(SQLException, RuntimeException) OSL_ENSURE(m_xSet.is(),"No resultset form statement!"); sal_Bool bOK = m_xSet->next(); if ( !bOK ) - m_aKeyIter = m_aKeyMap.end(); - m_xRow.set(m_xSet,UNO_QUERY); - OSL_ENSURE(m_xRow.is(),"No row form statement!"); + { + OKeySetMatrix::iterator aTemp = m_aKeyIter; + ++m_aKeyIter; + m_aKeyMap.erase(aTemp); + --m_rRowCount; + refreshRow(); + } + else + { + m_xRow.set(m_xSet,UNO_QUERY); + OSL_ENSURE(m_xRow.is(),"No row form statement!"); + } } // ----------------------------------------------------------------------------- sal_Bool OKeySet::fetchRow() diff --git a/dbaccess/source/core/api/KeySet.hxx b/dbaccess/source/core/api/KeySet.hxx index c002288bd9de..2f9d1b002cb1 100644 --- a/dbaccess/source/core/api/KeySet.hxx +++ b/dbaccess/source/core/api/KeySet.hxx @@ -113,6 +113,7 @@ namespace dbaccess ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryAnalyzer > m_xComposer; ::rtl::OUString m_sUpdateTableName; ::std::vector< ::rtl::OUString > m_aFilterColumns; + sal_Int32& m_rRowCount; sal_Bool m_bRowCountFinal; @@ -160,7 +161,8 @@ namespace dbaccess const ::rtl::OUString& _rUpdateTableName, const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryAnalyzer >& _xComposer, const ORowSetValueVector& _aParameterValueForCache, - sal_Int32 i_nMaxRows); + sal_Int32 i_nMaxRows, + sal_Int32& o_nRowCount); // late ctor which can throw exceptions virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter); diff --git a/dbaccess/source/core/api/OptimisticSet.cxx b/dbaccess/source/core/api/OptimisticSet.cxx index d984ca2c78c6..2637a4f6bea6 100644 --- a/dbaccess/source/core/api/OptimisticSet.cxx +++ b/dbaccess/source/core/api/OptimisticSet.cxx @@ -103,8 +103,9 @@ OptimisticSet::OptimisticSet(const ::comphelper::ComponentContext& _rContext, const Reference< XConnection>& i_xConnection, const Reference< XSingleSelectQueryAnalyzer >& _xComposer, const ORowSetValueVector& _aParameterValueForCache, - sal_Int32 i_nMaxRows) - :OKeySet(NULL,NULL,::rtl::OUString(),_xComposer,_aParameterValueForCache,i_nMaxRows) + sal_Int32 i_nMaxRows, + sal_Int32& o_nRowCount) + :OKeySet(NULL,NULL,::rtl::OUString(),_xComposer,_aParameterValueForCache,i_nMaxRows,o_nRowCount) ,m_aSqlParser( _rContext.getLegacyServiceFactory() ) ,m_aSqlIterator( i_xConnection, Reference<XTablesSupplier>(_xComposer,UNO_QUERY)->getTables(), m_aSqlParser, NULL ) ,m_bResultSetChanged(false) diff --git a/dbaccess/source/core/api/OptimisticSet.hxx b/dbaccess/source/core/api/OptimisticSet.hxx index da73eaeee8c5..f3b75e08ed5b 100644 --- a/dbaccess/source/core/api/OptimisticSet.hxx +++ b/dbaccess/source/core/api/OptimisticSet.hxx @@ -80,7 +80,8 @@ namespace dbaccess const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& i_xConnection, const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryAnalyzer >& _xComposer, const ORowSetValueVector& _aParameterValueForCache, - sal_Int32 i_nMaxRows); + sal_Int32 i_nMaxRows, + sal_Int32& o_nRowCount); // late ctor which can throw exceptions virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter); diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx index 1380c436ff0e..789fbadb794b 100644 --- a/dbaccess/source/core/api/RowSetCache.cxx +++ b/dbaccess/source/core/api/RowSetCache.cxx @@ -176,7 +176,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, if ( aTableNames.getLength() > 1 && !_rUpdateTableName.getLength() && bNeedKeySet ) {// here we have a join or union and nobody told us which table to update, so we update them all m_nPrivileges = Privilege::SELECT|Privilege::DELETE|Privilege::INSERT|Privilege::UPDATE; - OptimisticSet* pCursor = new OptimisticSet(m_aContext,xConnection,_xAnalyzer,_aParameterValueForCache,i_nMaxRows); + OptimisticSet* pCursor = new OptimisticSet(m_aContext,xConnection,_xAnalyzer,_aParameterValueForCache,i_nMaxRows,m_nRowCount); m_pCacheSet = pCursor; m_xCacheSet = m_pCacheSet; try @@ -309,7 +309,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, } } - OKeySet* pKeySet = new OKeySet(m_aUpdateTable,xUpdateTableKeys,aUpdateTableName ,_xAnalyzer,_aParameterValueForCache,i_nMaxRows); + OKeySet* pKeySet = new OKeySet(m_aUpdateTable,xUpdateTableKeys,aUpdateTableName ,_xAnalyzer,_aParameterValueForCache,i_nMaxRows,m_nRowCount); try { m_pCacheSet = pKeySet; @@ -825,7 +825,6 @@ sal_Bool ORowSetCache::moveWindow() if ( nNewStartPos < 1 ) { bCheck = m_pCacheSet->first(); - // aEnd = m_pMatrix->begin() + (sal_Int32)(m_nFetchSize*0.5); OSL_ENSURE((nNewEndPos - m_nStartPos - nNewStartPos) < (sal_Int32)m_pMatrix->size(),"Position is behind end()!"); aEnd = m_pMatrix->begin() + (nNewEndPos - m_nStartPos - nNewStartPos); aIter = aEnd; @@ -958,9 +957,6 @@ sal_Bool ORowSetCache::moveWindow() sal_Bool bCheck = m_pCacheSet->absolute(nPos); bCheck = fill(aIter,aEnd,nPos,bCheck); // refill the region wew don't need anymore -// // we know that this is the current maximal rowcount here -// if ( !m_bRowCountFinal && bCheck ) -// m_nRowCount = std::max(nPos,m_nRowCount); // we have to read one row forward to enshure that we know when we are on last row // but only when we don't know it already sal_Bool bOk = sal_True; diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx index fa67a3d8cfdb..f3b40ffe968e 100644 --- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx +++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx @@ -58,6 +58,7 @@ #include <comphelper/sequence.hxx> #include <comphelper/types.hxx> #include <cppuhelper/typeprovider.hxx> +#include <connectivity/predicateinput.hxx> #include <rtl/logfile.hxx> #include <unotools/syslocale.hxx> #include <tools/debug.hxx> @@ -1243,16 +1244,12 @@ sal_Bool OSingleSelectQueryComposer::setComparsionPredicate(OSQLParseNode * pCon ::rtl::OUString aValue; ::rtl::OUString aColumnName; - pCondition->parseNodeToPredicateStr(aValue, m_xConnection, xFormatter, m_aLocale, static_cast<sal_Char>( m_sDecimalSep.toChar() ) ); + pCondition->getChild(2)->parseNodeToPredicateStr(aValue, m_xConnection, xFormatter, m_aLocale, static_cast<sal_Char>( m_sDecimalSep.toChar() ) ); pCondition->getChild(0)->parseNodeToPredicateStr( aColumnName, m_xConnection, xFormatter, m_aLocale, static_cast<sal_Char>( m_sDecimalSep .toChar() ) ); - // don't display the column name - aValue = aValue.copy(aColumnName.getLength()); - aValue.trim(); - aItem.Name = getColumnName(pCondition->getChild(0),_rIterator); aItem.Value <<= aValue; - aItem.Handle = pCondition->getNodeType(); + aItem.Handle = getPredicateType(pCondition->getChild(1)); rFilter.push_back(aItem); } else // kann sich nur um einen Expr. Ausdruck handeln @@ -1269,7 +1266,7 @@ sal_Bool OSingleSelectQueryComposer::setComparsionPredicate(OSQLParseNode * pCon pLhs->getChild(i)->parseNodeToPredicateStr( aName, m_xConnection, xFormatter, m_aLocale, static_cast<sal_Char>( m_sDecimalSep.toChar() ) ); // Kriterium - aItem.Handle = pCondition->getChild(1)->getNodeType(); + aItem.Handle = getPredicateType(pCondition->getChild(1)); aValue = pCondition->getChild(1)->getTokenValue(); for(i=0;i< pRhs->count();i++) pRhs->getChild(i)->parseNodeToPredicateStr(aValue, m_xConnection, xFormatter, m_aLocale, static_cast<sal_Char>( m_sDecimalSep.toChar() ) ); @@ -1514,7 +1511,7 @@ Reference< XIndexAccess > SAL_CALL OSingleSelectQueryComposer::getOrderColumns( // ----------------------------------------------------------------------------- namespace { - ::rtl::OUString lcl_getCondition(const Sequence< Sequence< PropertyValue > >& filter ) + ::rtl::OUString lcl_getCondition(const Sequence< Sequence< PropertyValue > >& filter,const OPredicateInputController& i_aPredicateInputController,const Reference< XNameAccess >& i_xSelectColumns) { ::rtl::OUStringBuffer sRet; const Sequence< PropertyValue >* pOrIter = filter.getConstArray(); @@ -1531,6 +1528,15 @@ namespace sRet.append(pAndIter->Name); ::rtl::OUString sValue; pAndIter->Value >>= sValue; + if ( i_xSelectColumns.is() && i_xSelectColumns->hasByName(pAndIter->Name) ) + { + Reference<XPropertySet> xColumn(i_xSelectColumns->getByName(pAndIter->Name),UNO_QUERY); + sValue = i_aPredicateInputController.getPredicateValue(sValue,xColumn,sal_True); + } + else + { + sValue = i_aPredicateInputController.getPredicateValue(pAndIter->Name,sValue,sal_True); + } lcl_addFilterCriteria_throw(pAndIter->Handle,sValue,sRet); ++pAndIter; if ( pAndIter != pAndEnd ) @@ -1549,13 +1555,15 @@ namespace void SAL_CALL OSingleSelectQueryComposer::setStructuredFilter( const Sequence< Sequence< PropertyValue > >& filter ) throw (SQLException, ::com::sun::star::lang::IllegalArgumentException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::setStructuredFilter" ); - setFilter(lcl_getCondition(filter)); + OPredicateInputController aPredicateInput(m_aContext.getLegacyServiceFactory(),m_xConnection); + setFilter(lcl_getCondition(filter,aPredicateInput,getColumns())); } // ----------------------------------------------------------------------------- void SAL_CALL OSingleSelectQueryComposer::setStructuredHavingClause( const Sequence< Sequence< PropertyValue > >& filter ) throw (SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OSingleSelectQueryComposer::setStructuredHavingClause" ); - setHavingClause(lcl_getCondition(filter)); + OPredicateInputController aPredicateInput(m_aContext.getLegacyServiceFactory(),m_xConnection); + setHavingClause(lcl_getCondition(filter,aPredicateInput,getColumns())); } // ----------------------------------------------------------------------------- void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropertySet >& column, sal_Bool andCriteria ,::std::mem_fun1_t<bool,OSingleSelectQueryComposer,::rtl::OUString>& _aSetFunctor,sal_Int32 filterOperator) diff --git a/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx b/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx index 7c0d2ba4cea3..412fbb1c5231 100644 --- a/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx +++ b/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx @@ -27,51 +27,21 @@ #ifndef DBACCESS_CORE_API_SINGLESELECTQUERYCOMPOSER_HXX #define DBACCESS_CORE_API_SINGLESELECTQUERYCOMPOSER_HXX -#ifndef _COM_SUN_STAR_SDB_XPARAMETERSSUPPLIER_HPP_ #include <com/sun/star/sdb/XParametersSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XTablesSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYCOMPOSER_HPP_ #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp> -#endif -#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ #include <com/sun/star/lang/XServiceInfo.hpp> -#endif -#ifndef _COM_SUN_STAR_SCRIPT_XTYPECONVERTER_HPP_ #include <com/sun/star/script/XTypeConverter.hpp> -#endif -#ifndef _CPPUHELPER_IMPLBASE5_HXX_ #include <cppuhelper/implbase5.hxx> -#endif -#ifndef _CONNECTIVITY_PARSE_SQLITERATOR_HXX_ #include <connectivity/sqliterator.hxx> -#endif -#ifndef _CONNECTIVITY_SQLPARSE_HXX #include <connectivity/sqlparse.hxx> -#endif -#ifndef _DBASHARED_APITOOLS_HXX_ #include "apitools.hxx" -#endif -#ifndef _COMPHELPER_BROADCASTHELPER_HXX_ #include <comphelper/broadcasthelper.hxx> -#endif -#ifndef _COMPHELPER_UNO3_HXX_ #include <comphelper/uno3.hxx> -#endif -#ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_ #include <comphelper/proparrhlp.hxx> -#endif -#ifndef _COMPHELPER_PROPERTYCONTAINER_HXX_ #include <comphelper/propertycontainer.hxx> -#endif -#ifndef COMPHELPER_COMPONENTCONTEXT_HXX #include <comphelper/componentcontext.hxx> -#endif #include <memory> diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx index d15fb125f234..85312df66684 100644 --- a/dbaccess/source/ui/browser/unodatbr.cxx +++ b/dbaccess/source/ui/browser/unodatbr.cxx @@ -469,7 +469,7 @@ void SbaTableQueryBrowser::impl_sanitizeRowSetClauses_nothrow() // check if the order columns apply to tables which really exist in the statement const Reference< XIndexAccess > xOrderColumns( xComposer->getOrderColumns(), UNO_SET_THROW ); const sal_Int32 nOrderColumns( xOrderColumns->getCount() ); - bool invalidColumn = false; + bool invalidColumn = nOrderColumns == 0; for ( sal_Int32 c=0; ( c < nOrderColumns ) && !invalidColumn; ++c ) { const Reference< XPropertySet > xOrderColumn( xOrderColumns->getByIndex(c), UNO_QUERY_THROW ); @@ -2701,6 +2701,8 @@ bool SbaTableQueryBrowser::implSelect( SvLBoxEntry* _pEntry ) sStatus.SearchAndReplaceAscii("$name$", aName); BrowserViewStatusDisplay aShowStatus(static_cast<UnoDataBrowserView*>(getView()), sStatus); + + sal_Bool bEscapeProcessing = sal_True; if(xNameAccess.is() && xNameAccess->hasByName(sSimpleName)) { DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(_pEntry->GetUserData()); @@ -2711,38 +2713,42 @@ bool SbaTableQueryBrowser::implSelect( SvLBoxEntry* _pEntry ) { pData->xObjectProperties = pData->xObjectProperties.query( xObject ); // if the query contains a parameterized statement and preview is enabled we won't get any data. - if ( m_bPreview && nCommandType == CommandType::QUERY && xObject.is() ) + if ( nCommandType == CommandType::QUERY && xObject.is() ) { - ::rtl::OUString sSql; Reference<XPropertySet> xObjectProps(xObject,UNO_QUERY); - xObjectProps->getPropertyValue(PROPERTY_COMMAND) >>= sSql; - Reference< XMultiServiceFactory > xFactory( pConData->xConnection, UNO_QUERY ); - if (xFactory.is()) + xObjectProps->getPropertyValue(PROPERTY_ESCAPE_PROCESSING) >>= bEscapeProcessing; + if ( m_bPreview ) { - try + ::rtl::OUString sSql; + xObjectProps->getPropertyValue(PROPERTY_COMMAND) >>= sSql; + Reference< XMultiServiceFactory > xFactory( pConData->xConnection, UNO_QUERY ); + if (xFactory.is()) { - Reference<XSingleSelectQueryAnalyzer> xAnalyzer(xFactory->createInstance(SERVICE_NAME_SINGLESELECTQUERYCOMPOSER),UNO_QUERY); - if ( xAnalyzer.is() ) + try { - xAnalyzer->setQuery(sSql); - Reference<XParametersSupplier> xParSup(xAnalyzer,UNO_QUERY); - if ( xParSup->getParameters()->getCount() > 0 ) + Reference<XSingleSelectQueryAnalyzer> xAnalyzer(xFactory->createInstance(SERVICE_NAME_SINGLESELECTQUERYCOMPOSER),UNO_QUERY); + if ( xAnalyzer.is() ) { - String sFilter = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" WHERE ")); - sFilter = sFilter + xAnalyzer->getFilter(); - String sReplace(sSql); - sReplace.SearchAndReplace(sFilter,String()); - xAnalyzer->setQuery(sReplace); - Reference<XSingleSelectQueryComposer> xComposer(xAnalyzer,UNO_QUERY); - xComposer->setFilter(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0=1"))); - aName = xAnalyzer->getQuery(); - nCommandType = CommandType::COMMAND; + xAnalyzer->setQuery(sSql); + Reference<XParametersSupplier> xParSup(xAnalyzer,UNO_QUERY); + if ( xParSup->getParameters()->getCount() > 0 ) + { + String sFilter = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" WHERE ")); + sFilter = sFilter + xAnalyzer->getFilter(); + String sReplace(sSql); + sReplace.SearchAndReplace(sFilter,String()); + xAnalyzer->setQuery(sReplace); + Reference<XSingleSelectQueryComposer> xComposer(xAnalyzer,UNO_QUERY); + xComposer->setFilter(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0=1"))); + aName = xAnalyzer->getQuery(); + nCommandType = CommandType::COMMAND; + } } } - } - catch (Exception&) - { - DBG_UNHANDLED_EXCEPTION(); + catch (Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } } } } @@ -2751,7 +2757,7 @@ bool SbaTableQueryBrowser::implSelect( SvLBoxEntry* _pEntry ) } String sDataSourceName( getDataSourceAcessor( pConnection ) ); - bSuccess = implLoadAnything( sDataSourceName, aName, nCommandType, sal_True, pConData->xConnection ); + bSuccess = implLoadAnything( sDataSourceName, aName, nCommandType, bEscapeProcessing, pConData->xConnection ); if ( !bSuccess ) { // clean up criticalFail(); |