From 4f22837bda784e29f17750c8f1d623b40c1093d4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 4 Dec 2013 11:30:33 +0200 Subject: Implement on_delete pragma for object pointers Translates to the ON DELETE SQL clause. --- common/relationship-query/driver.cxx | 173 ----------------------------------- 1 file changed, 173 deletions(-) delete mode 100644 common/relationship-query/driver.cxx (limited to 'common/relationship-query/driver.cxx') diff --git a/common/relationship-query/driver.cxx b/common/relationship-query/driver.cxx deleted file mode 100644 index 785aa94..0000000 --- a/common/relationship-query/driver.cxx +++ /dev/null @@ -1,173 +0,0 @@ -// file : common/relationship-query/driver.cxx -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC -// license : GNU GPL v2; see accompanying LICENSE file - -// Test relationship queries. -// - -#include // std::auto_ptr -#include -#include - -#include -#include -#include - -#include // HAVE_CXX11, HAVE_TR1_MEMORY -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_database (argc, argv)); - -#if defined(HAVE_CXX11) || defined(HAVE_TR1_MEMORY) - - // - // - { - shared_ptr ca (new country ("CA", "Canada")); - shared_ptr za (new country ("ZA", "South Africa")); - shared_ptr us (new country ("US", "United States")); - shared_ptr se (new country ("SE", "Sweden")); - - shared_ptr st (new employer ("Simple Tech, Inc", ca)); - shared_ptr ct (new employer ("Complex Tech, Inc", us)); - - // person - // - shared_ptr p1 ( - new person (1, "John", "Doe", 30, ca, true, za)); - - shared_ptr p2 ( - new person (2, "Jane", "Doe", 29, za, false, us)); - p2->husband = p1; - - shared_ptr p3 ( - new person (3, "Joe", "Dirt", 31, us, true, us)); - - shared_ptr p4 ( - new person (4, "Johan", "Johansen", 32, se, false, ca)); - - // employee - // - shared_ptr e1 ( - new employee (1, "John", "Doe", 30, ca, true, za, st)); - - shared_ptr e2 ( - new employee (2, "Jane", "Doe", 29, za, false, us, ct)); - e2->husband = p1; - - shared_ptr e3 ( - new employee (3, "Joe", "Dirt", 31, us, true, us, st)); - - shared_ptr e4 ( - new employee (4, "Johan", "Johansen", 32, se, false, ca, ct)); - - transaction t (db->begin ()); - db->persist (ca); - db->persist (za); - db->persist (us); - db->persist (se); - - db->persist (st); - db->persist (ct); - - db->persist (p1); - db->persist (p2); - db->persist (p3); - db->persist (p4); - - db->persist (e1); - db->persist (e2); - db->persist (e3); - db->persist (e4); - t.commit (); - } - - typedef odb::query p_query; - typedef odb::result p_result; - - typedef odb::query e_query; - typedef odb::result e_result; - - // Make sure we have an independent JOIN for each relationship. - // - { - session s; - transaction t (db->begin ()); - - p_result pr (db->query ( - p_query::residence.location->code == "ZA")); - assert (size (pr) == 1); - - e_result er (db->query ( - e_query::residence.location->code == "ZA")); - assert (size (er) == 1); - - t.commit (); - } - - // Test Self-JOIN. - // - { - session s; - transaction t (db->begin ()); - - p_result pr (db->query (p_query::husband->last_name == "Doe")); - assert (size (pr) == 1); - - e_result er (db->query (e_query::husband->last_name == "Doe")); - assert (size (er) == 1); - - t.commit (); - } - - // Test query conditions from both base and derived. - // - { - session s; - transaction t (db->begin ()); - - e_result r ( - db->query ( - e_query::employed_by->name == "Simple Tech, Inc" && - e_query::nationality->code == "US")); - - assert (size (r) == 1); - - t.commit (); - } - - // Test second-level pointers. - // - { - session s; - transaction t (db->begin ()); - - p_result r ( - db->query ( - p_query::husband->residence.location == "CA")); - - assert (size (r) == 1); - - t.commit (); - } - -#endif // HAVE_CXX11 || HAVE_TR1_MEMORY - - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} -- cgit v1.1