summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrzej J.R. Hunt <andrzej@ahunt.org>2013-08-21 08:30:41 +0100
committerAndrzej J.R. Hunt <andrzej@ahunt.org>2013-08-21 11:29:44 +0100
commit7358cf00822a916b1690ffd86822a28d3996e288 (patch)
treedf4dc3327e5de83044ef9ac9483d2723e0a26dbb
parenta22f4351cc5db1be2278813aef78a7920452d2fe (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
-rw-r--r--connectivity/Library_firebird_sdbc.mk1
-rw-r--r--connectivity/source/drivers/firebird/Keys.cxx56
-rw-r--r--connectivity/source/drivers/firebird/Keys.hxx41
-rw-r--r--connectivity/source/drivers/firebird/Table.cxx10
4 files changed, 102 insertions, 6 deletions
diff --git a/connectivity/Library_firebird_sdbc.mk b/connectivity/Library_firebird_sdbc.mk
index 1f78608214b5..2391349a6cc7 100644
--- a/connectivity/Library_firebird_sdbc.mk
+++ b/connectivity/Library_firebird_sdbc.mk
@@ -43,6 +43,7 @@ $(eval $(call gb_Library_add_exception_objects,firebird_sdbc,\
connectivity/source/drivers/firebird/Connection \
connectivity/source/drivers/firebird/DatabaseMetaData \
connectivity/source/drivers/firebird/Driver \
+ connectivity/source/drivers/firebird/Keys \
connectivity/source/drivers/firebird/PreparedStatement \
connectivity/source/drivers/firebird/ResultSet \
connectivity/source/drivers/firebird/ResultSetMetaData \
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
diff --git a/connectivity/source/drivers/firebird/Keys.hxx b/connectivity/source/drivers/firebird/Keys.hxx
new file mode 100644
index 000000000000..a99edbdb2e1a
--- /dev/null
+++ b/connectivity/source/drivers/firebird/Keys.hxx
@@ -0,0 +1,41 @@
+/* -*- 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/.
+ */
+
+#ifndef CONNECTIVITY_FIREBIRD_KEYS_HXX
+#define CONNECTIVITY_FIREBIRD_KEYS_HXX
+
+#include <connectivity/TKeys.hxx>
+
+namespace connectivity
+{
+
+ namespace firebird
+ {
+
+ class Table;
+
+ class Keys: public ::connectivity::OKeysHelper
+ {
+ private:
+ Table* m_pTable;
+
+ public:
+ Keys(Table* pTable,
+ ::osl::Mutex& rMutex,
+ const ::connectivity::TStringVector& rNames);
+
+ // OKeysHelper / XDrop
+ void dropObject(sal_Int32 nPosition, const ::rtl::OUString sName);
+
+ };
+ }
+}
+#endif // CONNECTIVITY_FIREBIRD_KEYS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file
diff --git a/connectivity/source/drivers/firebird/Table.cxx b/connectivity/source/drivers/firebird/Table.cxx
index 9b76d2a368a4..8114d08c0a3a 100644
--- a/connectivity/source/drivers/firebird/Table.cxx
+++ b/connectivity/source/drivers/firebird/Table.cxx
@@ -8,12 +8,12 @@
*/
#include "Columns.hxx"
+#include "Keys.hxx"
#include "Table.hxx"
#include <comphelper/sequence.hxx>
#include <connectivity/dbtools.hxx>
#include <connectivity/TIndexes.hxx>
-#include <connectivity/TKeys.hxx>
#include <com/sun/star/sdbc/ColumnValue.hpp>
@@ -70,11 +70,9 @@ OCollection* Table::createColumns(const TStringVector& rNames)
OCollection* Table::createKeys(const TStringVector& rNames)
{
- // TODO: maybe add a wrapper here in case we the OKeysHelper isn't
- // fully FB compatible.
- return new OKeysHelper(this,
- m_rMutex,
- rNames);
+ return new Keys(this,
+ m_rMutex,
+ rNames);
}
OCollection* Table::createIndexes(const TStringVector& rNames)