aboutsummaryrefslogtreecommitdiff
path: root/common/schema/driver.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-02-07 17:52:49 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-02-07 17:52:49 +0200
commit7dbf58f9486fb3b3a021bbfab9df03af5a8f0fb3 (patch)
treebdf0897bd03cb578d932257a70ad98314c7e7821 /common/schema/driver.cxx
parent14cc151f37a089784f8db162bb6f419ec8d1aecb (diff)
Use multi-pass table creation in MySQL
This deals with table creation order and circular dependencies. Unfortunately, there doesn't seem to be a way in MySQL to drop a foreign key only if it exists without resorting to stored procedures.
Diffstat (limited to 'common/schema/driver.cxx')
-rw-r--r--common/schema/driver.cxx112
1 files changed, 0 insertions, 112 deletions
diff --git a/common/schema/driver.cxx b/common/schema/driver.cxx
deleted file mode 100644
index a47d1f6..0000000
--- a/common/schema/driver.cxx
+++ /dev/null
@@ -1,112 +0,0 @@
-// file : common/schema/driver.cxx
-// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC
-// license : GNU GPL v2; see accompanying LICENSE file
-
-// Test various aspects of database schema.
-//
-
-#include <memory> // std::auto_ptr
-#include <cassert>
-#include <iostream>
-
-#include <odb/database.hxx>
-#include <odb/transaction.hxx>
-
-#include <common/common.hxx>
-
-#include "test.hxx"
-#include "test-odb.hxx"
-
-using namespace std;
-using namespace odb::core;
-
-int
-main (int argc, char* argv[])
-{
- try
- {
- auto_ptr<database> db (create_database (argc, argv));
-
- // Test database schema (aka database namespace).
- //
- using ns::object2;
-
- object2 o2;
- o2.id = "aaa";
- o2.nums.push_back (1);
- o2.nums.push_back (2);
- o2.nums.push_back (3);
- o2.obj1 = new object1;
- o2.obj1->str = "aaa";
-
- {
- transaction t (db->begin ());
- db->persist (o2.obj1);
- db->persist (o2);
- t.commit ();
- }
-
- {
- transaction t (db->begin ());
- auto_ptr<object2> p2 (db->load<object2> ("aaa"));
- t.commit ();
-
- assert (o2 == *p2);
- }
-
- {
- typedef odb::query<object2> query;
- typedef odb::result<object2> result;
-
- transaction t (db->begin ());
-
- {
- result r (db->query<object2> (query::id == "aaa"));
- assert (size (r) == 1);
- }
-
- {
- result r (db->query<object2> (query::obj1->str == "aaa"));
- assert (size (r) == 1);
- }
-
- t.commit ();
- }
-
- {
- typedef odb::query<object_view> query;
- typedef odb::result<object_view> result;
-
- transaction t (db->begin ());
-
- result r (db->query<object_view> (query::object2::id == "aaa"));
-
- result::iterator i (r.begin ());
- assert (i != r.end ());
- assert (i->id2 == "aaa" && i->str == "aaa");
- assert (++i == r.end ());
-
- t.commit ();
- }
-
- {
- typedef odb::result<table_view> result;
-
- transaction t (db->begin ());
-
- result r (db->query<table_view> ());
-
- result::iterator i (r.begin ());
- assert (i != r.end ());
- assert (i->str == "aaa");
- assert (++i == r.end ());
-
- t.commit ();
- }
- }
- catch (const odb::exception& e)
- {
- cerr << e.what () << endl;
- return 1;
- }
-}