summaryrefslogtreecommitdiff
path: root/dbaccess
diff options
context:
space:
mode:
authorLionel Elie Mamane <lionel@mamane.lu>2012-12-02 18:32:38 +0100
committerLionel Elie Mamane <lionel@mamane.lu>2012-12-02 18:34:33 +0100
commitc25bb400bbfe20b3b13237ed10935ec9d0f6d769 (patch)
tree7d38bf0caddc16363b669b1285b7a1dac2469218 /dbaccess
parentb245079a50c94dc503628619f6342b70dcdc6e66 (diff)
fdo#42165 make nested joins as per strict ANSI SQL
Change-Id: I605d3811b27c33e35670306bb03b5a796ab72bc0
Diffstat (limited to 'dbaccess')
-rw-r--r--dbaccess/source/ui/inc/TableConnectionData.hxx3
-rw-r--r--dbaccess/source/ui/querydesign/QueryDesignView.cxx42
2 files changed, 31 insertions, 14 deletions
diff --git a/dbaccess/source/ui/inc/TableConnectionData.hxx b/dbaccess/source/ui/inc/TableConnectionData.hxx
index bc084dba4373..728978da8b79 100644
--- a/dbaccess/source/ui/inc/TableConnectionData.hxx
+++ b/dbaccess/source/ui/inc/TableConnectionData.hxx
@@ -81,7 +81,8 @@ namespace dbaui
*/
void normalizeLines();
- OConnectionLineDataVec* GetConnLineDataList(){ return &m_vConnLineData; }
+ const OConnectionLineDataVec* GetConnLineDataList() const { return &m_vConnLineData; }
+ OConnectionLineDataVec* GetConnLineDataList() { return &m_vConnLineData; }
inline TTableWindowData::value_type getReferencingTable() const { return m_pReferencingTable; }
inline TTableWindowData::value_type getReferencedTable() const { return m_pReferencedTable; }
diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
index e81da08dfad4..8ba3912444f1 100644
--- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx
+++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
@@ -290,14 +290,14 @@ namespace
}
//------------------------------------------------------------------------------
::rtl::OUString BuildJoinCriteria( const Reference< XConnection>& _xConnection,
- OConnectionLineDataVec* pLineDataList,
- OQueryTableConnectionData* pData)
+ const OConnectionLineDataVec* pLineDataList,
+ const OQueryTableConnectionData* pData)
{
::rtl::OUStringBuffer aCondition;
if ( _xConnection.is() )
{
- OConnectionLineDataVec::iterator aIter = pLineDataList->begin();
- OConnectionLineDataVec::iterator aEnd = pLineDataList->end();
+ OConnectionLineDataVec::const_iterator aIter = pLineDataList->begin();
+ OConnectionLineDataVec::const_iterator aEnd = pLineDataList->end();
try
{
const Reference< XDatabaseMetaData > xMetaData = _xConnection->getMetaData();
@@ -392,7 +392,7 @@ namespace
::rtl::OUString BuildJoin( const Reference< XConnection>& _xConnection,
const ::rtl::OUString& rLh,
const ::rtl::OUString& rRh,
- OQueryTableConnectionData* pData)
+ const OQueryTableConnectionData* pData)
{
String aErg(rLh);
@@ -430,9 +430,9 @@ namespace
}
//------------------------------------------------------------------------------
::rtl::OUString BuildJoin( const Reference< XConnection>& _xConnection,
- OQueryTableWindow* pLh,
- OQueryTableWindow* pRh,
- OQueryTableConnectionData* pData
+ const OQueryTableWindow* pLh,
+ const OQueryTableWindow* pRh,
+ const OQueryTableConnectionData* pData
)
{
bool bForce = pData->GetJoinType() == CROSS_JOIN || pData->isNatural();
@@ -441,20 +441,36 @@ namespace
//------------------------------------------------------------------------------
::rtl::OUString BuildJoin( const Reference< XConnection>& _xConnection,
const ::rtl::OUString &rLh,
- OQueryTableWindow* pRh,
- OQueryTableConnectionData* pData
+ const OQueryTableWindow* pRh,
+ const OQueryTableConnectionData* pData
)
{
return BuildJoin(_xConnection,rLh,BuildTable(_xConnection,pRh),pData);
}
//------------------------------------------------------------------------------
::rtl::OUString BuildJoin( const Reference< XConnection>& _xConnection,
- OQueryTableWindow* pLh,
+ const OQueryTableWindow* pLh,
const ::rtl::OUString &rRh,
- OQueryTableConnectionData* pData
+ const OQueryTableConnectionData* pData
)
{
- return BuildJoin(_xConnection,BuildTable(_xConnection,pLh),rRh,pData);
+ // strict ANSI SQL:
+ // - does not support any bracketing of JOINS
+ // - supports nested joins only in the LEFT HAND SIDE
+ // In this case, we are trying to build a join with a nested join
+ // in the right hand side.
+ // So switch the direction of the join and both hand sides.
+ OQueryTableConnectionData data(*pData);
+ switch (data.GetJoinType())
+ {
+ case LEFT_JOIN:
+ data.SetJoinType(RIGHT_JOIN);
+ break;
+ case RIGHT_JOIN:
+ data.SetJoinType(LEFT_JOIN);
+ break;
+ }
+ return BuildJoin(_xConnection, rRh, BuildTable(_xConnection,pLh), &data);
}
//------------------------------------------------------------------------------
void GetNextJoin( const Reference< XConnection>& _xConnection,