diff options
author | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2013-08-21 08:30:41 +0100 |
---|---|---|
committer | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2013-08-21 11:29:44 +0100 |
commit | 7358cf00822a916b1690ffd86822a28d3996e288 (patch) | |
tree | df4dc3327e5de83044ef9ac9483d2723e0a26dbb /connectivity/source/drivers/firebird/Keys.cxx | |
parent | a22f4351cc5db1be2278813aef78a7920452d2fe (diff) |
Add custom wrapper for OKeysHelper.firebird. (firebird-sdbc)
Keys are handled as a constraint in firebird so need different handling
when dropping to other dbs.
Change-Id: Ifc4929a1ee7477260b9a279487d44edbb525a17a
Diffstat (limited to 'connectivity/source/drivers/firebird/Keys.cxx')
-rw-r--r-- | connectivity/source/drivers/firebird/Keys.cxx | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/connectivity/source/drivers/firebird/Keys.cxx b/connectivity/source/drivers/firebird/Keys.cxx new file mode 100644 index 000000000000..c1874919e361 --- /dev/null +++ b/connectivity/source/drivers/firebird/Keys.cxx @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "Keys.hxx" +#include "Table.hxx" + +#include <connectivity/dbtools.hxx> + +using namespace ::connectivity; +using namespace ::connectivity::firebird; + +using namespace ::dbtools; +using namespace ::osl; + +using namespace ::com::sun::star; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::uno; + +Keys::Keys(Table* pTable, Mutex& rMutex, const TStringVector& rNames): + OKeysHelper(pTable, + rMutex, + rNames), + m_pTable(pTable) +{ +} + +//----- XDrop ---------------------------------------------------------------- +void Keys::dropObject(sal_Int32 nPosition, const OUString sName) +{ + Reference< XConnection> xConnection = m_pTable->getConnection(); + + if (!m_pTable->isNew()) + { + uno::Reference<XPropertySet> xKey(getObject(nPosition), UNO_QUERY); + + if (xKey.is()) + { + const OUString sQuote = m_pTable->getConnection()->getMetaData() + ->getIdentifierQuoteString(); + + OUString sSql("ALTER TABLE " + quoteName(sQuote, m_pTable->getName()) + + " DROP CONSTRAINT " + quoteName(sQuote, sName)); + + m_pTable->getConnection()->createStatement()->execute(sSql); + } + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file |