From f53b4dc54ed37169544ce7c080e194aab3d853f3 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 20 Nov 2014 15:46:21 +0200 Subject: Add test --- bulk/mssql/orig/person-odb.cxx | 524 ----------------------------------------- bulk/mssql/orig/person-odb.hxx | 214 ----------------- bulk/mssql/orig/person-odb.ixx | 61 ----- 3 files changed, 799 deletions(-) delete mode 100644 bulk/mssql/orig/person-odb.cxx delete mode 100644 bulk/mssql/orig/person-odb.hxx delete mode 100644 bulk/mssql/orig/person-odb.ixx (limited to 'bulk/mssql/orig') diff --git a/bulk/mssql/orig/person-odb.cxx b/bulk/mssql/orig/person-odb.cxx deleted file mode 100644 index 6ed2172..0000000 --- a/bulk/mssql/orig/person-odb.cxx +++ /dev/null @@ -1,524 +0,0 @@ -// This file was generated by ODB, object-relational mapping (ORM) -// compiler for C++. -// - -#include - -#include "person-odb.hxx" - -#include -#include // std::memcpy - - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace odb -{ - // person - // - - struct access::object_traits_impl< ::person, id_mssql >::extra_statement_cache_type - { - extra_statement_cache_type ( - mssql::connection&, - image_type&, - mssql::binding&, - mssql::binding&) - { - } - }; - - void access::object_traits_impl< ::person, id_mssql >:: - bind (mssql::bind* b, - image_type& i, - mssql::statement_kind sk) - { - ODB_POTENTIALLY_UNUSED (sk); - - using namespace mssql; - - std::size_t n (0); - - // id - // - if (sk != statement_insert && sk != statement_update) - { - b[n].type = mssql::bind::bigint; - b[n].buffer = &i.id_value; - b[n].size_ind = &i.id_size_ind; - n++; - } - - // num - // - b[n].type = mssql::bind::int_; - b[n].buffer = &i.num_value; - b[n].size_ind = &i.num_size_ind; - n++; - - // str - // - b[n].type = mssql::bind::long_string; - b[n].buffer = &i.str_callback; - b[n].size_ind = &i.str_size_ind; - b[n].capacity = 0; - n++; - } - - void access::object_traits_impl< ::person, id_mssql >:: - bind (mssql::bind* b, id_image_type& i) - { - std::size_t n (0); - b[n].type = mssql::bind::bigint; - b[n].buffer = &i.id_value; - b[n].size_ind = &i.id_size_ind; - } - - void access::object_traits_impl< ::person, id_mssql >:: - init (image_type& i, - const object_type& o, - mssql::statement_kind sk) - { - ODB_POTENTIALLY_UNUSED (i); - ODB_POTENTIALLY_UNUSED (o); - ODB_POTENTIALLY_UNUSED (sk); - - using namespace mssql; - - // num - // - { - unsigned int const& v = - o.num; - - bool is_null (false); - mssql::value_traits< - unsigned int, - mssql::id_int >::set_image ( - i.num_value, is_null, v); - i.num_size_ind = is_null ? SQL_NULL_DATA : 0; - } - - // str - // - { - ::std::string const& v = - o.str; - - bool is_null (false); - mssql::value_traits< - ::std::string, - mssql::id_long_string >::set_image ( - i.str_callback.callback.param, - i.str_callback.context.param, - is_null, - v); - i.str_size_ind = is_null ? SQL_NULL_DATA : SQL_DATA_AT_EXEC; - } - } - - void access::object_traits_impl< ::person, id_mssql >:: - init (object_type& o, - const image_type& i, - database* db) - { - ODB_POTENTIALLY_UNUSED (o); - ODB_POTENTIALLY_UNUSED (i); - ODB_POTENTIALLY_UNUSED (db); - - // id - // - { - long unsigned int& v = - o.id; - - mssql::value_traits< - long unsigned int, - mssql::id_bigint >::set_value ( - v, - i.id_value, - i.id_size_ind == SQL_NULL_DATA); - } - - // num - // - { - unsigned int& v = - o.num; - - mssql::value_traits< - unsigned int, - mssql::id_int >::set_value ( - v, - i.num_value, - i.num_size_ind == SQL_NULL_DATA); - } - - // str - // - { - ::std::string& v = - o.str; - - mssql::value_traits< - ::std::string, - mssql::id_long_string >::set_value ( - v, - i.str_callback.callback.result, - i.str_callback.context.result); - } - } - - void access::object_traits_impl< ::person, id_mssql >:: - init (id_image_type& i, const id_type& id) - { - { - bool is_null (false); - mssql::value_traits< - long unsigned int, - mssql::id_bigint >::set_image ( - i.id_value, is_null, id); - i.id_size_ind = is_null ? SQL_NULL_DATA : 0; - } - } - - const char access::object_traits_impl< ::person, id_mssql >::persist_statement[] = - "INSERT INTO [person] " - "([num], " - "[str]) " - "OUTPUT INSERTED.[id] " - "VALUES " - "(?, ?)"; - - const char access::object_traits_impl< ::person, id_mssql >::find_statement[] = - "SELECT " - "[person].[id], " - "[person].[num], " - "[person].[str] " - "FROM [person] " - "WHERE [person].[id]=?"; - - const char access::object_traits_impl< ::person, id_mssql >::update_statement[] = - "UPDATE [person] " - "SET " - "[num]=?, " - "[str]=? " - "WHERE [id]=?"; - - const char access::object_traits_impl< ::person, id_mssql >::erase_statement[] = - "DELETE FROM [person] " - "WHERE [id]=?"; - - void access::object_traits_impl< ::person, id_mssql >:: - persist (database& db, object_type& obj) - { - ODB_POTENTIALLY_UNUSED (db); - - using namespace mssql; - - mssql::connection& conn ( - mssql::transaction::current ().connection ()); - statements_type& sts ( - conn.statement_cache ().find_object ()); - - callback (db, - static_cast (obj), - callback_event::pre_persist); - - image_type& im (sts.image ()); - binding& imb (sts.insert_image_binding ()); - - init (im, obj, statement_insert); - - if (im.version != sts.insert_image_version () || - imb.version == 0) - { - bind (imb.bind, im, statement_insert); - sts.insert_image_version (im.version); - imb.version++; - } - - insert_statement& st (sts.persist_statement ()); - if (!st.execute ()) - throw object_already_persistent (); - - obj.id = static_cast< id_type > (st.id ()); - - callback (db, - static_cast (obj), - callback_event::post_persist); - } - - void access::object_traits_impl< ::person, id_mssql >:: - update (database& db, const object_type& obj) - { - ODB_POTENTIALLY_UNUSED (db); - - using namespace mssql; - using mssql::update_statement; - - callback (db, obj, callback_event::pre_update); - - mssql::transaction& tr (mssql::transaction::current ()); - mssql::connection& conn (tr.connection ()); - statements_type& sts ( - conn.statement_cache ().find_object ()); - - const id_type& id ( - obj.id); - id_image_type& idi (sts.id_image ()); - init (idi, id); - - image_type& im (sts.image ()); - init (im, obj, statement_update); - - bool u (false); - binding& imb (sts.update_image_binding ()); - if (im.version != sts.update_image_version () || - imb.version == 0) - { - bind (imb.bind, im, statement_update); - sts.update_image_version (im.version); - imb.version++; - u = true; - } - - binding& idb (sts.id_image_binding ()); - if (idi.version != sts.update_id_image_version () || - idb.version == 0) - { - if (idi.version != sts.id_image_version () || - idb.version == 0) - { - bind (idb.bind, idi); - sts.id_image_version (idi.version); - idb.version++; - } - - sts.update_id_image_version (idi.version); - - if (!u) - imb.version++; - } - - update_statement& st (sts.update_statement ()); - if (st.execute () == 0) - throw object_not_persistent (); - - callback (db, obj, callback_event::post_update); - pointer_cache_traits::update (db, obj); - } - - void access::object_traits_impl< ::person, id_mssql >:: - erase (database& db, const id_type& id) - { - using namespace mssql; - - ODB_POTENTIALLY_UNUSED (db); - - mssql::connection& conn ( - mssql::transaction::current ().connection ()); - statements_type& sts ( - conn.statement_cache ().find_object ()); - - id_image_type& i (sts.id_image ()); - init (i, id); - - binding& idb (sts.id_image_binding ()); - if (i.version != sts.id_image_version () || idb.version == 0) - { - bind (idb.bind, i); - sts.id_image_version (i.version); - idb.version++; - } - - if (sts.erase_statement ().execute () != 1) - throw object_not_persistent (); - - pointer_cache_traits::erase (db, id); - } - - access::object_traits_impl< ::person, id_mssql >::pointer_type - access::object_traits_impl< ::person, id_mssql >:: - find (database& db, const id_type& id) - { - using namespace mssql; - - { - pointer_type p (pointer_cache_traits::find (db, id)); - - if (!pointer_traits::null_ptr (p)) - return p; - } - - mssql::connection& conn ( - mssql::transaction::current ().connection ()); - statements_type& sts ( - conn.statement_cache ().find_object ()); - - statements_type::auto_lock l (sts); - auto_result ar; - - if (l.locked ()) - { - if (!find_ (sts, &id)) - return pointer_type (); - - ar.set (sts.find_statement ()); - } - - pointer_type p ( - access::object_factory::create ()); - pointer_traits::guard pg (p); - - pointer_cache_traits::insert_guard ig ( - pointer_cache_traits::insert (db, id, p)); - - object_type& obj (pointer_traits::get_ref (p)); - - if (l.locked ()) - { - select_statement& st (sts.find_statement ()); - ODB_POTENTIALLY_UNUSED (st); - - callback (db, obj, callback_event::pre_load); - init (obj, sts.image (), &db); - st.stream_result (); - ar.free (); - load_ (sts, obj, false); - sts.load_delayed (0); - l.unlock (); - callback (db, obj, callback_event::post_load); - pointer_cache_traits::load (ig.position ()); - } - else - sts.delay_load (id, obj, ig.position ()); - - ig.release (); - pg.release (); - return p; - } - - bool access::object_traits_impl< ::person, id_mssql >:: - find (database& db, const id_type& id, object_type& obj) - { - using namespace mssql; - - mssql::connection& conn ( - mssql::transaction::current ().connection ()); - statements_type& sts ( - conn.statement_cache ().find_object ()); - - statements_type::auto_lock l (sts); - - if (!find_ (sts, &id)) - return false; - - select_statement& st (sts.find_statement ()); - ODB_POTENTIALLY_UNUSED (st); - - auto_result ar (st); - reference_cache_traits::position_type pos ( - reference_cache_traits::insert (db, id, obj)); - reference_cache_traits::insert_guard ig (pos); - - callback (db, obj, callback_event::pre_load); - init (obj, sts.image (), &db); - st.stream_result (); - ar.free (); - load_ (sts, obj, false); - sts.load_delayed (0); - l.unlock (); - callback (db, obj, callback_event::post_load); - reference_cache_traits::load (pos); - ig.release (); - return true; - } - - bool access::object_traits_impl< ::person, id_mssql >:: - reload (database& db, object_type& obj) - { - using namespace mssql; - - mssql::connection& conn ( - mssql::transaction::current ().connection ()); - statements_type& sts ( - conn.statement_cache ().find_object ()); - - statements_type::auto_lock l (sts); - - const id_type& id ( - obj.id); - - if (!find_ (sts, &id)) - return false; - - select_statement& st (sts.find_statement ()); - ODB_POTENTIALLY_UNUSED (st); - - auto_result ar (st); - - callback (db, obj, callback_event::pre_load); - init (obj, sts.image (), &db); - st.stream_result (); - ar.free (); - load_ (sts, obj, true); - sts.load_delayed (0); - l.unlock (); - callback (db, obj, callback_event::post_load); - return true; - } - - bool access::object_traits_impl< ::person, id_mssql >:: - find_ (statements_type& sts, - const id_type* id) - { - using namespace mssql; - - id_image_type& i (sts.id_image ()); - init (i, *id); - - binding& idb (sts.id_image_binding ()); - if (i.version != sts.id_image_version () || idb.version == 0) - { - bind (idb.bind, i); - sts.id_image_version (i.version); - idb.version++; - } - - image_type& im (sts.image ()); - binding& imb (sts.select_image_binding ()); - - if (im.version != sts.select_image_version () || - imb.version == 0) - { - bind (imb.bind, im, statement_select); - sts.select_image_version (im.version); - imb.version++; - } - - select_statement& st (sts.find_statement ()); - - st.execute (); - auto_result ar (st); - select_statement::result r (st.fetch ()); - - if (r != select_statement::no_data) - { - ar.release (); - return true; - } - else - return false; - } -} - -#include diff --git a/bulk/mssql/orig/person-odb.hxx b/bulk/mssql/orig/person-odb.hxx deleted file mode 100644 index 9f395b0..0000000 --- a/bulk/mssql/orig/person-odb.hxx +++ /dev/null @@ -1,214 +0,0 @@ -// This file was generated by ODB, object-relational mapping (ORM) -// compiler for C++. -// - -#ifndef PERSON_ODB_HXX -#define PERSON_ODB_HXX - -#include - -#if (ODB_VERSION != 20302UL) -#error ODB runtime version mismatch -#endif - -#include - -#include "person.hxx" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace odb -{ - // person - // - template <> - struct class_traits< ::person > - { - static const class_kind kind = class_object; - }; - - template <> - class access::object_traits< ::person > - { - public: - typedef ::person object_type; - typedef ::person* pointer_type; - typedef odb::pointer_traits pointer_traits; - - static const bool polymorphic = false; - - typedef long unsigned int id_type; - - static const bool auto_id = true; - - static const bool abstract = false; - - static id_type - id (const object_type&); - - typedef - no_op_pointer_cache_traits - pointer_cache_traits; - - typedef - no_op_reference_cache_traits - reference_cache_traits; - - static void - callback (database&, object_type&, callback_event); - - static void - callback (database&, const object_type&, callback_event); - }; -} - -#include - -#include -#include -#include -#include - -namespace odb -{ - // person - // - template <> - class access::object_traits_impl< ::person, id_mssql >: - public access::object_traits< ::person > - { - public: - static const bool rowversion = false; - - struct id_image_type - { - long long id_value; - SQLLEN id_size_ind; - - std::size_t version; - }; - - struct image_type - { - // id - // - long long id_value; - SQLLEN id_size_ind; - - // num - // - int num_value; - SQLLEN num_size_ind; - - // str - // - mutable mssql::long_callback str_callback; - SQLLEN str_size_ind; - - std::size_t version; - - mssql::change_callback* - change_callback () - { - return 0; - } - }; - - struct extra_statement_cache_type; - - using object_traits::id; - - static void - bind (mssql::bind*, - image_type&, - mssql::statement_kind); - - static void - bind (mssql::bind*, id_image_type&); - - static void - init (image_type&, - const object_type&, - mssql::statement_kind); - - static void - init (object_type&, - const image_type&, - database*); - - static void - init (id_image_type&, const id_type&); - - typedef mssql::object_statements statements_type; - - static const std::size_t column_count = 3UL; - static const std::size_t id_column_count = 1UL; - static const std::size_t inverse_column_count = 0UL; - static const std::size_t readonly_column_count = 0UL; - static const std::size_t managed_optimistic_column_count = 0UL; - - static const std::size_t separate_load_column_count = 0UL; - static const std::size_t separate_update_column_count = 0UL; - - static const bool versioned = false; - - static const char persist_statement[]; - static const char find_statement[]; - static const char update_statement[]; - static const char erase_statement[]; - - static void - persist (database&, object_type&); - - static pointer_type - find (database&, const id_type&); - - static bool - find (database&, const id_type&, object_type&); - - static bool - reload (database&, object_type&); - - static void - update (database&, const object_type&); - - static void - erase (database&, const id_type&); - - static void - erase (database&, const object_type&); - - public: - static bool - find_ (statements_type&, - const id_type*); - - static void - load_ (statements_type&, - object_type&, - bool reload); - }; - - template <> - class access::object_traits_impl< ::person, id_common >: - public access::object_traits_impl< ::person, id_mssql > - { - }; -} - -#include "person-odb.ixx" - -#include - -#endif // PERSON_ODB_HXX diff --git a/bulk/mssql/orig/person-odb.ixx b/bulk/mssql/orig/person-odb.ixx deleted file mode 100644 index 73f62a7..0000000 --- a/bulk/mssql/orig/person-odb.ixx +++ /dev/null @@ -1,61 +0,0 @@ -// This file was generated by ODB, object-relational mapping (ORM) -// compiler for C++. -// - -namespace odb -{ - // person - // - - inline - access::object_traits< ::person >::id_type - access::object_traits< ::person >:: - id (const object_type& o) - { - return o.id; - } - - inline - void access::object_traits< ::person >:: - callback (database& db, object_type& x, callback_event e) - { - ODB_POTENTIALLY_UNUSED (db); - ODB_POTENTIALLY_UNUSED (x); - ODB_POTENTIALLY_UNUSED (e); - } - - inline - void access::object_traits< ::person >:: - callback (database& db, const object_type& x, callback_event e) - { - ODB_POTENTIALLY_UNUSED (db); - ODB_POTENTIALLY_UNUSED (x); - ODB_POTENTIALLY_UNUSED (e); - } -} - -namespace odb -{ - // person - // - - inline - void access::object_traits_impl< ::person, id_mssql >:: - erase (database& db, const object_type& obj) - { - callback (db, obj, callback_event::pre_erase); - erase (db, id (obj)); - callback (db, obj, callback_event::post_erase); - } - - inline - void access::object_traits_impl< ::person, id_mssql >:: - load_ (statements_type& sts, - object_type& obj, - bool) - { - ODB_POTENTIALLY_UNUSED (sts); - ODB_POTENTIALLY_UNUSED (obj); - } -} - -- cgit v1.1