diff options
author | Lionel Elie Mamane <lionel@mamane.lu> | 2012-12-02 18:32:38 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-12-03 12:50:16 +0000 |
commit | 1cac399e063827349c340cafdec8dc0756f90f1b (patch) | |
tree | 7584daff0b6037e0273443f16bf46a55a75f30bb | |
parent | a0926265dbfc617603cfa1fb8a4a22a5663183fe (diff) |
fdo#42165 make nested joins as per strict ANSI SQL
Change-Id: I605d3811b27c33e35670306bb03b5a796ab72bc0
Reviewed-on: https://gerrit.libreoffice.org/1225
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | dbaccess/source/ui/inc/TableConnectionData.hxx | 3 | ||||
-rw-r--r-- | dbaccess/source/ui/querydesign/QueryDesignView.cxx | 45 |
2 files changed, 34 insertions, 14 deletions
diff --git a/dbaccess/source/ui/inc/TableConnectionData.hxx b/dbaccess/source/ui/inc/TableConnectionData.hxx index 79ccd802d564..291529fe41e3 100644 --- a/dbaccess/source/ui/inc/TableConnectionData.hxx +++ b/dbaccess/source/ui/inc/TableConnectionData.hxx @@ -87,7 +87,8 @@ namespace dbaui void normalizeLines(); // loescht die Liste der ConnLines, bei bUseDefaults == sal_True werden danach MAX_CONN_COUNT neue Dummy-Linien eingefuegt - 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 6b91252feb56..7b33375ae9b7 100644 --- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx +++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx @@ -299,14 +299,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(); @@ -401,7 +401,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); @@ -439,9 +439,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(); @@ -450,20 +450,39 @@ 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; + default: + // the other join types are symmetric, so nothing to change + break; + } + return BuildJoin(_xConnection, rRh, BuildTable(_xConnection,pLh), &data); } //------------------------------------------------------------------------------ void GetNextJoin( const Reference< XConnection>& _xConnection, |