mirror of
https://github.com/latentPrion/cppbessot.git
synced 2026-04-17 18:44:23 +00:00
Compare commits
2 Commits
d17be6f641
...
8df8a764b4
| Author | SHA1 | Date | |
|---|---|---|---|
| 8df8a764b4 | |||
| 419d8b2f9f |
@@ -48,6 +48,69 @@ function(_cppbessot_try_link_nlohmann target_name)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(_cppbessot_add_generated_model_library cpp_include_dir expected_model_headers expected_model_sources)
|
||||
set_source_files_properties(${expected_model_headers} ${expected_model_sources}
|
||||
PROPERTIES GENERATED TRUE)
|
||||
add_library(cppBeSsotOpenAiModelGen STATIC ${expected_model_sources})
|
||||
add_dependencies(cppBeSsotOpenAiModelGen db_gen_cpp_headers)
|
||||
set_target_properties(cppBeSsotOpenAiModelGen PROPERTIES
|
||||
OUTPUT_NAME "cppBeSsotOpenAiModelGen"
|
||||
POSITION_INDEPENDENT_CODE ON)
|
||||
target_include_directories(cppBeSsotOpenAiModelGen PUBLIC "${cpp_include_dir}")
|
||||
_cppbessot_try_link_nlohmann(cppBeSsotOpenAiModelGen)
|
||||
add_library(cppbessot::openai_model_gen ALIAS cppBeSsotOpenAiModelGen)
|
||||
endfunction()
|
||||
|
||||
function(_cppbessot_add_generated_sqlite_library
|
||||
cpp_include_dir
|
||||
model_leaf_include_dir
|
||||
version_dir
|
||||
expected_sqlite_odb_sources)
|
||||
set_source_files_properties(${expected_sqlite_odb_sources} PROPERTIES GENERATED TRUE)
|
||||
add_library(cppBeSsotOdbSqlite SHARED ${expected_sqlite_odb_sources})
|
||||
# Keep the ODB library aligned with the SQL snapshots emitted from the same schema generation pass.
|
||||
add_dependencies(cppBeSsotOdbSqlite
|
||||
db_gen_odb_logic
|
||||
db_gen_sql_ddl)
|
||||
set_target_properties(cppBeSsotOdbSqlite PROPERTIES
|
||||
OUTPUT_NAME "cppBeSsotOdbSqlite"
|
||||
POSITION_INDEPENDENT_CODE ON)
|
||||
target_include_directories(cppBeSsotOdbSqlite PUBLIC
|
||||
"${cpp_include_dir}"
|
||||
"${model_leaf_include_dir}"
|
||||
"${version_dir}/generated-odb-source/sqlite"
|
||||
"${CPPBESSOT_SQLITE_INCLUDE_DIR}")
|
||||
target_link_libraries(cppBeSsotOdbSqlite PUBLIC
|
||||
"${CPPBESSOT_ODB_RUNTIME_LIB}"
|
||||
"${CPPBESSOT_ODB_SQLITE_RUNTIME_LIB}")
|
||||
add_library(cppbessot::odb_sqlite ALIAS cppBeSsotOdbSqlite)
|
||||
endfunction()
|
||||
|
||||
function(_cppbessot_add_generated_pgsql_library
|
||||
cpp_include_dir
|
||||
model_leaf_include_dir
|
||||
version_dir
|
||||
expected_pgsql_odb_sources)
|
||||
set_source_files_properties(${expected_pgsql_odb_sources} PROPERTIES GENERATED TRUE)
|
||||
add_library(cppBeSsotOdbPgSql SHARED ${expected_pgsql_odb_sources})
|
||||
# Keep the ODB library aligned with the SQL snapshots emitted from the same schema generation pass.
|
||||
add_dependencies(cppBeSsotOdbPgSql
|
||||
db_gen_odb_logic
|
||||
db_gen_sql_ddl)
|
||||
set_target_properties(cppBeSsotOdbPgSql PROPERTIES
|
||||
OUTPUT_NAME "cppBeSsotOdbPgSql"
|
||||
POSITION_INDEPENDENT_CODE ON)
|
||||
target_include_directories(cppBeSsotOdbPgSql PUBLIC
|
||||
"${cpp_include_dir}"
|
||||
"${model_leaf_include_dir}"
|
||||
"${version_dir}/generated-odb-source/postgre"
|
||||
"${CPPBESSOT_PGSQL_INCLUDE_DIR}")
|
||||
target_link_libraries(cppBeSsotOdbPgSql PUBLIC
|
||||
"${CPPBESSOT_ODB_RUNTIME_LIB}"
|
||||
"${CPPBESSOT_ODB_PGSQL_RUNTIME_LIB}")
|
||||
add_library(cppbessot::odb_pgsql ALIAS cppBeSsotOdbPgSql)
|
||||
endfunction()
|
||||
|
||||
function(cppbessot_add_generated_libraries)
|
||||
# Purpose: Create consumable libraries from generated model and ODB sources.
|
||||
# Inputs:
|
||||
@@ -80,48 +143,20 @@ function(cppbessot_add_generated_libraries)
|
||||
cppbessot_get_expected_cpp_model_outputs(_expected_model_headers _expected_model_sources "${CPPB_SCHEMA_DIR}")
|
||||
cppbessot_get_expected_odb_outputs(_expected_sqlite_odb_sources _expected_pgsql_odb_sources "${CPPB_SCHEMA_DIR}")
|
||||
|
||||
set_source_files_properties(${_expected_model_headers} ${_expected_model_sources}
|
||||
PROPERTIES GENERATED TRUE)
|
||||
add_library(cppBeSsotOpenAiModelGen STATIC ${_expected_model_sources})
|
||||
add_dependencies(cppBeSsotOpenAiModelGen db_gen_cpp_headers)
|
||||
set_target_properties(cppBeSsotOpenAiModelGen PROPERTIES
|
||||
OUTPUT_NAME "cppBeSsotOpenAiModelGen"
|
||||
POSITION_INDEPENDENT_CODE ON)
|
||||
target_include_directories(cppBeSsotOpenAiModelGen PUBLIC "${_cpp_include_dir}")
|
||||
_cppbessot_try_link_nlohmann(cppBeSsotOpenAiModelGen)
|
||||
add_library(cppbessot::openai_model_gen ALIAS cppBeSsotOpenAiModelGen)
|
||||
|
||||
set_source_files_properties(${_expected_sqlite_odb_sources} PROPERTIES GENERATED TRUE)
|
||||
add_library(cppBeSsotOdbSqlite SHARED ${_expected_sqlite_odb_sources})
|
||||
add_dependencies(cppBeSsotOdbSqlite db_gen_odb_logic)
|
||||
set_target_properties(cppBeSsotOdbSqlite PROPERTIES
|
||||
OUTPUT_NAME "cppBeSsotOdbSqlite"
|
||||
POSITION_INDEPENDENT_CODE ON)
|
||||
target_include_directories(cppBeSsotOdbSqlite PUBLIC
|
||||
_cppbessot_add_generated_model_library(
|
||||
"${_cpp_include_dir}"
|
||||
"${_expected_model_headers}"
|
||||
"${_expected_model_sources}")
|
||||
_cppbessot_add_generated_sqlite_library(
|
||||
"${_cpp_include_dir}"
|
||||
"${_model_leaf_include_dir}"
|
||||
"${_version_dir}/generated-odb-source/sqlite"
|
||||
"${CPPBESSOT_SQLITE_INCLUDE_DIR}")
|
||||
target_link_libraries(cppBeSsotOdbSqlite PUBLIC
|
||||
"${CPPBESSOT_ODB_RUNTIME_LIB}"
|
||||
"${CPPBESSOT_ODB_SQLITE_RUNTIME_LIB}")
|
||||
add_library(cppbessot::odb_sqlite ALIAS cppBeSsotOdbSqlite)
|
||||
|
||||
set_source_files_properties(${_expected_pgsql_odb_sources} PROPERTIES GENERATED TRUE)
|
||||
add_library(cppBeSsotOdbPgSql SHARED ${_expected_pgsql_odb_sources})
|
||||
add_dependencies(cppBeSsotOdbPgSql db_gen_odb_logic)
|
||||
set_target_properties(cppBeSsotOdbPgSql PROPERTIES
|
||||
OUTPUT_NAME "cppBeSsotOdbPgSql"
|
||||
POSITION_INDEPENDENT_CODE ON)
|
||||
target_include_directories(cppBeSsotOdbPgSql PUBLIC
|
||||
"${_version_dir}"
|
||||
"${_expected_sqlite_odb_sources}")
|
||||
_cppbessot_add_generated_pgsql_library(
|
||||
"${_cpp_include_dir}"
|
||||
"${_model_leaf_include_dir}"
|
||||
"${_version_dir}/generated-odb-source/postgre"
|
||||
"${CPPBESSOT_PGSQL_INCLUDE_DIR}")
|
||||
target_link_libraries(cppBeSsotOdbPgSql PUBLIC
|
||||
"${CPPBESSOT_ODB_RUNTIME_LIB}"
|
||||
"${CPPBESSOT_ODB_PGSQL_RUNTIME_LIB}")
|
||||
add_library(cppbessot::odb_pgsql ALIAS cppBeSsotOdbPgSql)
|
||||
"${_version_dir}"
|
||||
"${_expected_pgsql_odb_sources}")
|
||||
endfunction()
|
||||
|
||||
function(cppbessot_enable)
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* AUTO-GENERATED BY CppBeSsot.
|
||||
* Direct edits are pointless: this file is regenerated.
|
||||
* Update the OpenAPI schema and/or CppBeSsot templates, then regenerate generated-* outputs.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <odb/core.hxx>
|
||||
|
||||
namespace models {
|
||||
|
||||
#pragma db model version(1, 2)
|
||||
#pragma db object table("Agent")
|
||||
class Agent
|
||||
{
|
||||
public:
|
||||
#pragma db id
|
||||
// odbAddedIn: 1.1
|
||||
std::string id{};
|
||||
// odbAddedIn: 1.1
|
||||
std::string role{};
|
||||
// odbAddedIn: 1.1
|
||||
bool persistent{};
|
||||
// odbAddedIn: 1.1
|
||||
std::string displayName{};
|
||||
// odbAddedIn: 1.2
|
||||
int32_t trustScore{};
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(Agent, id, role, persistent, displayName, trustScore)
|
||||
|
||||
nlohmann::json toJson() const
|
||||
{
|
||||
return nlohmann::json(*this);
|
||||
}
|
||||
|
||||
static Agent fromJson(const nlohmann::json& j)
|
||||
{
|
||||
return j.get<Agent>();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace models
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* AUTO-GENERATED BY CppBeSsot.
|
||||
* Direct edits are pointless: this file is regenerated.
|
||||
* Update the OpenAPI schema and/or CppBeSsot templates, then regenerate generated-* outputs.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <odb/core.hxx>
|
||||
|
||||
namespace models {
|
||||
|
||||
#pragma db model version(1, 2)
|
||||
#pragma db object table("GovernmentAddress")
|
||||
class GovernmentAddress
|
||||
{
|
||||
public:
|
||||
#pragma db id
|
||||
// odbAddedIn: 1.1
|
||||
std::string id{};
|
||||
// odbAddedIn: 1.1
|
||||
std::string addressLabel{};
|
||||
// odbAddedIn: 1.1
|
||||
std::string regionLookupKey{};
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(GovernmentAddress, id, addressLabel, regionLookupKey)
|
||||
|
||||
nlohmann::json toJson() const
|
||||
{
|
||||
return nlohmann::json(*this);
|
||||
}
|
||||
|
||||
static GovernmentAddress fromJson(const nlohmann::json& j)
|
||||
{
|
||||
return j.get<GovernmentAddress>();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace models
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* AUTO-GENERATED BY CppBeSsot.
|
||||
* Direct edits are pointless: this file is regenerated.
|
||||
* Update the OpenAPI schema and/or CppBeSsot templates, then regenerate generated-* outputs.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <odb/core.hxx>
|
||||
|
||||
namespace models {
|
||||
|
||||
#pragma db model version(1, 2)
|
||||
#pragma db object table("TripAttemptResult")
|
||||
class TripAttemptResult
|
||||
{
|
||||
public:
|
||||
#pragma db id
|
||||
// odbAddedIn: 1.1
|
||||
std::string id{};
|
||||
// odbAddedIn: 1.1
|
||||
std::string result{};
|
||||
// odbAddedIn: 1.1
|
||||
std::string retryReason{};
|
||||
// odbAddedIn: 1.1
|
||||
std::string governmentSuspensionReason{};
|
||||
// odbAddedIn: 1.1
|
||||
std::string governmentTerminationReason{};
|
||||
// odbAddedIn: 1.1
|
||||
std::string complianceSuspensionReason{};
|
||||
// odbAddedIn: 1.1
|
||||
std::string complianceTerminationReason{};
|
||||
// odbAddedIn: 1.1
|
||||
std::string policySuspensionReason{};
|
||||
// odbAddedIn: 1.1
|
||||
std::string policyTerminationReason{};
|
||||
// odbAddedIn: 1.1
|
||||
std::string cancelationReason{};
|
||||
// odbAddedIn: 1.1
|
||||
std::string failureReason{};
|
||||
// odbAddedIn: 1.1
|
||||
std::string details{};
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(TripAttemptResult, id, result, retryReason, governmentSuspensionReason, governmentTerminationReason, complianceSuspensionReason, complianceTerminationReason, policySuspensionReason, policyTerminationReason, cancelationReason, failureReason, details)
|
||||
|
||||
nlohmann::json toJson() const
|
||||
{
|
||||
return nlohmann::json(*this);
|
||||
}
|
||||
|
||||
static TripAttemptResult fromJson(const nlohmann::json& j)
|
||||
{
|
||||
return j.get<TripAttemptResult>();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace models
|
||||
|
||||
11
db/test-schema-v1.2/generated-cpp-source/src/model/Agent.cpp
Normal file
11
db/test-schema-v1.2/generated-cpp-source/src/model/Agent.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* AUTO-GENERATED BY CppBeSsot.
|
||||
* Direct edits are pointless: this file is regenerated.
|
||||
* Update the OpenAPI schema and/or CppBeSsot templates, then regenerate generated-* outputs.
|
||||
*/
|
||||
#include "cppbessot/model/Agent.h"
|
||||
|
||||
namespace models {
|
||||
// Nlohmann-based models are header-only for now.
|
||||
} // namespace models
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* AUTO-GENERATED BY CppBeSsot.
|
||||
* Direct edits are pointless: this file is regenerated.
|
||||
* Update the OpenAPI schema and/or CppBeSsot templates, then regenerate generated-* outputs.
|
||||
*/
|
||||
#include "cppbessot/model/GovernmentAddress.h"
|
||||
|
||||
namespace models {
|
||||
// Nlohmann-based models are header-only for now.
|
||||
} // namespace models
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* AUTO-GENERATED BY CppBeSsot.
|
||||
* Direct edits are pointless: this file is regenerated.
|
||||
* Update the OpenAPI schema and/or CppBeSsot templates, then regenerate generated-* outputs.
|
||||
*/
|
||||
#include "cppbessot/model/TripAttemptResult.h"
|
||||
|
||||
namespace models {
|
||||
// Nlohmann-based models are header-only for now.
|
||||
} // namespace models
|
||||
|
||||
864
db/test-schema-v1.2/generated-odb-source/postgre/Agent-odb.cxx
Normal file
864
db/test-schema-v1.2/generated-odb-source/postgre/Agent-odb.cxx
Normal file
@@ -0,0 +1,864 @@
|
||||
// This file was generated by ODB, object-relational mapping (ORM)
|
||||
// compiler for C++.
|
||||
//
|
||||
|
||||
#include <odb/pre.hxx>
|
||||
|
||||
#include "Agent-odb.hxx"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring> // std::memcpy
|
||||
|
||||
|
||||
#include <odb/pgsql/traits.hxx>
|
||||
#include <odb/pgsql/database.hxx>
|
||||
#include <odb/pgsql/transaction.hxx>
|
||||
#include <odb/pgsql/connection.hxx>
|
||||
#include <odb/pgsql/statement.hxx>
|
||||
#include <odb/pgsql/statement-cache.hxx>
|
||||
#include <odb/pgsql/simple-object-statements.hxx>
|
||||
#include <odb/pgsql/container-statements.hxx>
|
||||
#include <odb/pgsql/exceptions.hxx>
|
||||
#include <odb/pgsql/simple-object-result.hxx>
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// Agent
|
||||
//
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
persist_statement_name[] = "persist_models_Agent";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
find_statement_name[] = "find_models_Agent";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
update_statement_name[] = "update_models_Agent";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
erase_statement_name[] = "erase_models_Agent";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
query_statement_name[] = "query_models_Agent";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
erase_query_statement_name[] = "erase_query_models_Agent";
|
||||
|
||||
const unsigned int access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
persist_statement_types[] =
|
||||
{
|
||||
pgsql::text_oid,
|
||||
pgsql::text_oid,
|
||||
pgsql::bool_oid,
|
||||
pgsql::text_oid,
|
||||
pgsql::int4_oid
|
||||
};
|
||||
|
||||
const unsigned int access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
find_statement_types[] =
|
||||
{
|
||||
pgsql::text_oid
|
||||
};
|
||||
|
||||
const unsigned int access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
update_statement_types[] =
|
||||
{
|
||||
pgsql::text_oid,
|
||||
pgsql::bool_oid,
|
||||
pgsql::text_oid,
|
||||
pgsql::int4_oid,
|
||||
pgsql::text_oid
|
||||
};
|
||||
|
||||
struct access::object_traits_impl< ::models::Agent, id_pgsql >::extra_statement_cache_type
|
||||
{
|
||||
extra_statement_cache_type (
|
||||
pgsql::connection&,
|
||||
image_type&,
|
||||
id_image_type&,
|
||||
pgsql::binding&,
|
||||
pgsql::binding&,
|
||||
pgsql::native_binding&,
|
||||
const unsigned int*)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
access::object_traits_impl< ::models::Agent, id_pgsql >::id_type
|
||||
access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
id (const image_type& i)
|
||||
{
|
||||
pgsql::database* db (0);
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
id_type id;
|
||||
{
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::set_value (
|
||||
id,
|
||||
i.id_value,
|
||||
i.id_size,
|
||||
i.id_null);
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
bool access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
grow (image_type& i,
|
||||
bool* t)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (i);
|
||||
ODB_POTENTIALLY_UNUSED (t);
|
||||
|
||||
bool grew (false);
|
||||
|
||||
// id
|
||||
//
|
||||
if (t[0UL])
|
||||
{
|
||||
i.id_value.capacity (i.id_size);
|
||||
grew = true;
|
||||
}
|
||||
|
||||
// role
|
||||
//
|
||||
if (t[1UL])
|
||||
{
|
||||
i.role_value.capacity (i.role_size);
|
||||
grew = true;
|
||||
}
|
||||
|
||||
// persistent
|
||||
//
|
||||
t[2UL] = 0;
|
||||
|
||||
// displayName
|
||||
//
|
||||
if (t[3UL])
|
||||
{
|
||||
i.displayName_value.capacity (i.displayName_size);
|
||||
grew = true;
|
||||
}
|
||||
|
||||
// trustScore
|
||||
//
|
||||
t[4UL] = 0;
|
||||
|
||||
return grew;
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
bind (pgsql::bind* b,
|
||||
image_type& i,
|
||||
pgsql::statement_kind sk)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (sk);
|
||||
|
||||
using namespace pgsql;
|
||||
|
||||
std::size_t n (0);
|
||||
|
||||
// id
|
||||
//
|
||||
if (sk != statement_update)
|
||||
{
|
||||
b[n].type = pgsql::bind::text;
|
||||
b[n].buffer = i.id_value.data ();
|
||||
b[n].capacity = i.id_value.capacity ();
|
||||
b[n].size = &i.id_size;
|
||||
b[n].is_null = &i.id_null;
|
||||
n++;
|
||||
}
|
||||
|
||||
// role
|
||||
//
|
||||
b[n].type = pgsql::bind::text;
|
||||
b[n].buffer = i.role_value.data ();
|
||||
b[n].capacity = i.role_value.capacity ();
|
||||
b[n].size = &i.role_size;
|
||||
b[n].is_null = &i.role_null;
|
||||
n++;
|
||||
|
||||
// persistent
|
||||
//
|
||||
b[n].type = pgsql::bind::boolean_;
|
||||
b[n].buffer = &i.persistent_value;
|
||||
b[n].is_null = &i.persistent_null;
|
||||
n++;
|
||||
|
||||
// displayName
|
||||
//
|
||||
b[n].type = pgsql::bind::text;
|
||||
b[n].buffer = i.displayName_value.data ();
|
||||
b[n].capacity = i.displayName_value.capacity ();
|
||||
b[n].size = &i.displayName_size;
|
||||
b[n].is_null = &i.displayName_null;
|
||||
n++;
|
||||
|
||||
// trustScore
|
||||
//
|
||||
b[n].type = pgsql::bind::integer;
|
||||
b[n].buffer = &i.trustScore_value;
|
||||
b[n].is_null = &i.trustScore_null;
|
||||
n++;
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
bind (pgsql::bind* b, id_image_type& i)
|
||||
{
|
||||
std::size_t n (0);
|
||||
b[n].type = pgsql::bind::text;
|
||||
b[n].buffer = i.id_value.data ();
|
||||
b[n].capacity = i.id_value.capacity ();
|
||||
b[n].size = &i.id_size;
|
||||
b[n].is_null = &i.id_null;
|
||||
}
|
||||
|
||||
bool access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
init (image_type& i,
|
||||
const object_type& o,
|
||||
pgsql::statement_kind sk)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (i);
|
||||
ODB_POTENTIALLY_UNUSED (o);
|
||||
ODB_POTENTIALLY_UNUSED (sk);
|
||||
|
||||
using namespace pgsql;
|
||||
|
||||
bool grew (false);
|
||||
|
||||
// id
|
||||
//
|
||||
if (sk == statement_insert)
|
||||
{
|
||||
::std::string const& v =
|
||||
o.id;
|
||||
|
||||
bool is_null (false);
|
||||
std::size_t size (0);
|
||||
std::size_t cap (i.id_value.capacity ());
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::set_image (
|
||||
i.id_value,
|
||||
size,
|
||||
is_null,
|
||||
v);
|
||||
i.id_null = is_null;
|
||||
i.id_size = size;
|
||||
grew = grew || (cap != i.id_value.capacity ());
|
||||
}
|
||||
|
||||
// role
|
||||
//
|
||||
{
|
||||
::std::string const& v =
|
||||
o.role;
|
||||
|
||||
bool is_null (false);
|
||||
std::size_t size (0);
|
||||
std::size_t cap (i.role_value.capacity ());
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::set_image (
|
||||
i.role_value,
|
||||
size,
|
||||
is_null,
|
||||
v);
|
||||
i.role_null = is_null;
|
||||
i.role_size = size;
|
||||
grew = grew || (cap != i.role_value.capacity ());
|
||||
}
|
||||
|
||||
// persistent
|
||||
//
|
||||
{
|
||||
bool const& v =
|
||||
o.persistent;
|
||||
|
||||
bool is_null (false);
|
||||
pgsql::value_traits<
|
||||
bool,
|
||||
pgsql::id_boolean >::set_image (
|
||||
i.persistent_value, is_null, v);
|
||||
i.persistent_null = is_null;
|
||||
}
|
||||
|
||||
// displayName
|
||||
//
|
||||
{
|
||||
::std::string const& v =
|
||||
o.displayName;
|
||||
|
||||
bool is_null (false);
|
||||
std::size_t size (0);
|
||||
std::size_t cap (i.displayName_value.capacity ());
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::set_image (
|
||||
i.displayName_value,
|
||||
size,
|
||||
is_null,
|
||||
v);
|
||||
i.displayName_null = is_null;
|
||||
i.displayName_size = size;
|
||||
grew = grew || (cap != i.displayName_value.capacity ());
|
||||
}
|
||||
|
||||
// trustScore
|
||||
//
|
||||
{
|
||||
::int32_t const& v =
|
||||
o.trustScore;
|
||||
|
||||
bool is_null (false);
|
||||
pgsql::value_traits<
|
||||
::int32_t,
|
||||
pgsql::id_integer >::set_image (
|
||||
i.trustScore_value, is_null, v);
|
||||
i.trustScore_null = is_null;
|
||||
}
|
||||
|
||||
return grew;
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
init (object_type& o,
|
||||
const image_type& i,
|
||||
database* db)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (o);
|
||||
ODB_POTENTIALLY_UNUSED (i);
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
// id
|
||||
//
|
||||
{
|
||||
::std::string& v =
|
||||
o.id;
|
||||
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::set_value (
|
||||
v,
|
||||
i.id_value,
|
||||
i.id_size,
|
||||
i.id_null);
|
||||
}
|
||||
|
||||
// role
|
||||
//
|
||||
{
|
||||
::std::string& v =
|
||||
o.role;
|
||||
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::set_value (
|
||||
v,
|
||||
i.role_value,
|
||||
i.role_size,
|
||||
i.role_null);
|
||||
}
|
||||
|
||||
// persistent
|
||||
//
|
||||
{
|
||||
bool& v =
|
||||
o.persistent;
|
||||
|
||||
pgsql::value_traits<
|
||||
bool,
|
||||
pgsql::id_boolean >::set_value (
|
||||
v,
|
||||
i.persistent_value,
|
||||
i.persistent_null);
|
||||
}
|
||||
|
||||
// displayName
|
||||
//
|
||||
{
|
||||
::std::string& v =
|
||||
o.displayName;
|
||||
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::set_value (
|
||||
v,
|
||||
i.displayName_value,
|
||||
i.displayName_size,
|
||||
i.displayName_null);
|
||||
}
|
||||
|
||||
// trustScore
|
||||
//
|
||||
{
|
||||
::int32_t& v =
|
||||
o.trustScore;
|
||||
|
||||
pgsql::value_traits<
|
||||
::int32_t,
|
||||
pgsql::id_integer >::set_value (
|
||||
v,
|
||||
i.trustScore_value,
|
||||
i.trustScore_null);
|
||||
}
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
init (id_image_type& i, const id_type& id)
|
||||
{
|
||||
bool grew (false);
|
||||
{
|
||||
bool is_null (false);
|
||||
std::size_t size (0);
|
||||
std::size_t cap (i.id_value.capacity ());
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::set_image (
|
||||
i.id_value,
|
||||
size,
|
||||
is_null,
|
||||
id);
|
||||
i.id_null = is_null;
|
||||
i.id_size = size;
|
||||
grew = grew || (cap != i.id_value.capacity ());
|
||||
}
|
||||
|
||||
if (grew)
|
||||
i.version++;
|
||||
}
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_pgsql >::persist_statement[] =
|
||||
"INSERT INTO \"Agent\" "
|
||||
"(\"id\", "
|
||||
"\"role\", "
|
||||
"\"persistent\", "
|
||||
"\"displayName\", "
|
||||
"\"trustScore\") "
|
||||
"VALUES "
|
||||
"($1, $2, $3, $4, $5)";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_pgsql >::find_statement[] =
|
||||
"SELECT "
|
||||
"\"Agent\".\"id\", "
|
||||
"\"Agent\".\"role\", "
|
||||
"\"Agent\".\"persistent\", "
|
||||
"\"Agent\".\"displayName\", "
|
||||
"\"Agent\".\"trustScore\" "
|
||||
"FROM \"Agent\" "
|
||||
"WHERE \"Agent\".\"id\"=$1";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_pgsql >::update_statement[] =
|
||||
"UPDATE \"Agent\" "
|
||||
"SET "
|
||||
"\"role\"=$1, "
|
||||
"\"persistent\"=$2, "
|
||||
"\"displayName\"=$3, "
|
||||
"\"trustScore\"=$4 "
|
||||
"WHERE \"id\"=$5";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_pgsql >::erase_statement[] =
|
||||
"DELETE FROM \"Agent\" "
|
||||
"WHERE \"id\"=$1";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_pgsql >::query_statement[] =
|
||||
"SELECT "
|
||||
"\"Agent\".\"id\", "
|
||||
"\"Agent\".\"role\", "
|
||||
"\"Agent\".\"persistent\", "
|
||||
"\"Agent\".\"displayName\", "
|
||||
"\"Agent\".\"trustScore\" "
|
||||
"FROM \"Agent\"";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_pgsql >::erase_query_statement[] =
|
||||
"DELETE FROM \"Agent\"";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_pgsql >::table_name[] =
|
||||
"\"Agent\"";
|
||||
|
||||
void access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
persist (database& db, const object_type& obj)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
using namespace pgsql;
|
||||
|
||||
pgsql::connection& conn (
|
||||
pgsql::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
callback (db,
|
||||
obj,
|
||||
callback_event::pre_persist);
|
||||
|
||||
image_type& im (sts.image ());
|
||||
binding& imb (sts.insert_image_binding ());
|
||||
|
||||
if (init (im, obj, statement_insert))
|
||||
im.version++;
|
||||
|
||||
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 ();
|
||||
|
||||
callback (db,
|
||||
obj,
|
||||
callback_event::post_persist);
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
update (database& db, const object_type& obj)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
using namespace pgsql;
|
||||
using pgsql::update_statement;
|
||||
|
||||
callback (db, obj, callback_event::pre_update);
|
||||
|
||||
pgsql::transaction& tr (pgsql::transaction::current ());
|
||||
pgsql::connection& conn (tr.connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
const id_type& id (
|
||||
obj.id);
|
||||
id_image_type& idi (sts.id_image ());
|
||||
init (idi, id);
|
||||
|
||||
image_type& im (sts.image ());
|
||||
if (init (im, obj, statement_update))
|
||||
im.version++;
|
||||
|
||||
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< ::models::Agent, id_pgsql >::
|
||||
erase (database& db, const id_type& id)
|
||||
{
|
||||
using namespace pgsql;
|
||||
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
pgsql::connection& conn (
|
||||
pgsql::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
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< ::models::Agent, id_pgsql >::pointer_type
|
||||
access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
find (database& db, const id_type& id)
|
||||
{
|
||||
using namespace pgsql;
|
||||
|
||||
{
|
||||
pointer_type p (pointer_cache_traits::find (db, id));
|
||||
|
||||
if (!pointer_traits::null_ptr (p))
|
||||
return p;
|
||||
}
|
||||
|
||||
pgsql::connection& conn (
|
||||
pgsql::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
statements_type::auto_lock l (sts);
|
||||
|
||||
if (l.locked ())
|
||||
{
|
||||
if (!find_ (sts, &id))
|
||||
return pointer_type ();
|
||||
}
|
||||
|
||||
pointer_type p (
|
||||
access::object_factory<object_type, pointer_type>::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);
|
||||
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< ::models::Agent, id_pgsql >::
|
||||
find (database& db, const id_type& id, object_type& obj)
|
||||
{
|
||||
using namespace pgsql;
|
||||
|
||||
pgsql::connection& conn (
|
||||
pgsql::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
statements_type::auto_lock l (sts);
|
||||
|
||||
if (!find_ (sts, &id))
|
||||
return false;
|
||||
|
||||
select_statement& st (sts.find_statement ());
|
||||
ODB_POTENTIALLY_UNUSED (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);
|
||||
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< ::models::Agent, id_pgsql >::
|
||||
reload (database& db, object_type& obj)
|
||||
{
|
||||
using namespace pgsql;
|
||||
|
||||
pgsql::connection& conn (
|
||||
pgsql::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
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);
|
||||
|
||||
callback (db, obj, callback_event::pre_load);
|
||||
init (obj, sts.image (), &db);
|
||||
load_ (sts, obj, true);
|
||||
sts.load_delayed (0);
|
||||
l.unlock ();
|
||||
callback (db, obj, callback_event::post_load);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
find_ (statements_type& sts,
|
||||
const id_type* id)
|
||||
{
|
||||
using namespace pgsql;
|
||||
|
||||
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::truncated)
|
||||
{
|
||||
if (grow (im, sts.select_image_truncated ()))
|
||||
im.version++;
|
||||
|
||||
if (im.version != sts.select_image_version ())
|
||||
{
|
||||
bind (imb.bind, im, statement_select);
|
||||
sts.select_image_version (im.version);
|
||||
imb.version++;
|
||||
st.refetch ();
|
||||
}
|
||||
}
|
||||
|
||||
return r != select_statement::no_data;
|
||||
}
|
||||
|
||||
result< access::object_traits_impl< ::models::Agent, id_pgsql >::object_type >
|
||||
access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
query (database&, const query_base_type& q)
|
||||
{
|
||||
using namespace pgsql;
|
||||
using odb::details::shared;
|
||||
using odb::details::shared_ptr;
|
||||
|
||||
pgsql::connection& conn (
|
||||
pgsql::transaction::current ().connection ());
|
||||
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
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++;
|
||||
}
|
||||
|
||||
std::string text (query_statement);
|
||||
if (!q.empty ())
|
||||
{
|
||||
text += " ";
|
||||
text += q.clause ();
|
||||
}
|
||||
|
||||
q.init_parameters ();
|
||||
shared_ptr<select_statement> st (
|
||||
new (shared) select_statement (
|
||||
sts.connection (),
|
||||
query_statement_name,
|
||||
text,
|
||||
false,
|
||||
true,
|
||||
q.parameter_types (),
|
||||
q.parameter_count (),
|
||||
q.parameters_binding (),
|
||||
imb));
|
||||
|
||||
st->execute ();
|
||||
st->deallocate ();
|
||||
|
||||
shared_ptr< odb::object_result_impl<object_type> > r (
|
||||
new (shared) pgsql::object_result_impl<object_type> (
|
||||
q, st, sts, 0));
|
||||
|
||||
return result<object_type> (r);
|
||||
}
|
||||
|
||||
unsigned long long access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
erase_query (database&, const query_base_type& q)
|
||||
{
|
||||
using namespace pgsql;
|
||||
|
||||
pgsql::connection& conn (
|
||||
pgsql::transaction::current ().connection ());
|
||||
|
||||
std::string text (erase_query_statement);
|
||||
if (!q.empty ())
|
||||
{
|
||||
text += ' ';
|
||||
text += q.clause ();
|
||||
}
|
||||
|
||||
q.init_parameters ();
|
||||
delete_statement st (
|
||||
conn,
|
||||
erase_query_statement_name,
|
||||
text,
|
||||
q.parameter_types (),
|
||||
q.parameter_count (),
|
||||
q.parameters_binding ());
|
||||
|
||||
return st.execute ();
|
||||
}
|
||||
}
|
||||
|
||||
#include <odb/post.hxx>
|
||||
353
db/test-schema-v1.2/generated-odb-source/postgre/Agent-odb.hxx
Normal file
353
db/test-schema-v1.2/generated-odb-source/postgre/Agent-odb.hxx
Normal file
@@ -0,0 +1,353 @@
|
||||
// This file was generated by ODB, object-relational mapping (ORM)
|
||||
// compiler for C++.
|
||||
//
|
||||
|
||||
#ifndef AGENT_ODB_HXX
|
||||
#define AGENT_ODB_HXX
|
||||
|
||||
#include <odb/version.hxx>
|
||||
|
||||
#if (ODB_VERSION != 20400UL)
|
||||
#error ODB runtime version mismatch
|
||||
#endif
|
||||
|
||||
#include <odb/pre.hxx>
|
||||
|
||||
#include "Agent.h"
|
||||
|
||||
#include <memory>
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
#include <odb/core.hxx>
|
||||
#include <odb/traits.hxx>
|
||||
#include <odb/callback.hxx>
|
||||
#include <odb/wrapper-traits.hxx>
|
||||
#include <odb/pointer-traits.hxx>
|
||||
#include <odb/container-traits.hxx>
|
||||
#include <odb/no-op-cache-traits.hxx>
|
||||
#include <odb/result.hxx>
|
||||
#include <odb/simple-object-result.hxx>
|
||||
|
||||
#include <odb/details/unused.hxx>
|
||||
#include <odb/details/shared-ptr.hxx>
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// Agent
|
||||
//
|
||||
template <>
|
||||
struct class_traits< ::models::Agent >
|
||||
{
|
||||
static const class_kind kind = class_object;
|
||||
};
|
||||
|
||||
template <>
|
||||
class access::object_traits< ::models::Agent >
|
||||
{
|
||||
public:
|
||||
typedef ::models::Agent object_type;
|
||||
typedef ::models::Agent* pointer_type;
|
||||
typedef odb::pointer_traits<pointer_type> pointer_traits;
|
||||
|
||||
static const bool polymorphic = false;
|
||||
|
||||
typedef ::std::string id_type;
|
||||
|
||||
static const bool auto_id = false;
|
||||
|
||||
static const bool abstract = false;
|
||||
|
||||
static id_type
|
||||
id (const object_type&);
|
||||
|
||||
typedef
|
||||
no_op_pointer_cache_traits<pointer_type>
|
||||
pointer_cache_traits;
|
||||
|
||||
typedef
|
||||
no_op_reference_cache_traits<object_type>
|
||||
reference_cache_traits;
|
||||
|
||||
static void
|
||||
callback (database&, object_type&, callback_event);
|
||||
|
||||
static void
|
||||
callback (database&, const object_type&, callback_event);
|
||||
};
|
||||
}
|
||||
|
||||
#include <odb/details/buffer.hxx>
|
||||
|
||||
#include <odb/pgsql/version.hxx>
|
||||
#include <odb/pgsql/forward.hxx>
|
||||
#include <odb/pgsql/binding.hxx>
|
||||
#include <odb/pgsql/pgsql-types.hxx>
|
||||
#include <odb/pgsql/query.hxx>
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// Agent
|
||||
//
|
||||
template <typename A>
|
||||
struct query_columns< ::models::Agent, id_pgsql, A >
|
||||
{
|
||||
// id
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
id_type_;
|
||||
|
||||
static const id_type_ id;
|
||||
|
||||
// role
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
role_type_;
|
||||
|
||||
static const role_type_ role;
|
||||
|
||||
// persistent
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
bool,
|
||||
pgsql::id_boolean >::query_type,
|
||||
pgsql::id_boolean >
|
||||
persistent_type_;
|
||||
|
||||
static const persistent_type_ persistent;
|
||||
|
||||
// displayName
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
displayName_type_;
|
||||
|
||||
static const displayName_type_ displayName;
|
||||
|
||||
// trustScore
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::int32_t,
|
||||
pgsql::id_integer >::query_type,
|
||||
pgsql::id_integer >
|
||||
trustScore_type_;
|
||||
|
||||
static const trustScore_type_ trustScore;
|
||||
};
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::Agent, id_pgsql, A >::id_type_
|
||||
query_columns< ::models::Agent, id_pgsql, A >::
|
||||
id (A::table_name, "\"id\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::Agent, id_pgsql, A >::role_type_
|
||||
query_columns< ::models::Agent, id_pgsql, A >::
|
||||
role (A::table_name, "\"role\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::Agent, id_pgsql, A >::persistent_type_
|
||||
query_columns< ::models::Agent, id_pgsql, A >::
|
||||
persistent (A::table_name, "\"persistent\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::Agent, id_pgsql, A >::displayName_type_
|
||||
query_columns< ::models::Agent, id_pgsql, A >::
|
||||
displayName (A::table_name, "\"displayName\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::Agent, id_pgsql, A >::trustScore_type_
|
||||
query_columns< ::models::Agent, id_pgsql, A >::
|
||||
trustScore (A::table_name, "\"trustScore\"", 0);
|
||||
|
||||
template <typename A>
|
||||
struct pointer_query_columns< ::models::Agent, id_pgsql, A >:
|
||||
query_columns< ::models::Agent, id_pgsql, A >
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
class access::object_traits_impl< ::models::Agent, id_pgsql >:
|
||||
public access::object_traits< ::models::Agent >
|
||||
{
|
||||
public:
|
||||
struct id_image_type
|
||||
{
|
||||
details::buffer id_value;
|
||||
std::size_t id_size;
|
||||
bool id_null;
|
||||
|
||||
std::size_t version;
|
||||
};
|
||||
|
||||
struct image_type
|
||||
{
|
||||
// id
|
||||
//
|
||||
details::buffer id_value;
|
||||
std::size_t id_size;
|
||||
bool id_null;
|
||||
|
||||
// role
|
||||
//
|
||||
details::buffer role_value;
|
||||
std::size_t role_size;
|
||||
bool role_null;
|
||||
|
||||
// persistent
|
||||
//
|
||||
bool persistent_value;
|
||||
bool persistent_null;
|
||||
|
||||
// displayName
|
||||
//
|
||||
details::buffer displayName_value;
|
||||
std::size_t displayName_size;
|
||||
bool displayName_null;
|
||||
|
||||
// trustScore
|
||||
//
|
||||
int trustScore_value;
|
||||
bool trustScore_null;
|
||||
|
||||
std::size_t version;
|
||||
};
|
||||
|
||||
struct extra_statement_cache_type;
|
||||
|
||||
using object_traits<object_type>::id;
|
||||
|
||||
static id_type
|
||||
id (const image_type&);
|
||||
|
||||
static bool
|
||||
grow (image_type&,
|
||||
bool*);
|
||||
|
||||
static void
|
||||
bind (pgsql::bind*,
|
||||
image_type&,
|
||||
pgsql::statement_kind);
|
||||
|
||||
static void
|
||||
bind (pgsql::bind*, id_image_type&);
|
||||
|
||||
static bool
|
||||
init (image_type&,
|
||||
const object_type&,
|
||||
pgsql::statement_kind);
|
||||
|
||||
static void
|
||||
init (object_type&,
|
||||
const image_type&,
|
||||
database*);
|
||||
|
||||
static void
|
||||
init (id_image_type&, const id_type&);
|
||||
|
||||
typedef pgsql::object_statements<object_type> statements_type;
|
||||
|
||||
typedef pgsql::query_base query_base_type;
|
||||
|
||||
static const std::size_t column_count = 5UL;
|
||||
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 const char query_statement[];
|
||||
static const char erase_query_statement[];
|
||||
|
||||
static const char table_name[];
|
||||
|
||||
static void
|
||||
persist (database&, const 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&);
|
||||
|
||||
static result<object_type>
|
||||
query (database&, const query_base_type&);
|
||||
|
||||
static unsigned long long
|
||||
erase_query (database&, const query_base_type&);
|
||||
|
||||
static const char persist_statement_name[];
|
||||
static const char find_statement_name[];
|
||||
static const char update_statement_name[];
|
||||
static const char erase_statement_name[];
|
||||
static const char query_statement_name[];
|
||||
static const char erase_query_statement_name[];
|
||||
|
||||
static const unsigned int persist_statement_types[];
|
||||
static const unsigned int find_statement_types[];
|
||||
static const unsigned int update_statement_types[];
|
||||
|
||||
public:
|
||||
static bool
|
||||
find_ (statements_type&,
|
||||
const id_type*);
|
||||
|
||||
static void
|
||||
load_ (statements_type&,
|
||||
object_type&,
|
||||
bool reload);
|
||||
};
|
||||
|
||||
template <>
|
||||
class access::object_traits_impl< ::models::Agent, id_common >:
|
||||
public access::object_traits_impl< ::models::Agent, id_pgsql >
|
||||
{
|
||||
};
|
||||
|
||||
// Agent
|
||||
//
|
||||
}
|
||||
|
||||
#include "Agent-odb.ixx"
|
||||
|
||||
#include <odb/post.hxx>
|
||||
|
||||
#endif // AGENT_ODB_HXX
|
||||
@@ -0,0 +1,61 @@
|
||||
// This file was generated by ODB, object-relational mapping (ORM)
|
||||
// compiler for C++.
|
||||
//
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// Agent
|
||||
//
|
||||
|
||||
inline
|
||||
access::object_traits< ::models::Agent >::id_type
|
||||
access::object_traits< ::models::Agent >::
|
||||
id (const object_type& o)
|
||||
{
|
||||
return o.id;
|
||||
}
|
||||
|
||||
inline
|
||||
void access::object_traits< ::models::Agent >::
|
||||
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< ::models::Agent >::
|
||||
callback (database& db, const object_type& x, callback_event e)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
ODB_POTENTIALLY_UNUSED (x);
|
||||
ODB_POTENTIALLY_UNUSED (e);
|
||||
}
|
||||
}
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// Agent
|
||||
//
|
||||
|
||||
inline
|
||||
void access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
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< ::models::Agent, id_pgsql >::
|
||||
load_ (statements_type& sts,
|
||||
object_type& obj,
|
||||
bool)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (sts);
|
||||
ODB_POTENTIALLY_UNUSED (obj);
|
||||
}
|
||||
}
|
||||
|
||||
16
db/test-schema-v1.2/generated-odb-source/postgre/Agent.xml
Normal file
16
db/test-schema-v1.2/generated-odb-source/postgre/Agent.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" database="pgsql" version="1">
|
||||
<changeset version="2">
|
||||
<add-table name="Agent" kind="object">
|
||||
<column name="id" type="TEXT" null="false"/>
|
||||
<column name="role" type="TEXT" null="false"/>
|
||||
<column name="persistent" type="BOOLEAN" null="false"/>
|
||||
<column name="displayName" type="TEXT" null="false"/>
|
||||
<column name="trustScore" type="INTEGER" null="false"/>
|
||||
<primary-key>
|
||||
<column name="id"/>
|
||||
</primary-key>
|
||||
</add-table>
|
||||
</changeset>
|
||||
|
||||
<model version="1"/>
|
||||
</changelog>
|
||||
@@ -0,0 +1,774 @@
|
||||
// This file was generated by ODB, object-relational mapping (ORM)
|
||||
// compiler for C++.
|
||||
//
|
||||
|
||||
#include <odb/pre.hxx>
|
||||
|
||||
#include "GovernmentAddress-odb.hxx"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring> // std::memcpy
|
||||
|
||||
|
||||
#include <odb/pgsql/traits.hxx>
|
||||
#include <odb/pgsql/database.hxx>
|
||||
#include <odb/pgsql/transaction.hxx>
|
||||
#include <odb/pgsql/connection.hxx>
|
||||
#include <odb/pgsql/statement.hxx>
|
||||
#include <odb/pgsql/statement-cache.hxx>
|
||||
#include <odb/pgsql/simple-object-statements.hxx>
|
||||
#include <odb/pgsql/container-statements.hxx>
|
||||
#include <odb/pgsql/exceptions.hxx>
|
||||
#include <odb/pgsql/simple-object-result.hxx>
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// GovernmentAddress
|
||||
//
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
persist_statement_name[] = "persist_models_GovernmentAddress";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
find_statement_name[] = "find_models_GovernmentAddress";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
update_statement_name[] = "update_models_GovernmentAddress";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
erase_statement_name[] = "erase_models_GovernmentAddress";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
query_statement_name[] = "query_models_GovernmentAddress";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
erase_query_statement_name[] = "erase_query_models_GovernmentAddress";
|
||||
|
||||
const unsigned int access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
persist_statement_types[] =
|
||||
{
|
||||
pgsql::text_oid,
|
||||
pgsql::text_oid,
|
||||
pgsql::text_oid
|
||||
};
|
||||
|
||||
const unsigned int access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
find_statement_types[] =
|
||||
{
|
||||
pgsql::text_oid
|
||||
};
|
||||
|
||||
const unsigned int access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
update_statement_types[] =
|
||||
{
|
||||
pgsql::text_oid,
|
||||
pgsql::text_oid,
|
||||
pgsql::text_oid
|
||||
};
|
||||
|
||||
struct access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::extra_statement_cache_type
|
||||
{
|
||||
extra_statement_cache_type (
|
||||
pgsql::connection&,
|
||||
image_type&,
|
||||
id_image_type&,
|
||||
pgsql::binding&,
|
||||
pgsql::binding&,
|
||||
pgsql::native_binding&,
|
||||
const unsigned int*)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::id_type
|
||||
access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
id (const image_type& i)
|
||||
{
|
||||
pgsql::database* db (0);
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
id_type id;
|
||||
{
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::set_value (
|
||||
id,
|
||||
i.id_value,
|
||||
i.id_size,
|
||||
i.id_null);
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
bool access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
grow (image_type& i,
|
||||
bool* t)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (i);
|
||||
ODB_POTENTIALLY_UNUSED (t);
|
||||
|
||||
bool grew (false);
|
||||
|
||||
// id
|
||||
//
|
||||
if (t[0UL])
|
||||
{
|
||||
i.id_value.capacity (i.id_size);
|
||||
grew = true;
|
||||
}
|
||||
|
||||
// addressLabel
|
||||
//
|
||||
if (t[1UL])
|
||||
{
|
||||
i.addressLabel_value.capacity (i.addressLabel_size);
|
||||
grew = true;
|
||||
}
|
||||
|
||||
// regionLookupKey
|
||||
//
|
||||
if (t[2UL])
|
||||
{
|
||||
i.regionLookupKey_value.capacity (i.regionLookupKey_size);
|
||||
grew = true;
|
||||
}
|
||||
|
||||
return grew;
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
bind (pgsql::bind* b,
|
||||
image_type& i,
|
||||
pgsql::statement_kind sk)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (sk);
|
||||
|
||||
using namespace pgsql;
|
||||
|
||||
std::size_t n (0);
|
||||
|
||||
// id
|
||||
//
|
||||
if (sk != statement_update)
|
||||
{
|
||||
b[n].type = pgsql::bind::text;
|
||||
b[n].buffer = i.id_value.data ();
|
||||
b[n].capacity = i.id_value.capacity ();
|
||||
b[n].size = &i.id_size;
|
||||
b[n].is_null = &i.id_null;
|
||||
n++;
|
||||
}
|
||||
|
||||
// addressLabel
|
||||
//
|
||||
b[n].type = pgsql::bind::text;
|
||||
b[n].buffer = i.addressLabel_value.data ();
|
||||
b[n].capacity = i.addressLabel_value.capacity ();
|
||||
b[n].size = &i.addressLabel_size;
|
||||
b[n].is_null = &i.addressLabel_null;
|
||||
n++;
|
||||
|
||||
// regionLookupKey
|
||||
//
|
||||
b[n].type = pgsql::bind::text;
|
||||
b[n].buffer = i.regionLookupKey_value.data ();
|
||||
b[n].capacity = i.regionLookupKey_value.capacity ();
|
||||
b[n].size = &i.regionLookupKey_size;
|
||||
b[n].is_null = &i.regionLookupKey_null;
|
||||
n++;
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
bind (pgsql::bind* b, id_image_type& i)
|
||||
{
|
||||
std::size_t n (0);
|
||||
b[n].type = pgsql::bind::text;
|
||||
b[n].buffer = i.id_value.data ();
|
||||
b[n].capacity = i.id_value.capacity ();
|
||||
b[n].size = &i.id_size;
|
||||
b[n].is_null = &i.id_null;
|
||||
}
|
||||
|
||||
bool access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
init (image_type& i,
|
||||
const object_type& o,
|
||||
pgsql::statement_kind sk)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (i);
|
||||
ODB_POTENTIALLY_UNUSED (o);
|
||||
ODB_POTENTIALLY_UNUSED (sk);
|
||||
|
||||
using namespace pgsql;
|
||||
|
||||
bool grew (false);
|
||||
|
||||
// id
|
||||
//
|
||||
if (sk == statement_insert)
|
||||
{
|
||||
::std::string const& v =
|
||||
o.id;
|
||||
|
||||
bool is_null (false);
|
||||
std::size_t size (0);
|
||||
std::size_t cap (i.id_value.capacity ());
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::set_image (
|
||||
i.id_value,
|
||||
size,
|
||||
is_null,
|
||||
v);
|
||||
i.id_null = is_null;
|
||||
i.id_size = size;
|
||||
grew = grew || (cap != i.id_value.capacity ());
|
||||
}
|
||||
|
||||
// addressLabel
|
||||
//
|
||||
{
|
||||
::std::string const& v =
|
||||
o.addressLabel;
|
||||
|
||||
bool is_null (false);
|
||||
std::size_t size (0);
|
||||
std::size_t cap (i.addressLabel_value.capacity ());
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::set_image (
|
||||
i.addressLabel_value,
|
||||
size,
|
||||
is_null,
|
||||
v);
|
||||
i.addressLabel_null = is_null;
|
||||
i.addressLabel_size = size;
|
||||
grew = grew || (cap != i.addressLabel_value.capacity ());
|
||||
}
|
||||
|
||||
// regionLookupKey
|
||||
//
|
||||
{
|
||||
::std::string const& v =
|
||||
o.regionLookupKey;
|
||||
|
||||
bool is_null (false);
|
||||
std::size_t size (0);
|
||||
std::size_t cap (i.regionLookupKey_value.capacity ());
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::set_image (
|
||||
i.regionLookupKey_value,
|
||||
size,
|
||||
is_null,
|
||||
v);
|
||||
i.regionLookupKey_null = is_null;
|
||||
i.regionLookupKey_size = size;
|
||||
grew = grew || (cap != i.regionLookupKey_value.capacity ());
|
||||
}
|
||||
|
||||
return grew;
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
init (object_type& o,
|
||||
const image_type& i,
|
||||
database* db)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (o);
|
||||
ODB_POTENTIALLY_UNUSED (i);
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
// id
|
||||
//
|
||||
{
|
||||
::std::string& v =
|
||||
o.id;
|
||||
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::set_value (
|
||||
v,
|
||||
i.id_value,
|
||||
i.id_size,
|
||||
i.id_null);
|
||||
}
|
||||
|
||||
// addressLabel
|
||||
//
|
||||
{
|
||||
::std::string& v =
|
||||
o.addressLabel;
|
||||
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::set_value (
|
||||
v,
|
||||
i.addressLabel_value,
|
||||
i.addressLabel_size,
|
||||
i.addressLabel_null);
|
||||
}
|
||||
|
||||
// regionLookupKey
|
||||
//
|
||||
{
|
||||
::std::string& v =
|
||||
o.regionLookupKey;
|
||||
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::set_value (
|
||||
v,
|
||||
i.regionLookupKey_value,
|
||||
i.regionLookupKey_size,
|
||||
i.regionLookupKey_null);
|
||||
}
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
init (id_image_type& i, const id_type& id)
|
||||
{
|
||||
bool grew (false);
|
||||
{
|
||||
bool is_null (false);
|
||||
std::size_t size (0);
|
||||
std::size_t cap (i.id_value.capacity ());
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::set_image (
|
||||
i.id_value,
|
||||
size,
|
||||
is_null,
|
||||
id);
|
||||
i.id_null = is_null;
|
||||
i.id_size = size;
|
||||
grew = grew || (cap != i.id_value.capacity ());
|
||||
}
|
||||
|
||||
if (grew)
|
||||
i.version++;
|
||||
}
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::persist_statement[] =
|
||||
"INSERT INTO \"GovernmentAddress\" "
|
||||
"(\"id\", "
|
||||
"\"addressLabel\", "
|
||||
"\"regionLookupKey\") "
|
||||
"VALUES "
|
||||
"($1, $2, $3)";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::find_statement[] =
|
||||
"SELECT "
|
||||
"\"GovernmentAddress\".\"id\", "
|
||||
"\"GovernmentAddress\".\"addressLabel\", "
|
||||
"\"GovernmentAddress\".\"regionLookupKey\" "
|
||||
"FROM \"GovernmentAddress\" "
|
||||
"WHERE \"GovernmentAddress\".\"id\"=$1";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::update_statement[] =
|
||||
"UPDATE \"GovernmentAddress\" "
|
||||
"SET "
|
||||
"\"addressLabel\"=$1, "
|
||||
"\"regionLookupKey\"=$2 "
|
||||
"WHERE \"id\"=$3";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::erase_statement[] =
|
||||
"DELETE FROM \"GovernmentAddress\" "
|
||||
"WHERE \"id\"=$1";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::query_statement[] =
|
||||
"SELECT "
|
||||
"\"GovernmentAddress\".\"id\", "
|
||||
"\"GovernmentAddress\".\"addressLabel\", "
|
||||
"\"GovernmentAddress\".\"regionLookupKey\" "
|
||||
"FROM \"GovernmentAddress\"";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::erase_query_statement[] =
|
||||
"DELETE FROM \"GovernmentAddress\"";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::table_name[] =
|
||||
"\"GovernmentAddress\"";
|
||||
|
||||
void access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
persist (database& db, const object_type& obj)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
using namespace pgsql;
|
||||
|
||||
pgsql::connection& conn (
|
||||
pgsql::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
callback (db,
|
||||
obj,
|
||||
callback_event::pre_persist);
|
||||
|
||||
image_type& im (sts.image ());
|
||||
binding& imb (sts.insert_image_binding ());
|
||||
|
||||
if (init (im, obj, statement_insert))
|
||||
im.version++;
|
||||
|
||||
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 ();
|
||||
|
||||
callback (db,
|
||||
obj,
|
||||
callback_event::post_persist);
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
update (database& db, const object_type& obj)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
using namespace pgsql;
|
||||
using pgsql::update_statement;
|
||||
|
||||
callback (db, obj, callback_event::pre_update);
|
||||
|
||||
pgsql::transaction& tr (pgsql::transaction::current ());
|
||||
pgsql::connection& conn (tr.connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
const id_type& id (
|
||||
obj.id);
|
||||
id_image_type& idi (sts.id_image ());
|
||||
init (idi, id);
|
||||
|
||||
image_type& im (sts.image ());
|
||||
if (init (im, obj, statement_update))
|
||||
im.version++;
|
||||
|
||||
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< ::models::GovernmentAddress, id_pgsql >::
|
||||
erase (database& db, const id_type& id)
|
||||
{
|
||||
using namespace pgsql;
|
||||
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
pgsql::connection& conn (
|
||||
pgsql::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
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< ::models::GovernmentAddress, id_pgsql >::pointer_type
|
||||
access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
find (database& db, const id_type& id)
|
||||
{
|
||||
using namespace pgsql;
|
||||
|
||||
{
|
||||
pointer_type p (pointer_cache_traits::find (db, id));
|
||||
|
||||
if (!pointer_traits::null_ptr (p))
|
||||
return p;
|
||||
}
|
||||
|
||||
pgsql::connection& conn (
|
||||
pgsql::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
statements_type::auto_lock l (sts);
|
||||
|
||||
if (l.locked ())
|
||||
{
|
||||
if (!find_ (sts, &id))
|
||||
return pointer_type ();
|
||||
}
|
||||
|
||||
pointer_type p (
|
||||
access::object_factory<object_type, pointer_type>::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);
|
||||
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< ::models::GovernmentAddress, id_pgsql >::
|
||||
find (database& db, const id_type& id, object_type& obj)
|
||||
{
|
||||
using namespace pgsql;
|
||||
|
||||
pgsql::connection& conn (
|
||||
pgsql::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
statements_type::auto_lock l (sts);
|
||||
|
||||
if (!find_ (sts, &id))
|
||||
return false;
|
||||
|
||||
select_statement& st (sts.find_statement ());
|
||||
ODB_POTENTIALLY_UNUSED (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);
|
||||
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< ::models::GovernmentAddress, id_pgsql >::
|
||||
reload (database& db, object_type& obj)
|
||||
{
|
||||
using namespace pgsql;
|
||||
|
||||
pgsql::connection& conn (
|
||||
pgsql::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
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);
|
||||
|
||||
callback (db, obj, callback_event::pre_load);
|
||||
init (obj, sts.image (), &db);
|
||||
load_ (sts, obj, true);
|
||||
sts.load_delayed (0);
|
||||
l.unlock ();
|
||||
callback (db, obj, callback_event::post_load);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
find_ (statements_type& sts,
|
||||
const id_type* id)
|
||||
{
|
||||
using namespace pgsql;
|
||||
|
||||
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::truncated)
|
||||
{
|
||||
if (grow (im, sts.select_image_truncated ()))
|
||||
im.version++;
|
||||
|
||||
if (im.version != sts.select_image_version ())
|
||||
{
|
||||
bind (imb.bind, im, statement_select);
|
||||
sts.select_image_version (im.version);
|
||||
imb.version++;
|
||||
st.refetch ();
|
||||
}
|
||||
}
|
||||
|
||||
return r != select_statement::no_data;
|
||||
}
|
||||
|
||||
result< access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::object_type >
|
||||
access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
query (database&, const query_base_type& q)
|
||||
{
|
||||
using namespace pgsql;
|
||||
using odb::details::shared;
|
||||
using odb::details::shared_ptr;
|
||||
|
||||
pgsql::connection& conn (
|
||||
pgsql::transaction::current ().connection ());
|
||||
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
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++;
|
||||
}
|
||||
|
||||
std::string text (query_statement);
|
||||
if (!q.empty ())
|
||||
{
|
||||
text += " ";
|
||||
text += q.clause ();
|
||||
}
|
||||
|
||||
q.init_parameters ();
|
||||
shared_ptr<select_statement> st (
|
||||
new (shared) select_statement (
|
||||
sts.connection (),
|
||||
query_statement_name,
|
||||
text,
|
||||
false,
|
||||
true,
|
||||
q.parameter_types (),
|
||||
q.parameter_count (),
|
||||
q.parameters_binding (),
|
||||
imb));
|
||||
|
||||
st->execute ();
|
||||
st->deallocate ();
|
||||
|
||||
shared_ptr< odb::object_result_impl<object_type> > r (
|
||||
new (shared) pgsql::object_result_impl<object_type> (
|
||||
q, st, sts, 0));
|
||||
|
||||
return result<object_type> (r);
|
||||
}
|
||||
|
||||
unsigned long long access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
erase_query (database&, const query_base_type& q)
|
||||
{
|
||||
using namespace pgsql;
|
||||
|
||||
pgsql::connection& conn (
|
||||
pgsql::transaction::current ().connection ());
|
||||
|
||||
std::string text (erase_query_statement);
|
||||
if (!q.empty ())
|
||||
{
|
||||
text += ' ';
|
||||
text += q.clause ();
|
||||
}
|
||||
|
||||
q.init_parameters ();
|
||||
delete_statement st (
|
||||
conn,
|
||||
erase_query_statement_name,
|
||||
text,
|
||||
q.parameter_types (),
|
||||
q.parameter_count (),
|
||||
q.parameters_binding ());
|
||||
|
||||
return st.execute ();
|
||||
}
|
||||
}
|
||||
|
||||
#include <odb/post.hxx>
|
||||
@@ -0,0 +1,309 @@
|
||||
// This file was generated by ODB, object-relational mapping (ORM)
|
||||
// compiler for C++.
|
||||
//
|
||||
|
||||
#ifndef GOVERNMENT_ADDRESS_ODB_HXX
|
||||
#define GOVERNMENT_ADDRESS_ODB_HXX
|
||||
|
||||
#include <odb/version.hxx>
|
||||
|
||||
#if (ODB_VERSION != 20400UL)
|
||||
#error ODB runtime version mismatch
|
||||
#endif
|
||||
|
||||
#include <odb/pre.hxx>
|
||||
|
||||
#include "GovernmentAddress.h"
|
||||
|
||||
#include <memory>
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
#include <odb/core.hxx>
|
||||
#include <odb/traits.hxx>
|
||||
#include <odb/callback.hxx>
|
||||
#include <odb/wrapper-traits.hxx>
|
||||
#include <odb/pointer-traits.hxx>
|
||||
#include <odb/container-traits.hxx>
|
||||
#include <odb/no-op-cache-traits.hxx>
|
||||
#include <odb/result.hxx>
|
||||
#include <odb/simple-object-result.hxx>
|
||||
|
||||
#include <odb/details/unused.hxx>
|
||||
#include <odb/details/shared-ptr.hxx>
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// GovernmentAddress
|
||||
//
|
||||
template <>
|
||||
struct class_traits< ::models::GovernmentAddress >
|
||||
{
|
||||
static const class_kind kind = class_object;
|
||||
};
|
||||
|
||||
template <>
|
||||
class access::object_traits< ::models::GovernmentAddress >
|
||||
{
|
||||
public:
|
||||
typedef ::models::GovernmentAddress object_type;
|
||||
typedef ::models::GovernmentAddress* pointer_type;
|
||||
typedef odb::pointer_traits<pointer_type> pointer_traits;
|
||||
|
||||
static const bool polymorphic = false;
|
||||
|
||||
typedef ::std::string id_type;
|
||||
|
||||
static const bool auto_id = false;
|
||||
|
||||
static const bool abstract = false;
|
||||
|
||||
static id_type
|
||||
id (const object_type&);
|
||||
|
||||
typedef
|
||||
no_op_pointer_cache_traits<pointer_type>
|
||||
pointer_cache_traits;
|
||||
|
||||
typedef
|
||||
no_op_reference_cache_traits<object_type>
|
||||
reference_cache_traits;
|
||||
|
||||
static void
|
||||
callback (database&, object_type&, callback_event);
|
||||
|
||||
static void
|
||||
callback (database&, const object_type&, callback_event);
|
||||
};
|
||||
}
|
||||
|
||||
#include <odb/details/buffer.hxx>
|
||||
|
||||
#include <odb/pgsql/version.hxx>
|
||||
#include <odb/pgsql/forward.hxx>
|
||||
#include <odb/pgsql/binding.hxx>
|
||||
#include <odb/pgsql/pgsql-types.hxx>
|
||||
#include <odb/pgsql/query.hxx>
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// GovernmentAddress
|
||||
//
|
||||
template <typename A>
|
||||
struct query_columns< ::models::GovernmentAddress, id_pgsql, A >
|
||||
{
|
||||
// id
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
id_type_;
|
||||
|
||||
static const id_type_ id;
|
||||
|
||||
// addressLabel
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
addressLabel_type_;
|
||||
|
||||
static const addressLabel_type_ addressLabel;
|
||||
|
||||
// regionLookupKey
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
regionLookupKey_type_;
|
||||
|
||||
static const regionLookupKey_type_ regionLookupKey;
|
||||
};
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::GovernmentAddress, id_pgsql, A >::id_type_
|
||||
query_columns< ::models::GovernmentAddress, id_pgsql, A >::
|
||||
id (A::table_name, "\"id\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::GovernmentAddress, id_pgsql, A >::addressLabel_type_
|
||||
query_columns< ::models::GovernmentAddress, id_pgsql, A >::
|
||||
addressLabel (A::table_name, "\"addressLabel\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::GovernmentAddress, id_pgsql, A >::regionLookupKey_type_
|
||||
query_columns< ::models::GovernmentAddress, id_pgsql, A >::
|
||||
regionLookupKey (A::table_name, "\"regionLookupKey\"", 0);
|
||||
|
||||
template <typename A>
|
||||
struct pointer_query_columns< ::models::GovernmentAddress, id_pgsql, A >:
|
||||
query_columns< ::models::GovernmentAddress, id_pgsql, A >
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
class access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >:
|
||||
public access::object_traits< ::models::GovernmentAddress >
|
||||
{
|
||||
public:
|
||||
struct id_image_type
|
||||
{
|
||||
details::buffer id_value;
|
||||
std::size_t id_size;
|
||||
bool id_null;
|
||||
|
||||
std::size_t version;
|
||||
};
|
||||
|
||||
struct image_type
|
||||
{
|
||||
// id
|
||||
//
|
||||
details::buffer id_value;
|
||||
std::size_t id_size;
|
||||
bool id_null;
|
||||
|
||||
// addressLabel
|
||||
//
|
||||
details::buffer addressLabel_value;
|
||||
std::size_t addressLabel_size;
|
||||
bool addressLabel_null;
|
||||
|
||||
// regionLookupKey
|
||||
//
|
||||
details::buffer regionLookupKey_value;
|
||||
std::size_t regionLookupKey_size;
|
||||
bool regionLookupKey_null;
|
||||
|
||||
std::size_t version;
|
||||
};
|
||||
|
||||
struct extra_statement_cache_type;
|
||||
|
||||
using object_traits<object_type>::id;
|
||||
|
||||
static id_type
|
||||
id (const image_type&);
|
||||
|
||||
static bool
|
||||
grow (image_type&,
|
||||
bool*);
|
||||
|
||||
static void
|
||||
bind (pgsql::bind*,
|
||||
image_type&,
|
||||
pgsql::statement_kind);
|
||||
|
||||
static void
|
||||
bind (pgsql::bind*, id_image_type&);
|
||||
|
||||
static bool
|
||||
init (image_type&,
|
||||
const object_type&,
|
||||
pgsql::statement_kind);
|
||||
|
||||
static void
|
||||
init (object_type&,
|
||||
const image_type&,
|
||||
database*);
|
||||
|
||||
static void
|
||||
init (id_image_type&, const id_type&);
|
||||
|
||||
typedef pgsql::object_statements<object_type> statements_type;
|
||||
|
||||
typedef pgsql::query_base query_base_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 const char query_statement[];
|
||||
static const char erase_query_statement[];
|
||||
|
||||
static const char table_name[];
|
||||
|
||||
static void
|
||||
persist (database&, const 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&);
|
||||
|
||||
static result<object_type>
|
||||
query (database&, const query_base_type&);
|
||||
|
||||
static unsigned long long
|
||||
erase_query (database&, const query_base_type&);
|
||||
|
||||
static const char persist_statement_name[];
|
||||
static const char find_statement_name[];
|
||||
static const char update_statement_name[];
|
||||
static const char erase_statement_name[];
|
||||
static const char query_statement_name[];
|
||||
static const char erase_query_statement_name[];
|
||||
|
||||
static const unsigned int persist_statement_types[];
|
||||
static const unsigned int find_statement_types[];
|
||||
static const unsigned int update_statement_types[];
|
||||
|
||||
public:
|
||||
static bool
|
||||
find_ (statements_type&,
|
||||
const id_type*);
|
||||
|
||||
static void
|
||||
load_ (statements_type&,
|
||||
object_type&,
|
||||
bool reload);
|
||||
};
|
||||
|
||||
template <>
|
||||
class access::object_traits_impl< ::models::GovernmentAddress, id_common >:
|
||||
public access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >
|
||||
{
|
||||
};
|
||||
|
||||
// GovernmentAddress
|
||||
//
|
||||
}
|
||||
|
||||
#include "GovernmentAddress-odb.ixx"
|
||||
|
||||
#include <odb/post.hxx>
|
||||
|
||||
#endif // GOVERNMENT_ADDRESS_ODB_HXX
|
||||
@@ -0,0 +1,61 @@
|
||||
// This file was generated by ODB, object-relational mapping (ORM)
|
||||
// compiler for C++.
|
||||
//
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// GovernmentAddress
|
||||
//
|
||||
|
||||
inline
|
||||
access::object_traits< ::models::GovernmentAddress >::id_type
|
||||
access::object_traits< ::models::GovernmentAddress >::
|
||||
id (const object_type& o)
|
||||
{
|
||||
return o.id;
|
||||
}
|
||||
|
||||
inline
|
||||
void access::object_traits< ::models::GovernmentAddress >::
|
||||
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< ::models::GovernmentAddress >::
|
||||
callback (database& db, const object_type& x, callback_event e)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
ODB_POTENTIALLY_UNUSED (x);
|
||||
ODB_POTENTIALLY_UNUSED (e);
|
||||
}
|
||||
}
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// GovernmentAddress
|
||||
//
|
||||
|
||||
inline
|
||||
void access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
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< ::models::GovernmentAddress, id_pgsql >::
|
||||
load_ (statements_type& sts,
|
||||
object_type& obj,
|
||||
bool)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (sts);
|
||||
ODB_POTENTIALLY_UNUSED (obj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" database="pgsql" version="1">
|
||||
<changeset version="2">
|
||||
<add-table name="GovernmentAddress" kind="object">
|
||||
<column name="id" type="TEXT" null="false"/>
|
||||
<column name="addressLabel" type="TEXT" null="false"/>
|
||||
<column name="regionLookupKey" type="TEXT" null="false"/>
|
||||
<primary-key>
|
||||
<column name="id"/>
|
||||
</primary-key>
|
||||
</add-table>
|
||||
</changeset>
|
||||
|
||||
<model version="1"/>
|
||||
</changelog>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,516 @@
|
||||
// This file was generated by ODB, object-relational mapping (ORM)
|
||||
// compiler for C++.
|
||||
//
|
||||
|
||||
#ifndef TRIP_ATTEMPT_RESULT_ODB_HXX
|
||||
#define TRIP_ATTEMPT_RESULT_ODB_HXX
|
||||
|
||||
#include <odb/version.hxx>
|
||||
|
||||
#if (ODB_VERSION != 20400UL)
|
||||
#error ODB runtime version mismatch
|
||||
#endif
|
||||
|
||||
#include <odb/pre.hxx>
|
||||
|
||||
#include "TripAttemptResult.h"
|
||||
|
||||
#include <memory>
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
#include <odb/core.hxx>
|
||||
#include <odb/traits.hxx>
|
||||
#include <odb/callback.hxx>
|
||||
#include <odb/wrapper-traits.hxx>
|
||||
#include <odb/pointer-traits.hxx>
|
||||
#include <odb/container-traits.hxx>
|
||||
#include <odb/no-op-cache-traits.hxx>
|
||||
#include <odb/result.hxx>
|
||||
#include <odb/simple-object-result.hxx>
|
||||
|
||||
#include <odb/details/unused.hxx>
|
||||
#include <odb/details/shared-ptr.hxx>
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// TripAttemptResult
|
||||
//
|
||||
template <>
|
||||
struct class_traits< ::models::TripAttemptResult >
|
||||
{
|
||||
static const class_kind kind = class_object;
|
||||
};
|
||||
|
||||
template <>
|
||||
class access::object_traits< ::models::TripAttemptResult >
|
||||
{
|
||||
public:
|
||||
typedef ::models::TripAttemptResult object_type;
|
||||
typedef ::models::TripAttemptResult* pointer_type;
|
||||
typedef odb::pointer_traits<pointer_type> pointer_traits;
|
||||
|
||||
static const bool polymorphic = false;
|
||||
|
||||
typedef ::std::string id_type;
|
||||
|
||||
static const bool auto_id = false;
|
||||
|
||||
static const bool abstract = false;
|
||||
|
||||
static id_type
|
||||
id (const object_type&);
|
||||
|
||||
typedef
|
||||
no_op_pointer_cache_traits<pointer_type>
|
||||
pointer_cache_traits;
|
||||
|
||||
typedef
|
||||
no_op_reference_cache_traits<object_type>
|
||||
reference_cache_traits;
|
||||
|
||||
static void
|
||||
callback (database&, object_type&, callback_event);
|
||||
|
||||
static void
|
||||
callback (database&, const object_type&, callback_event);
|
||||
};
|
||||
}
|
||||
|
||||
#include <odb/details/buffer.hxx>
|
||||
|
||||
#include <odb/pgsql/version.hxx>
|
||||
#include <odb/pgsql/forward.hxx>
|
||||
#include <odb/pgsql/binding.hxx>
|
||||
#include <odb/pgsql/pgsql-types.hxx>
|
||||
#include <odb/pgsql/query.hxx>
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// TripAttemptResult
|
||||
//
|
||||
template <typename A>
|
||||
struct query_columns< ::models::TripAttemptResult, id_pgsql, A >
|
||||
{
|
||||
// id
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
id_type_;
|
||||
|
||||
static const id_type_ id;
|
||||
|
||||
// result
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
result_type_;
|
||||
|
||||
static const result_type_ result;
|
||||
|
||||
// retryReason
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
retryReason_type_;
|
||||
|
||||
static const retryReason_type_ retryReason;
|
||||
|
||||
// governmentSuspensionReason
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
governmentSuspensionReason_type_;
|
||||
|
||||
static const governmentSuspensionReason_type_ governmentSuspensionReason;
|
||||
|
||||
// governmentTerminationReason
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
governmentTerminationReason_type_;
|
||||
|
||||
static const governmentTerminationReason_type_ governmentTerminationReason;
|
||||
|
||||
// complianceSuspensionReason
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
complianceSuspensionReason_type_;
|
||||
|
||||
static const complianceSuspensionReason_type_ complianceSuspensionReason;
|
||||
|
||||
// complianceTerminationReason
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
complianceTerminationReason_type_;
|
||||
|
||||
static const complianceTerminationReason_type_ complianceTerminationReason;
|
||||
|
||||
// policySuspensionReason
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
policySuspensionReason_type_;
|
||||
|
||||
static const policySuspensionReason_type_ policySuspensionReason;
|
||||
|
||||
// policyTerminationReason
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
policyTerminationReason_type_;
|
||||
|
||||
static const policyTerminationReason_type_ policyTerminationReason;
|
||||
|
||||
// cancelationReason
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
cancelationReason_type_;
|
||||
|
||||
static const cancelationReason_type_ cancelationReason;
|
||||
|
||||
// failureReason
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
failureReason_type_;
|
||||
|
||||
static const failureReason_type_ failureReason;
|
||||
|
||||
// details
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
details_type_;
|
||||
|
||||
static const details_type_ details;
|
||||
};
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_pgsql, A >::id_type_
|
||||
query_columns< ::models::TripAttemptResult, id_pgsql, A >::
|
||||
id (A::table_name, "\"id\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_pgsql, A >::result_type_
|
||||
query_columns< ::models::TripAttemptResult, id_pgsql, A >::
|
||||
result (A::table_name, "\"result\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_pgsql, A >::retryReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_pgsql, A >::
|
||||
retryReason (A::table_name, "\"retryReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_pgsql, A >::governmentSuspensionReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_pgsql, A >::
|
||||
governmentSuspensionReason (A::table_name, "\"governmentSuspensionReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_pgsql, A >::governmentTerminationReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_pgsql, A >::
|
||||
governmentTerminationReason (A::table_name, "\"governmentTerminationReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_pgsql, A >::complianceSuspensionReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_pgsql, A >::
|
||||
complianceSuspensionReason (A::table_name, "\"complianceSuspensionReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_pgsql, A >::complianceTerminationReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_pgsql, A >::
|
||||
complianceTerminationReason (A::table_name, "\"complianceTerminationReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_pgsql, A >::policySuspensionReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_pgsql, A >::
|
||||
policySuspensionReason (A::table_name, "\"policySuspensionReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_pgsql, A >::policyTerminationReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_pgsql, A >::
|
||||
policyTerminationReason (A::table_name, "\"policyTerminationReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_pgsql, A >::cancelationReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_pgsql, A >::
|
||||
cancelationReason (A::table_name, "\"cancelationReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_pgsql, A >::failureReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_pgsql, A >::
|
||||
failureReason (A::table_name, "\"failureReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_pgsql, A >::details_type_
|
||||
query_columns< ::models::TripAttemptResult, id_pgsql, A >::
|
||||
details (A::table_name, "\"details\"", 0);
|
||||
|
||||
template <typename A>
|
||||
struct pointer_query_columns< ::models::TripAttemptResult, id_pgsql, A >:
|
||||
query_columns< ::models::TripAttemptResult, id_pgsql, A >
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
class access::object_traits_impl< ::models::TripAttemptResult, id_pgsql >:
|
||||
public access::object_traits< ::models::TripAttemptResult >
|
||||
{
|
||||
public:
|
||||
struct id_image_type
|
||||
{
|
||||
details::buffer id_value;
|
||||
std::size_t id_size;
|
||||
bool id_null;
|
||||
|
||||
std::size_t version;
|
||||
};
|
||||
|
||||
struct image_type
|
||||
{
|
||||
// id
|
||||
//
|
||||
details::buffer id_value;
|
||||
std::size_t id_size;
|
||||
bool id_null;
|
||||
|
||||
// result
|
||||
//
|
||||
details::buffer result_value;
|
||||
std::size_t result_size;
|
||||
bool result_null;
|
||||
|
||||
// retryReason
|
||||
//
|
||||
details::buffer retryReason_value;
|
||||
std::size_t retryReason_size;
|
||||
bool retryReason_null;
|
||||
|
||||
// governmentSuspensionReason
|
||||
//
|
||||
details::buffer governmentSuspensionReason_value;
|
||||
std::size_t governmentSuspensionReason_size;
|
||||
bool governmentSuspensionReason_null;
|
||||
|
||||
// governmentTerminationReason
|
||||
//
|
||||
details::buffer governmentTerminationReason_value;
|
||||
std::size_t governmentTerminationReason_size;
|
||||
bool governmentTerminationReason_null;
|
||||
|
||||
// complianceSuspensionReason
|
||||
//
|
||||
details::buffer complianceSuspensionReason_value;
|
||||
std::size_t complianceSuspensionReason_size;
|
||||
bool complianceSuspensionReason_null;
|
||||
|
||||
// complianceTerminationReason
|
||||
//
|
||||
details::buffer complianceTerminationReason_value;
|
||||
std::size_t complianceTerminationReason_size;
|
||||
bool complianceTerminationReason_null;
|
||||
|
||||
// policySuspensionReason
|
||||
//
|
||||
details::buffer policySuspensionReason_value;
|
||||
std::size_t policySuspensionReason_size;
|
||||
bool policySuspensionReason_null;
|
||||
|
||||
// policyTerminationReason
|
||||
//
|
||||
details::buffer policyTerminationReason_value;
|
||||
std::size_t policyTerminationReason_size;
|
||||
bool policyTerminationReason_null;
|
||||
|
||||
// cancelationReason
|
||||
//
|
||||
details::buffer cancelationReason_value;
|
||||
std::size_t cancelationReason_size;
|
||||
bool cancelationReason_null;
|
||||
|
||||
// failureReason
|
||||
//
|
||||
details::buffer failureReason_value;
|
||||
std::size_t failureReason_size;
|
||||
bool failureReason_null;
|
||||
|
||||
// details
|
||||
//
|
||||
details::buffer details_value;
|
||||
std::size_t details_size;
|
||||
bool details_null;
|
||||
|
||||
std::size_t version;
|
||||
};
|
||||
|
||||
struct extra_statement_cache_type;
|
||||
|
||||
using object_traits<object_type>::id;
|
||||
|
||||
static id_type
|
||||
id (const image_type&);
|
||||
|
||||
static bool
|
||||
grow (image_type&,
|
||||
bool*);
|
||||
|
||||
static void
|
||||
bind (pgsql::bind*,
|
||||
image_type&,
|
||||
pgsql::statement_kind);
|
||||
|
||||
static void
|
||||
bind (pgsql::bind*, id_image_type&);
|
||||
|
||||
static bool
|
||||
init (image_type&,
|
||||
const object_type&,
|
||||
pgsql::statement_kind);
|
||||
|
||||
static void
|
||||
init (object_type&,
|
||||
const image_type&,
|
||||
database*);
|
||||
|
||||
static void
|
||||
init (id_image_type&, const id_type&);
|
||||
|
||||
typedef pgsql::object_statements<object_type> statements_type;
|
||||
|
||||
typedef pgsql::query_base query_base_type;
|
||||
|
||||
static const std::size_t column_count = 12UL;
|
||||
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 const char query_statement[];
|
||||
static const char erase_query_statement[];
|
||||
|
||||
static const char table_name[];
|
||||
|
||||
static void
|
||||
persist (database&, const 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&);
|
||||
|
||||
static result<object_type>
|
||||
query (database&, const query_base_type&);
|
||||
|
||||
static unsigned long long
|
||||
erase_query (database&, const query_base_type&);
|
||||
|
||||
static const char persist_statement_name[];
|
||||
static const char find_statement_name[];
|
||||
static const char update_statement_name[];
|
||||
static const char erase_statement_name[];
|
||||
static const char query_statement_name[];
|
||||
static const char erase_query_statement_name[];
|
||||
|
||||
static const unsigned int persist_statement_types[];
|
||||
static const unsigned int find_statement_types[];
|
||||
static const unsigned int update_statement_types[];
|
||||
|
||||
public:
|
||||
static bool
|
||||
find_ (statements_type&,
|
||||
const id_type*);
|
||||
|
||||
static void
|
||||
load_ (statements_type&,
|
||||
object_type&,
|
||||
bool reload);
|
||||
};
|
||||
|
||||
template <>
|
||||
class access::object_traits_impl< ::models::TripAttemptResult, id_common >:
|
||||
public access::object_traits_impl< ::models::TripAttemptResult, id_pgsql >
|
||||
{
|
||||
};
|
||||
|
||||
// TripAttemptResult
|
||||
//
|
||||
}
|
||||
|
||||
#include "TripAttemptResult-odb.ixx"
|
||||
|
||||
#include <odb/post.hxx>
|
||||
|
||||
#endif // TRIP_ATTEMPT_RESULT_ODB_HXX
|
||||
@@ -0,0 +1,61 @@
|
||||
// This file was generated by ODB, object-relational mapping (ORM)
|
||||
// compiler for C++.
|
||||
//
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// TripAttemptResult
|
||||
//
|
||||
|
||||
inline
|
||||
access::object_traits< ::models::TripAttemptResult >::id_type
|
||||
access::object_traits< ::models::TripAttemptResult >::
|
||||
id (const object_type& o)
|
||||
{
|
||||
return o.id;
|
||||
}
|
||||
|
||||
inline
|
||||
void access::object_traits< ::models::TripAttemptResult >::
|
||||
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< ::models::TripAttemptResult >::
|
||||
callback (database& db, const object_type& x, callback_event e)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
ODB_POTENTIALLY_UNUSED (x);
|
||||
ODB_POTENTIALLY_UNUSED (e);
|
||||
}
|
||||
}
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// TripAttemptResult
|
||||
//
|
||||
|
||||
inline
|
||||
void access::object_traits_impl< ::models::TripAttemptResult, id_pgsql >::
|
||||
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< ::models::TripAttemptResult, id_pgsql >::
|
||||
load_ (statements_type& sts,
|
||||
object_type& obj,
|
||||
bool)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (sts);
|
||||
ODB_POTENTIALLY_UNUSED (obj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" database="pgsql" version="1">
|
||||
<changeset version="2">
|
||||
<add-table name="TripAttemptResult" kind="object">
|
||||
<column name="id" type="TEXT" null="false"/>
|
||||
<column name="result" type="TEXT" null="false"/>
|
||||
<column name="retryReason" type="TEXT" null="false"/>
|
||||
<column name="governmentSuspensionReason" type="TEXT" null="false"/>
|
||||
<column name="governmentTerminationReason" type="TEXT" null="false"/>
|
||||
<column name="complianceSuspensionReason" type="TEXT" null="false"/>
|
||||
<column name="complianceTerminationReason" type="TEXT" null="false"/>
|
||||
<column name="policySuspensionReason" type="TEXT" null="false"/>
|
||||
<column name="policyTerminationReason" type="TEXT" null="false"/>
|
||||
<column name="cancelationReason" type="TEXT" null="false"/>
|
||||
<column name="failureReason" type="TEXT" null="false"/>
|
||||
<column name="details" type="TEXT" null="false"/>
|
||||
<primary-key>
|
||||
<column name="id"/>
|
||||
</primary-key>
|
||||
</add-table>
|
||||
</changeset>
|
||||
|
||||
<model version="1"/>
|
||||
</changelog>
|
||||
815
db/test-schema-v1.2/generated-odb-source/sqlite/Agent-odb.cxx
Normal file
815
db/test-schema-v1.2/generated-odb-source/sqlite/Agent-odb.cxx
Normal file
@@ -0,0 +1,815 @@
|
||||
// This file was generated by ODB, object-relational mapping (ORM)
|
||||
// compiler for C++.
|
||||
//
|
||||
|
||||
#include <odb/pre.hxx>
|
||||
|
||||
#include "Agent-odb.hxx"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring> // std::memcpy
|
||||
|
||||
|
||||
#include <odb/sqlite/traits.hxx>
|
||||
#include <odb/sqlite/database.hxx>
|
||||
#include <odb/sqlite/transaction.hxx>
|
||||
#include <odb/sqlite/connection.hxx>
|
||||
#include <odb/sqlite/statement.hxx>
|
||||
#include <odb/sqlite/statement-cache.hxx>
|
||||
#include <odb/sqlite/simple-object-statements.hxx>
|
||||
#include <odb/sqlite/container-statements.hxx>
|
||||
#include <odb/sqlite/exceptions.hxx>
|
||||
#include <odb/sqlite/simple-object-result.hxx>
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// Agent
|
||||
//
|
||||
|
||||
struct access::object_traits_impl< ::models::Agent, id_sqlite >::extra_statement_cache_type
|
||||
{
|
||||
extra_statement_cache_type (
|
||||
sqlite::connection&,
|
||||
image_type&,
|
||||
id_image_type&,
|
||||
sqlite::binding&,
|
||||
sqlite::binding&)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
access::object_traits_impl< ::models::Agent, id_sqlite >::id_type
|
||||
access::object_traits_impl< ::models::Agent, id_sqlite >::
|
||||
id (const image_type& i)
|
||||
{
|
||||
sqlite::database* db (0);
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
id_type id;
|
||||
{
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::set_value (
|
||||
id,
|
||||
i.id_value,
|
||||
i.id_size,
|
||||
i.id_null);
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
bool access::object_traits_impl< ::models::Agent, id_sqlite >::
|
||||
grow (image_type& i,
|
||||
bool* t)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (i);
|
||||
ODB_POTENTIALLY_UNUSED (t);
|
||||
|
||||
bool grew (false);
|
||||
|
||||
// id
|
||||
//
|
||||
if (t[0UL])
|
||||
{
|
||||
i.id_value.capacity (i.id_size);
|
||||
grew = true;
|
||||
}
|
||||
|
||||
// role
|
||||
//
|
||||
if (t[1UL])
|
||||
{
|
||||
i.role_value.capacity (i.role_size);
|
||||
grew = true;
|
||||
}
|
||||
|
||||
// persistent
|
||||
//
|
||||
t[2UL] = false;
|
||||
|
||||
// displayName
|
||||
//
|
||||
if (t[3UL])
|
||||
{
|
||||
i.displayName_value.capacity (i.displayName_size);
|
||||
grew = true;
|
||||
}
|
||||
|
||||
// trustScore
|
||||
//
|
||||
t[4UL] = false;
|
||||
|
||||
return grew;
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::Agent, id_sqlite >::
|
||||
bind (sqlite::bind* b,
|
||||
image_type& i,
|
||||
sqlite::statement_kind sk)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (sk);
|
||||
|
||||
using namespace sqlite;
|
||||
|
||||
std::size_t n (0);
|
||||
|
||||
// id
|
||||
//
|
||||
if (sk != statement_update)
|
||||
{
|
||||
b[n].type = sqlite::image_traits<
|
||||
::std::string,
|
||||
sqlite::id_text>::bind_value;
|
||||
b[n].buffer = i.id_value.data ();
|
||||
b[n].size = &i.id_size;
|
||||
b[n].capacity = i.id_value.capacity ();
|
||||
b[n].is_null = &i.id_null;
|
||||
n++;
|
||||
}
|
||||
|
||||
// role
|
||||
//
|
||||
b[n].type = sqlite::image_traits<
|
||||
::std::string,
|
||||
sqlite::id_text>::bind_value;
|
||||
b[n].buffer = i.role_value.data ();
|
||||
b[n].size = &i.role_size;
|
||||
b[n].capacity = i.role_value.capacity ();
|
||||
b[n].is_null = &i.role_null;
|
||||
n++;
|
||||
|
||||
// persistent
|
||||
//
|
||||
b[n].type = sqlite::bind::integer;
|
||||
b[n].buffer = &i.persistent_value;
|
||||
b[n].is_null = &i.persistent_null;
|
||||
n++;
|
||||
|
||||
// displayName
|
||||
//
|
||||
b[n].type = sqlite::image_traits<
|
||||
::std::string,
|
||||
sqlite::id_text>::bind_value;
|
||||
b[n].buffer = i.displayName_value.data ();
|
||||
b[n].size = &i.displayName_size;
|
||||
b[n].capacity = i.displayName_value.capacity ();
|
||||
b[n].is_null = &i.displayName_null;
|
||||
n++;
|
||||
|
||||
// trustScore
|
||||
//
|
||||
b[n].type = sqlite::bind::integer;
|
||||
b[n].buffer = &i.trustScore_value;
|
||||
b[n].is_null = &i.trustScore_null;
|
||||
n++;
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::Agent, id_sqlite >::
|
||||
bind (sqlite::bind* b, id_image_type& i)
|
||||
{
|
||||
std::size_t n (0);
|
||||
b[n].type = sqlite::image_traits<
|
||||
::std::string,
|
||||
sqlite::id_text>::bind_value;
|
||||
b[n].buffer = i.id_value.data ();
|
||||
b[n].size = &i.id_size;
|
||||
b[n].capacity = i.id_value.capacity ();
|
||||
b[n].is_null = &i.id_null;
|
||||
}
|
||||
|
||||
bool access::object_traits_impl< ::models::Agent, id_sqlite >::
|
||||
init (image_type& i,
|
||||
const object_type& o,
|
||||
sqlite::statement_kind sk)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (i);
|
||||
ODB_POTENTIALLY_UNUSED (o);
|
||||
ODB_POTENTIALLY_UNUSED (sk);
|
||||
|
||||
using namespace sqlite;
|
||||
|
||||
bool grew (false);
|
||||
|
||||
// id
|
||||
//
|
||||
if (sk == statement_insert)
|
||||
{
|
||||
::std::string const& v =
|
||||
o.id;
|
||||
|
||||
bool is_null (false);
|
||||
std::size_t cap (i.id_value.capacity ());
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::set_image (
|
||||
i.id_value,
|
||||
i.id_size,
|
||||
is_null,
|
||||
v);
|
||||
i.id_null = is_null;
|
||||
grew = grew || (cap != i.id_value.capacity ());
|
||||
}
|
||||
|
||||
// role
|
||||
//
|
||||
{
|
||||
::std::string const& v =
|
||||
o.role;
|
||||
|
||||
bool is_null (false);
|
||||
std::size_t cap (i.role_value.capacity ());
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::set_image (
|
||||
i.role_value,
|
||||
i.role_size,
|
||||
is_null,
|
||||
v);
|
||||
i.role_null = is_null;
|
||||
grew = grew || (cap != i.role_value.capacity ());
|
||||
}
|
||||
|
||||
// persistent
|
||||
//
|
||||
{
|
||||
bool const& v =
|
||||
o.persistent;
|
||||
|
||||
bool is_null (false);
|
||||
sqlite::value_traits<
|
||||
bool,
|
||||
sqlite::id_integer >::set_image (
|
||||
i.persistent_value,
|
||||
is_null,
|
||||
v);
|
||||
i.persistent_null = is_null;
|
||||
}
|
||||
|
||||
// displayName
|
||||
//
|
||||
{
|
||||
::std::string const& v =
|
||||
o.displayName;
|
||||
|
||||
bool is_null (false);
|
||||
std::size_t cap (i.displayName_value.capacity ());
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::set_image (
|
||||
i.displayName_value,
|
||||
i.displayName_size,
|
||||
is_null,
|
||||
v);
|
||||
i.displayName_null = is_null;
|
||||
grew = grew || (cap != i.displayName_value.capacity ());
|
||||
}
|
||||
|
||||
// trustScore
|
||||
//
|
||||
{
|
||||
::int32_t const& v =
|
||||
o.trustScore;
|
||||
|
||||
bool is_null (false);
|
||||
sqlite::value_traits<
|
||||
::int32_t,
|
||||
sqlite::id_integer >::set_image (
|
||||
i.trustScore_value,
|
||||
is_null,
|
||||
v);
|
||||
i.trustScore_null = is_null;
|
||||
}
|
||||
|
||||
return grew;
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::Agent, id_sqlite >::
|
||||
init (object_type& o,
|
||||
const image_type& i,
|
||||
database* db)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (o);
|
||||
ODB_POTENTIALLY_UNUSED (i);
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
// id
|
||||
//
|
||||
{
|
||||
::std::string& v =
|
||||
o.id;
|
||||
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::set_value (
|
||||
v,
|
||||
i.id_value,
|
||||
i.id_size,
|
||||
i.id_null);
|
||||
}
|
||||
|
||||
// role
|
||||
//
|
||||
{
|
||||
::std::string& v =
|
||||
o.role;
|
||||
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::set_value (
|
||||
v,
|
||||
i.role_value,
|
||||
i.role_size,
|
||||
i.role_null);
|
||||
}
|
||||
|
||||
// persistent
|
||||
//
|
||||
{
|
||||
bool& v =
|
||||
o.persistent;
|
||||
|
||||
sqlite::value_traits<
|
||||
bool,
|
||||
sqlite::id_integer >::set_value (
|
||||
v,
|
||||
i.persistent_value,
|
||||
i.persistent_null);
|
||||
}
|
||||
|
||||
// displayName
|
||||
//
|
||||
{
|
||||
::std::string& v =
|
||||
o.displayName;
|
||||
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::set_value (
|
||||
v,
|
||||
i.displayName_value,
|
||||
i.displayName_size,
|
||||
i.displayName_null);
|
||||
}
|
||||
|
||||
// trustScore
|
||||
//
|
||||
{
|
||||
::int32_t& v =
|
||||
o.trustScore;
|
||||
|
||||
sqlite::value_traits<
|
||||
::int32_t,
|
||||
sqlite::id_integer >::set_value (
|
||||
v,
|
||||
i.trustScore_value,
|
||||
i.trustScore_null);
|
||||
}
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::Agent, id_sqlite >::
|
||||
init (id_image_type& i, const id_type& id)
|
||||
{
|
||||
bool grew (false);
|
||||
{
|
||||
bool is_null (false);
|
||||
std::size_t cap (i.id_value.capacity ());
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::set_image (
|
||||
i.id_value,
|
||||
i.id_size,
|
||||
is_null,
|
||||
id);
|
||||
i.id_null = is_null;
|
||||
grew = grew || (cap != i.id_value.capacity ());
|
||||
}
|
||||
|
||||
if (grew)
|
||||
i.version++;
|
||||
}
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_sqlite >::persist_statement[] =
|
||||
"INSERT INTO \"Agent\" "
|
||||
"(\"id\", "
|
||||
"\"role\", "
|
||||
"\"persistent\", "
|
||||
"\"displayName\", "
|
||||
"\"trustScore\") "
|
||||
"VALUES "
|
||||
"(?, ?, ?, ?, ?)";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_sqlite >::find_statement[] =
|
||||
"SELECT "
|
||||
"\"Agent\".\"id\", "
|
||||
"\"Agent\".\"role\", "
|
||||
"\"Agent\".\"persistent\", "
|
||||
"\"Agent\".\"displayName\", "
|
||||
"\"Agent\".\"trustScore\" "
|
||||
"FROM \"Agent\" "
|
||||
"WHERE \"Agent\".\"id\"=?";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_sqlite >::update_statement[] =
|
||||
"UPDATE \"Agent\" "
|
||||
"SET "
|
||||
"\"role\"=?, "
|
||||
"\"persistent\"=?, "
|
||||
"\"displayName\"=?, "
|
||||
"\"trustScore\"=? "
|
||||
"WHERE \"id\"=?";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_sqlite >::erase_statement[] =
|
||||
"DELETE FROM \"Agent\" "
|
||||
"WHERE \"id\"=?";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_sqlite >::query_statement[] =
|
||||
"SELECT "
|
||||
"\"Agent\".\"id\", "
|
||||
"\"Agent\".\"role\", "
|
||||
"\"Agent\".\"persistent\", "
|
||||
"\"Agent\".\"displayName\", "
|
||||
"\"Agent\".\"trustScore\" "
|
||||
"FROM \"Agent\"";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_sqlite >::erase_query_statement[] =
|
||||
"DELETE FROM \"Agent\"";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_sqlite >::table_name[] =
|
||||
"\"Agent\"";
|
||||
|
||||
void access::object_traits_impl< ::models::Agent, id_sqlite >::
|
||||
persist (database& db, const object_type& obj)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
using namespace sqlite;
|
||||
|
||||
sqlite::connection& conn (
|
||||
sqlite::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
callback (db,
|
||||
obj,
|
||||
callback_event::pre_persist);
|
||||
|
||||
image_type& im (sts.image ());
|
||||
binding& imb (sts.insert_image_binding ());
|
||||
|
||||
if (init (im, obj, statement_insert))
|
||||
im.version++;
|
||||
|
||||
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 ();
|
||||
|
||||
callback (db,
|
||||
obj,
|
||||
callback_event::post_persist);
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::Agent, id_sqlite >::
|
||||
update (database& db, const object_type& obj)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
using namespace sqlite;
|
||||
using sqlite::update_statement;
|
||||
|
||||
callback (db, obj, callback_event::pre_update);
|
||||
|
||||
sqlite::transaction& tr (sqlite::transaction::current ());
|
||||
sqlite::connection& conn (tr.connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
const id_type& id (
|
||||
obj.id);
|
||||
id_image_type& idi (sts.id_image ());
|
||||
init (idi, id);
|
||||
|
||||
image_type& im (sts.image ());
|
||||
if (init (im, obj, statement_update))
|
||||
im.version++;
|
||||
|
||||
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< ::models::Agent, id_sqlite >::
|
||||
erase (database& db, const id_type& id)
|
||||
{
|
||||
using namespace sqlite;
|
||||
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
sqlite::connection& conn (
|
||||
sqlite::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
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< ::models::Agent, id_sqlite >::pointer_type
|
||||
access::object_traits_impl< ::models::Agent, id_sqlite >::
|
||||
find (database& db, const id_type& id)
|
||||
{
|
||||
using namespace sqlite;
|
||||
|
||||
{
|
||||
pointer_type p (pointer_cache_traits::find (db, id));
|
||||
|
||||
if (!pointer_traits::null_ptr (p))
|
||||
return p;
|
||||
}
|
||||
|
||||
sqlite::connection& conn (
|
||||
sqlite::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
statements_type::auto_lock l (sts);
|
||||
|
||||
if (l.locked ())
|
||||
{
|
||||
if (!find_ (sts, &id))
|
||||
return pointer_type ();
|
||||
}
|
||||
|
||||
pointer_type p (
|
||||
access::object_factory<object_type, pointer_type>::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);
|
||||
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< ::models::Agent, id_sqlite >::
|
||||
find (database& db, const id_type& id, object_type& obj)
|
||||
{
|
||||
using namespace sqlite;
|
||||
|
||||
sqlite::connection& conn (
|
||||
sqlite::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
statements_type::auto_lock l (sts);
|
||||
|
||||
if (!find_ (sts, &id))
|
||||
return false;
|
||||
|
||||
select_statement& st (sts.find_statement ());
|
||||
ODB_POTENTIALLY_UNUSED (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);
|
||||
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< ::models::Agent, id_sqlite >::
|
||||
reload (database& db, object_type& obj)
|
||||
{
|
||||
using namespace sqlite;
|
||||
|
||||
sqlite::connection& conn (
|
||||
sqlite::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
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);
|
||||
|
||||
callback (db, obj, callback_event::pre_load);
|
||||
init (obj, sts.image (), &db);
|
||||
load_ (sts, obj, true);
|
||||
sts.load_delayed (0);
|
||||
l.unlock ();
|
||||
callback (db, obj, callback_event::post_load);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool access::object_traits_impl< ::models::Agent, id_sqlite >::
|
||||
find_ (statements_type& sts,
|
||||
const id_type* id)
|
||||
{
|
||||
using namespace sqlite;
|
||||
|
||||
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::truncated)
|
||||
{
|
||||
if (grow (im, sts.select_image_truncated ()))
|
||||
im.version++;
|
||||
|
||||
if (im.version != sts.select_image_version ())
|
||||
{
|
||||
bind (imb.bind, im, statement_select);
|
||||
sts.select_image_version (im.version);
|
||||
imb.version++;
|
||||
st.refetch ();
|
||||
}
|
||||
}
|
||||
|
||||
return r != select_statement::no_data;
|
||||
}
|
||||
|
||||
result< access::object_traits_impl< ::models::Agent, id_sqlite >::object_type >
|
||||
access::object_traits_impl< ::models::Agent, id_sqlite >::
|
||||
query (database&, const query_base_type& q)
|
||||
{
|
||||
using namespace sqlite;
|
||||
using odb::details::shared;
|
||||
using odb::details::shared_ptr;
|
||||
|
||||
sqlite::connection& conn (
|
||||
sqlite::transaction::current ().connection ());
|
||||
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
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++;
|
||||
}
|
||||
|
||||
std::string text (query_statement);
|
||||
if (!q.empty ())
|
||||
{
|
||||
text += " ";
|
||||
text += q.clause ();
|
||||
}
|
||||
|
||||
q.init_parameters ();
|
||||
shared_ptr<select_statement> st (
|
||||
new (shared) select_statement (
|
||||
conn,
|
||||
text,
|
||||
false,
|
||||
true,
|
||||
q.parameters_binding (),
|
||||
imb));
|
||||
|
||||
st->execute ();
|
||||
|
||||
shared_ptr< odb::object_result_impl<object_type> > r (
|
||||
new (shared) sqlite::object_result_impl<object_type> (
|
||||
q, st, sts, 0));
|
||||
|
||||
return result<object_type> (r);
|
||||
}
|
||||
|
||||
unsigned long long access::object_traits_impl< ::models::Agent, id_sqlite >::
|
||||
erase_query (database&, const query_base_type& q)
|
||||
{
|
||||
using namespace sqlite;
|
||||
|
||||
sqlite::connection& conn (
|
||||
sqlite::transaction::current ().connection ());
|
||||
|
||||
std::string text (erase_query_statement);
|
||||
if (!q.empty ())
|
||||
{
|
||||
text += ' ';
|
||||
text += q.clause ();
|
||||
}
|
||||
|
||||
q.init_parameters ();
|
||||
delete_statement st (
|
||||
conn,
|
||||
text,
|
||||
q.parameters_binding ());
|
||||
|
||||
return st.execute ();
|
||||
}
|
||||
}
|
||||
|
||||
#include <odb/post.hxx>
|
||||
342
db/test-schema-v1.2/generated-odb-source/sqlite/Agent-odb.hxx
Normal file
342
db/test-schema-v1.2/generated-odb-source/sqlite/Agent-odb.hxx
Normal file
@@ -0,0 +1,342 @@
|
||||
// This file was generated by ODB, object-relational mapping (ORM)
|
||||
// compiler for C++.
|
||||
//
|
||||
|
||||
#ifndef AGENT_ODB_HXX
|
||||
#define AGENT_ODB_HXX
|
||||
|
||||
#include <odb/version.hxx>
|
||||
|
||||
#if (ODB_VERSION != 20400UL)
|
||||
#error ODB runtime version mismatch
|
||||
#endif
|
||||
|
||||
#include <odb/pre.hxx>
|
||||
|
||||
#include "Agent.h"
|
||||
|
||||
#include <memory>
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
#include <odb/core.hxx>
|
||||
#include <odb/traits.hxx>
|
||||
#include <odb/callback.hxx>
|
||||
#include <odb/wrapper-traits.hxx>
|
||||
#include <odb/pointer-traits.hxx>
|
||||
#include <odb/container-traits.hxx>
|
||||
#include <odb/no-op-cache-traits.hxx>
|
||||
#include <odb/result.hxx>
|
||||
#include <odb/simple-object-result.hxx>
|
||||
|
||||
#include <odb/details/unused.hxx>
|
||||
#include <odb/details/shared-ptr.hxx>
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// Agent
|
||||
//
|
||||
template <>
|
||||
struct class_traits< ::models::Agent >
|
||||
{
|
||||
static const class_kind kind = class_object;
|
||||
};
|
||||
|
||||
template <>
|
||||
class access::object_traits< ::models::Agent >
|
||||
{
|
||||
public:
|
||||
typedef ::models::Agent object_type;
|
||||
typedef ::models::Agent* pointer_type;
|
||||
typedef odb::pointer_traits<pointer_type> pointer_traits;
|
||||
|
||||
static const bool polymorphic = false;
|
||||
|
||||
typedef ::std::string id_type;
|
||||
|
||||
static const bool auto_id = false;
|
||||
|
||||
static const bool abstract = false;
|
||||
|
||||
static id_type
|
||||
id (const object_type&);
|
||||
|
||||
typedef
|
||||
no_op_pointer_cache_traits<pointer_type>
|
||||
pointer_cache_traits;
|
||||
|
||||
typedef
|
||||
no_op_reference_cache_traits<object_type>
|
||||
reference_cache_traits;
|
||||
|
||||
static void
|
||||
callback (database&, object_type&, callback_event);
|
||||
|
||||
static void
|
||||
callback (database&, const object_type&, callback_event);
|
||||
};
|
||||
}
|
||||
|
||||
#include <odb/details/buffer.hxx>
|
||||
|
||||
#include <odb/sqlite/version.hxx>
|
||||
#include <odb/sqlite/forward.hxx>
|
||||
#include <odb/sqlite/binding.hxx>
|
||||
#include <odb/sqlite/sqlite-types.hxx>
|
||||
#include <odb/sqlite/query.hxx>
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// Agent
|
||||
//
|
||||
template <typename A>
|
||||
struct query_columns< ::models::Agent, id_sqlite, A >
|
||||
{
|
||||
// id
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
id_type_;
|
||||
|
||||
static const id_type_ id;
|
||||
|
||||
// role
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
role_type_;
|
||||
|
||||
static const role_type_ role;
|
||||
|
||||
// persistent
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
bool,
|
||||
sqlite::id_integer >::query_type,
|
||||
sqlite::id_integer >
|
||||
persistent_type_;
|
||||
|
||||
static const persistent_type_ persistent;
|
||||
|
||||
// displayName
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
displayName_type_;
|
||||
|
||||
static const displayName_type_ displayName;
|
||||
|
||||
// trustScore
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::int32_t,
|
||||
sqlite::id_integer >::query_type,
|
||||
sqlite::id_integer >
|
||||
trustScore_type_;
|
||||
|
||||
static const trustScore_type_ trustScore;
|
||||
};
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::Agent, id_sqlite, A >::id_type_
|
||||
query_columns< ::models::Agent, id_sqlite, A >::
|
||||
id (A::table_name, "\"id\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::Agent, id_sqlite, A >::role_type_
|
||||
query_columns< ::models::Agent, id_sqlite, A >::
|
||||
role (A::table_name, "\"role\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::Agent, id_sqlite, A >::persistent_type_
|
||||
query_columns< ::models::Agent, id_sqlite, A >::
|
||||
persistent (A::table_name, "\"persistent\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::Agent, id_sqlite, A >::displayName_type_
|
||||
query_columns< ::models::Agent, id_sqlite, A >::
|
||||
displayName (A::table_name, "\"displayName\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::Agent, id_sqlite, A >::trustScore_type_
|
||||
query_columns< ::models::Agent, id_sqlite, A >::
|
||||
trustScore (A::table_name, "\"trustScore\"", 0);
|
||||
|
||||
template <typename A>
|
||||
struct pointer_query_columns< ::models::Agent, id_sqlite, A >:
|
||||
query_columns< ::models::Agent, id_sqlite, A >
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
class access::object_traits_impl< ::models::Agent, id_sqlite >:
|
||||
public access::object_traits< ::models::Agent >
|
||||
{
|
||||
public:
|
||||
struct id_image_type
|
||||
{
|
||||
details::buffer id_value;
|
||||
std::size_t id_size;
|
||||
bool id_null;
|
||||
|
||||
std::size_t version;
|
||||
};
|
||||
|
||||
struct image_type
|
||||
{
|
||||
// id
|
||||
//
|
||||
details::buffer id_value;
|
||||
std::size_t id_size;
|
||||
bool id_null;
|
||||
|
||||
// role
|
||||
//
|
||||
details::buffer role_value;
|
||||
std::size_t role_size;
|
||||
bool role_null;
|
||||
|
||||
// persistent
|
||||
//
|
||||
long long persistent_value;
|
||||
bool persistent_null;
|
||||
|
||||
// displayName
|
||||
//
|
||||
details::buffer displayName_value;
|
||||
std::size_t displayName_size;
|
||||
bool displayName_null;
|
||||
|
||||
// trustScore
|
||||
//
|
||||
long long trustScore_value;
|
||||
bool trustScore_null;
|
||||
|
||||
std::size_t version;
|
||||
};
|
||||
|
||||
struct extra_statement_cache_type;
|
||||
|
||||
using object_traits<object_type>::id;
|
||||
|
||||
static id_type
|
||||
id (const image_type&);
|
||||
|
||||
static bool
|
||||
grow (image_type&,
|
||||
bool*);
|
||||
|
||||
static void
|
||||
bind (sqlite::bind*,
|
||||
image_type&,
|
||||
sqlite::statement_kind);
|
||||
|
||||
static void
|
||||
bind (sqlite::bind*, id_image_type&);
|
||||
|
||||
static bool
|
||||
init (image_type&,
|
||||
const object_type&,
|
||||
sqlite::statement_kind);
|
||||
|
||||
static void
|
||||
init (object_type&,
|
||||
const image_type&,
|
||||
database*);
|
||||
|
||||
static void
|
||||
init (id_image_type&, const id_type&);
|
||||
|
||||
typedef sqlite::object_statements<object_type> statements_type;
|
||||
|
||||
typedef sqlite::query_base query_base_type;
|
||||
|
||||
static const std::size_t column_count = 5UL;
|
||||
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 const char query_statement[];
|
||||
static const char erase_query_statement[];
|
||||
|
||||
static const char table_name[];
|
||||
|
||||
static void
|
||||
persist (database&, const 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&);
|
||||
|
||||
static result<object_type>
|
||||
query (database&, const query_base_type&);
|
||||
|
||||
static unsigned long long
|
||||
erase_query (database&, const query_base_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< ::models::Agent, id_common >:
|
||||
public access::object_traits_impl< ::models::Agent, id_sqlite >
|
||||
{
|
||||
};
|
||||
|
||||
// Agent
|
||||
//
|
||||
}
|
||||
|
||||
#include "Agent-odb.ixx"
|
||||
|
||||
#include <odb/post.hxx>
|
||||
|
||||
#endif // AGENT_ODB_HXX
|
||||
@@ -0,0 +1,61 @@
|
||||
// This file was generated by ODB, object-relational mapping (ORM)
|
||||
// compiler for C++.
|
||||
//
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// Agent
|
||||
//
|
||||
|
||||
inline
|
||||
access::object_traits< ::models::Agent >::id_type
|
||||
access::object_traits< ::models::Agent >::
|
||||
id (const object_type& o)
|
||||
{
|
||||
return o.id;
|
||||
}
|
||||
|
||||
inline
|
||||
void access::object_traits< ::models::Agent >::
|
||||
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< ::models::Agent >::
|
||||
callback (database& db, const object_type& x, callback_event e)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
ODB_POTENTIALLY_UNUSED (x);
|
||||
ODB_POTENTIALLY_UNUSED (e);
|
||||
}
|
||||
}
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// Agent
|
||||
//
|
||||
|
||||
inline
|
||||
void access::object_traits_impl< ::models::Agent, id_sqlite >::
|
||||
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< ::models::Agent, id_sqlite >::
|
||||
load_ (statements_type& sts,
|
||||
object_type& obj,
|
||||
bool)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (sts);
|
||||
ODB_POTENTIALLY_UNUSED (obj);
|
||||
}
|
||||
}
|
||||
|
||||
16
db/test-schema-v1.2/generated-odb-source/sqlite/Agent.xml
Normal file
16
db/test-schema-v1.2/generated-odb-source/sqlite/Agent.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" database="sqlite" version="1">
|
||||
<changeset version="2">
|
||||
<add-table name="Agent" kind="object">
|
||||
<column name="id" type="TEXT" null="false"/>
|
||||
<column name="role" type="TEXT" null="false"/>
|
||||
<column name="persistent" type="INTEGER" null="false"/>
|
||||
<column name="displayName" type="TEXT" null="false"/>
|
||||
<column name="trustScore" type="INTEGER" null="false"/>
|
||||
<primary-key>
|
||||
<column name="id"/>
|
||||
</primary-key>
|
||||
</add-table>
|
||||
</changeset>
|
||||
|
||||
<model version="1"/>
|
||||
</changelog>
|
||||
@@ -0,0 +1,725 @@
|
||||
// This file was generated by ODB, object-relational mapping (ORM)
|
||||
// compiler for C++.
|
||||
//
|
||||
|
||||
#include <odb/pre.hxx>
|
||||
|
||||
#include "GovernmentAddress-odb.hxx"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring> // std::memcpy
|
||||
|
||||
|
||||
#include <odb/sqlite/traits.hxx>
|
||||
#include <odb/sqlite/database.hxx>
|
||||
#include <odb/sqlite/transaction.hxx>
|
||||
#include <odb/sqlite/connection.hxx>
|
||||
#include <odb/sqlite/statement.hxx>
|
||||
#include <odb/sqlite/statement-cache.hxx>
|
||||
#include <odb/sqlite/simple-object-statements.hxx>
|
||||
#include <odb/sqlite/container-statements.hxx>
|
||||
#include <odb/sqlite/exceptions.hxx>
|
||||
#include <odb/sqlite/simple-object-result.hxx>
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// GovernmentAddress
|
||||
//
|
||||
|
||||
struct access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::extra_statement_cache_type
|
||||
{
|
||||
extra_statement_cache_type (
|
||||
sqlite::connection&,
|
||||
image_type&,
|
||||
id_image_type&,
|
||||
sqlite::binding&,
|
||||
sqlite::binding&)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::id_type
|
||||
access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::
|
||||
id (const image_type& i)
|
||||
{
|
||||
sqlite::database* db (0);
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
id_type id;
|
||||
{
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::set_value (
|
||||
id,
|
||||
i.id_value,
|
||||
i.id_size,
|
||||
i.id_null);
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
bool access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::
|
||||
grow (image_type& i,
|
||||
bool* t)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (i);
|
||||
ODB_POTENTIALLY_UNUSED (t);
|
||||
|
||||
bool grew (false);
|
||||
|
||||
// id
|
||||
//
|
||||
if (t[0UL])
|
||||
{
|
||||
i.id_value.capacity (i.id_size);
|
||||
grew = true;
|
||||
}
|
||||
|
||||
// addressLabel
|
||||
//
|
||||
if (t[1UL])
|
||||
{
|
||||
i.addressLabel_value.capacity (i.addressLabel_size);
|
||||
grew = true;
|
||||
}
|
||||
|
||||
// regionLookupKey
|
||||
//
|
||||
if (t[2UL])
|
||||
{
|
||||
i.regionLookupKey_value.capacity (i.regionLookupKey_size);
|
||||
grew = true;
|
||||
}
|
||||
|
||||
return grew;
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::
|
||||
bind (sqlite::bind* b,
|
||||
image_type& i,
|
||||
sqlite::statement_kind sk)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (sk);
|
||||
|
||||
using namespace sqlite;
|
||||
|
||||
std::size_t n (0);
|
||||
|
||||
// id
|
||||
//
|
||||
if (sk != statement_update)
|
||||
{
|
||||
b[n].type = sqlite::image_traits<
|
||||
::std::string,
|
||||
sqlite::id_text>::bind_value;
|
||||
b[n].buffer = i.id_value.data ();
|
||||
b[n].size = &i.id_size;
|
||||
b[n].capacity = i.id_value.capacity ();
|
||||
b[n].is_null = &i.id_null;
|
||||
n++;
|
||||
}
|
||||
|
||||
// addressLabel
|
||||
//
|
||||
b[n].type = sqlite::image_traits<
|
||||
::std::string,
|
||||
sqlite::id_text>::bind_value;
|
||||
b[n].buffer = i.addressLabel_value.data ();
|
||||
b[n].size = &i.addressLabel_size;
|
||||
b[n].capacity = i.addressLabel_value.capacity ();
|
||||
b[n].is_null = &i.addressLabel_null;
|
||||
n++;
|
||||
|
||||
// regionLookupKey
|
||||
//
|
||||
b[n].type = sqlite::image_traits<
|
||||
::std::string,
|
||||
sqlite::id_text>::bind_value;
|
||||
b[n].buffer = i.regionLookupKey_value.data ();
|
||||
b[n].size = &i.regionLookupKey_size;
|
||||
b[n].capacity = i.regionLookupKey_value.capacity ();
|
||||
b[n].is_null = &i.regionLookupKey_null;
|
||||
n++;
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::
|
||||
bind (sqlite::bind* b, id_image_type& i)
|
||||
{
|
||||
std::size_t n (0);
|
||||
b[n].type = sqlite::image_traits<
|
||||
::std::string,
|
||||
sqlite::id_text>::bind_value;
|
||||
b[n].buffer = i.id_value.data ();
|
||||
b[n].size = &i.id_size;
|
||||
b[n].capacity = i.id_value.capacity ();
|
||||
b[n].is_null = &i.id_null;
|
||||
}
|
||||
|
||||
bool access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::
|
||||
init (image_type& i,
|
||||
const object_type& o,
|
||||
sqlite::statement_kind sk)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (i);
|
||||
ODB_POTENTIALLY_UNUSED (o);
|
||||
ODB_POTENTIALLY_UNUSED (sk);
|
||||
|
||||
using namespace sqlite;
|
||||
|
||||
bool grew (false);
|
||||
|
||||
// id
|
||||
//
|
||||
if (sk == statement_insert)
|
||||
{
|
||||
::std::string const& v =
|
||||
o.id;
|
||||
|
||||
bool is_null (false);
|
||||
std::size_t cap (i.id_value.capacity ());
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::set_image (
|
||||
i.id_value,
|
||||
i.id_size,
|
||||
is_null,
|
||||
v);
|
||||
i.id_null = is_null;
|
||||
grew = grew || (cap != i.id_value.capacity ());
|
||||
}
|
||||
|
||||
// addressLabel
|
||||
//
|
||||
{
|
||||
::std::string const& v =
|
||||
o.addressLabel;
|
||||
|
||||
bool is_null (false);
|
||||
std::size_t cap (i.addressLabel_value.capacity ());
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::set_image (
|
||||
i.addressLabel_value,
|
||||
i.addressLabel_size,
|
||||
is_null,
|
||||
v);
|
||||
i.addressLabel_null = is_null;
|
||||
grew = grew || (cap != i.addressLabel_value.capacity ());
|
||||
}
|
||||
|
||||
// regionLookupKey
|
||||
//
|
||||
{
|
||||
::std::string const& v =
|
||||
o.regionLookupKey;
|
||||
|
||||
bool is_null (false);
|
||||
std::size_t cap (i.regionLookupKey_value.capacity ());
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::set_image (
|
||||
i.regionLookupKey_value,
|
||||
i.regionLookupKey_size,
|
||||
is_null,
|
||||
v);
|
||||
i.regionLookupKey_null = is_null;
|
||||
grew = grew || (cap != i.regionLookupKey_value.capacity ());
|
||||
}
|
||||
|
||||
return grew;
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::
|
||||
init (object_type& o,
|
||||
const image_type& i,
|
||||
database* db)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (o);
|
||||
ODB_POTENTIALLY_UNUSED (i);
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
// id
|
||||
//
|
||||
{
|
||||
::std::string& v =
|
||||
o.id;
|
||||
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::set_value (
|
||||
v,
|
||||
i.id_value,
|
||||
i.id_size,
|
||||
i.id_null);
|
||||
}
|
||||
|
||||
// addressLabel
|
||||
//
|
||||
{
|
||||
::std::string& v =
|
||||
o.addressLabel;
|
||||
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::set_value (
|
||||
v,
|
||||
i.addressLabel_value,
|
||||
i.addressLabel_size,
|
||||
i.addressLabel_null);
|
||||
}
|
||||
|
||||
// regionLookupKey
|
||||
//
|
||||
{
|
||||
::std::string& v =
|
||||
o.regionLookupKey;
|
||||
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::set_value (
|
||||
v,
|
||||
i.regionLookupKey_value,
|
||||
i.regionLookupKey_size,
|
||||
i.regionLookupKey_null);
|
||||
}
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::
|
||||
init (id_image_type& i, const id_type& id)
|
||||
{
|
||||
bool grew (false);
|
||||
{
|
||||
bool is_null (false);
|
||||
std::size_t cap (i.id_value.capacity ());
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::set_image (
|
||||
i.id_value,
|
||||
i.id_size,
|
||||
is_null,
|
||||
id);
|
||||
i.id_null = is_null;
|
||||
grew = grew || (cap != i.id_value.capacity ());
|
||||
}
|
||||
|
||||
if (grew)
|
||||
i.version++;
|
||||
}
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::persist_statement[] =
|
||||
"INSERT INTO \"GovernmentAddress\" "
|
||||
"(\"id\", "
|
||||
"\"addressLabel\", "
|
||||
"\"regionLookupKey\") "
|
||||
"VALUES "
|
||||
"(?, ?, ?)";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::find_statement[] =
|
||||
"SELECT "
|
||||
"\"GovernmentAddress\".\"id\", "
|
||||
"\"GovernmentAddress\".\"addressLabel\", "
|
||||
"\"GovernmentAddress\".\"regionLookupKey\" "
|
||||
"FROM \"GovernmentAddress\" "
|
||||
"WHERE \"GovernmentAddress\".\"id\"=?";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::update_statement[] =
|
||||
"UPDATE \"GovernmentAddress\" "
|
||||
"SET "
|
||||
"\"addressLabel\"=?, "
|
||||
"\"regionLookupKey\"=? "
|
||||
"WHERE \"id\"=?";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::erase_statement[] =
|
||||
"DELETE FROM \"GovernmentAddress\" "
|
||||
"WHERE \"id\"=?";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::query_statement[] =
|
||||
"SELECT "
|
||||
"\"GovernmentAddress\".\"id\", "
|
||||
"\"GovernmentAddress\".\"addressLabel\", "
|
||||
"\"GovernmentAddress\".\"regionLookupKey\" "
|
||||
"FROM \"GovernmentAddress\"";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::erase_query_statement[] =
|
||||
"DELETE FROM \"GovernmentAddress\"";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::table_name[] =
|
||||
"\"GovernmentAddress\"";
|
||||
|
||||
void access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::
|
||||
persist (database& db, const object_type& obj)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
using namespace sqlite;
|
||||
|
||||
sqlite::connection& conn (
|
||||
sqlite::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
callback (db,
|
||||
obj,
|
||||
callback_event::pre_persist);
|
||||
|
||||
image_type& im (sts.image ());
|
||||
binding& imb (sts.insert_image_binding ());
|
||||
|
||||
if (init (im, obj, statement_insert))
|
||||
im.version++;
|
||||
|
||||
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 ();
|
||||
|
||||
callback (db,
|
||||
obj,
|
||||
callback_event::post_persist);
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::
|
||||
update (database& db, const object_type& obj)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
using namespace sqlite;
|
||||
using sqlite::update_statement;
|
||||
|
||||
callback (db, obj, callback_event::pre_update);
|
||||
|
||||
sqlite::transaction& tr (sqlite::transaction::current ());
|
||||
sqlite::connection& conn (tr.connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
const id_type& id (
|
||||
obj.id);
|
||||
id_image_type& idi (sts.id_image ());
|
||||
init (idi, id);
|
||||
|
||||
image_type& im (sts.image ());
|
||||
if (init (im, obj, statement_update))
|
||||
im.version++;
|
||||
|
||||
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< ::models::GovernmentAddress, id_sqlite >::
|
||||
erase (database& db, const id_type& id)
|
||||
{
|
||||
using namespace sqlite;
|
||||
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
sqlite::connection& conn (
|
||||
sqlite::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
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< ::models::GovernmentAddress, id_sqlite >::pointer_type
|
||||
access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::
|
||||
find (database& db, const id_type& id)
|
||||
{
|
||||
using namespace sqlite;
|
||||
|
||||
{
|
||||
pointer_type p (pointer_cache_traits::find (db, id));
|
||||
|
||||
if (!pointer_traits::null_ptr (p))
|
||||
return p;
|
||||
}
|
||||
|
||||
sqlite::connection& conn (
|
||||
sqlite::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
statements_type::auto_lock l (sts);
|
||||
|
||||
if (l.locked ())
|
||||
{
|
||||
if (!find_ (sts, &id))
|
||||
return pointer_type ();
|
||||
}
|
||||
|
||||
pointer_type p (
|
||||
access::object_factory<object_type, pointer_type>::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);
|
||||
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< ::models::GovernmentAddress, id_sqlite >::
|
||||
find (database& db, const id_type& id, object_type& obj)
|
||||
{
|
||||
using namespace sqlite;
|
||||
|
||||
sqlite::connection& conn (
|
||||
sqlite::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
statements_type::auto_lock l (sts);
|
||||
|
||||
if (!find_ (sts, &id))
|
||||
return false;
|
||||
|
||||
select_statement& st (sts.find_statement ());
|
||||
ODB_POTENTIALLY_UNUSED (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);
|
||||
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< ::models::GovernmentAddress, id_sqlite >::
|
||||
reload (database& db, object_type& obj)
|
||||
{
|
||||
using namespace sqlite;
|
||||
|
||||
sqlite::connection& conn (
|
||||
sqlite::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
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);
|
||||
|
||||
callback (db, obj, callback_event::pre_load);
|
||||
init (obj, sts.image (), &db);
|
||||
load_ (sts, obj, true);
|
||||
sts.load_delayed (0);
|
||||
l.unlock ();
|
||||
callback (db, obj, callback_event::post_load);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::
|
||||
find_ (statements_type& sts,
|
||||
const id_type* id)
|
||||
{
|
||||
using namespace sqlite;
|
||||
|
||||
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::truncated)
|
||||
{
|
||||
if (grow (im, sts.select_image_truncated ()))
|
||||
im.version++;
|
||||
|
||||
if (im.version != sts.select_image_version ())
|
||||
{
|
||||
bind (imb.bind, im, statement_select);
|
||||
sts.select_image_version (im.version);
|
||||
imb.version++;
|
||||
st.refetch ();
|
||||
}
|
||||
}
|
||||
|
||||
return r != select_statement::no_data;
|
||||
}
|
||||
|
||||
result< access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::object_type >
|
||||
access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::
|
||||
query (database&, const query_base_type& q)
|
||||
{
|
||||
using namespace sqlite;
|
||||
using odb::details::shared;
|
||||
using odb::details::shared_ptr;
|
||||
|
||||
sqlite::connection& conn (
|
||||
sqlite::transaction::current ().connection ());
|
||||
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
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++;
|
||||
}
|
||||
|
||||
std::string text (query_statement);
|
||||
if (!q.empty ())
|
||||
{
|
||||
text += " ";
|
||||
text += q.clause ();
|
||||
}
|
||||
|
||||
q.init_parameters ();
|
||||
shared_ptr<select_statement> st (
|
||||
new (shared) select_statement (
|
||||
conn,
|
||||
text,
|
||||
false,
|
||||
true,
|
||||
q.parameters_binding (),
|
||||
imb));
|
||||
|
||||
st->execute ();
|
||||
|
||||
shared_ptr< odb::object_result_impl<object_type> > r (
|
||||
new (shared) sqlite::object_result_impl<object_type> (
|
||||
q, st, sts, 0));
|
||||
|
||||
return result<object_type> (r);
|
||||
}
|
||||
|
||||
unsigned long long access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::
|
||||
erase_query (database&, const query_base_type& q)
|
||||
{
|
||||
using namespace sqlite;
|
||||
|
||||
sqlite::connection& conn (
|
||||
sqlite::transaction::current ().connection ());
|
||||
|
||||
std::string text (erase_query_statement);
|
||||
if (!q.empty ())
|
||||
{
|
||||
text += ' ';
|
||||
text += q.clause ();
|
||||
}
|
||||
|
||||
q.init_parameters ();
|
||||
delete_statement st (
|
||||
conn,
|
||||
text,
|
||||
q.parameters_binding ());
|
||||
|
||||
return st.execute ();
|
||||
}
|
||||
}
|
||||
|
||||
#include <odb/post.hxx>
|
||||
@@ -0,0 +1,298 @@
|
||||
// This file was generated by ODB, object-relational mapping (ORM)
|
||||
// compiler for C++.
|
||||
//
|
||||
|
||||
#ifndef GOVERNMENT_ADDRESS_ODB_HXX
|
||||
#define GOVERNMENT_ADDRESS_ODB_HXX
|
||||
|
||||
#include <odb/version.hxx>
|
||||
|
||||
#if (ODB_VERSION != 20400UL)
|
||||
#error ODB runtime version mismatch
|
||||
#endif
|
||||
|
||||
#include <odb/pre.hxx>
|
||||
|
||||
#include "GovernmentAddress.h"
|
||||
|
||||
#include <memory>
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
#include <odb/core.hxx>
|
||||
#include <odb/traits.hxx>
|
||||
#include <odb/callback.hxx>
|
||||
#include <odb/wrapper-traits.hxx>
|
||||
#include <odb/pointer-traits.hxx>
|
||||
#include <odb/container-traits.hxx>
|
||||
#include <odb/no-op-cache-traits.hxx>
|
||||
#include <odb/result.hxx>
|
||||
#include <odb/simple-object-result.hxx>
|
||||
|
||||
#include <odb/details/unused.hxx>
|
||||
#include <odb/details/shared-ptr.hxx>
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// GovernmentAddress
|
||||
//
|
||||
template <>
|
||||
struct class_traits< ::models::GovernmentAddress >
|
||||
{
|
||||
static const class_kind kind = class_object;
|
||||
};
|
||||
|
||||
template <>
|
||||
class access::object_traits< ::models::GovernmentAddress >
|
||||
{
|
||||
public:
|
||||
typedef ::models::GovernmentAddress object_type;
|
||||
typedef ::models::GovernmentAddress* pointer_type;
|
||||
typedef odb::pointer_traits<pointer_type> pointer_traits;
|
||||
|
||||
static const bool polymorphic = false;
|
||||
|
||||
typedef ::std::string id_type;
|
||||
|
||||
static const bool auto_id = false;
|
||||
|
||||
static const bool abstract = false;
|
||||
|
||||
static id_type
|
||||
id (const object_type&);
|
||||
|
||||
typedef
|
||||
no_op_pointer_cache_traits<pointer_type>
|
||||
pointer_cache_traits;
|
||||
|
||||
typedef
|
||||
no_op_reference_cache_traits<object_type>
|
||||
reference_cache_traits;
|
||||
|
||||
static void
|
||||
callback (database&, object_type&, callback_event);
|
||||
|
||||
static void
|
||||
callback (database&, const object_type&, callback_event);
|
||||
};
|
||||
}
|
||||
|
||||
#include <odb/details/buffer.hxx>
|
||||
|
||||
#include <odb/sqlite/version.hxx>
|
||||
#include <odb/sqlite/forward.hxx>
|
||||
#include <odb/sqlite/binding.hxx>
|
||||
#include <odb/sqlite/sqlite-types.hxx>
|
||||
#include <odb/sqlite/query.hxx>
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// GovernmentAddress
|
||||
//
|
||||
template <typename A>
|
||||
struct query_columns< ::models::GovernmentAddress, id_sqlite, A >
|
||||
{
|
||||
// id
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
id_type_;
|
||||
|
||||
static const id_type_ id;
|
||||
|
||||
// addressLabel
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
addressLabel_type_;
|
||||
|
||||
static const addressLabel_type_ addressLabel;
|
||||
|
||||
// regionLookupKey
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
regionLookupKey_type_;
|
||||
|
||||
static const regionLookupKey_type_ regionLookupKey;
|
||||
};
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::GovernmentAddress, id_sqlite, A >::id_type_
|
||||
query_columns< ::models::GovernmentAddress, id_sqlite, A >::
|
||||
id (A::table_name, "\"id\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::GovernmentAddress, id_sqlite, A >::addressLabel_type_
|
||||
query_columns< ::models::GovernmentAddress, id_sqlite, A >::
|
||||
addressLabel (A::table_name, "\"addressLabel\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::GovernmentAddress, id_sqlite, A >::regionLookupKey_type_
|
||||
query_columns< ::models::GovernmentAddress, id_sqlite, A >::
|
||||
regionLookupKey (A::table_name, "\"regionLookupKey\"", 0);
|
||||
|
||||
template <typename A>
|
||||
struct pointer_query_columns< ::models::GovernmentAddress, id_sqlite, A >:
|
||||
query_columns< ::models::GovernmentAddress, id_sqlite, A >
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
class access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >:
|
||||
public access::object_traits< ::models::GovernmentAddress >
|
||||
{
|
||||
public:
|
||||
struct id_image_type
|
||||
{
|
||||
details::buffer id_value;
|
||||
std::size_t id_size;
|
||||
bool id_null;
|
||||
|
||||
std::size_t version;
|
||||
};
|
||||
|
||||
struct image_type
|
||||
{
|
||||
// id
|
||||
//
|
||||
details::buffer id_value;
|
||||
std::size_t id_size;
|
||||
bool id_null;
|
||||
|
||||
// addressLabel
|
||||
//
|
||||
details::buffer addressLabel_value;
|
||||
std::size_t addressLabel_size;
|
||||
bool addressLabel_null;
|
||||
|
||||
// regionLookupKey
|
||||
//
|
||||
details::buffer regionLookupKey_value;
|
||||
std::size_t regionLookupKey_size;
|
||||
bool regionLookupKey_null;
|
||||
|
||||
std::size_t version;
|
||||
};
|
||||
|
||||
struct extra_statement_cache_type;
|
||||
|
||||
using object_traits<object_type>::id;
|
||||
|
||||
static id_type
|
||||
id (const image_type&);
|
||||
|
||||
static bool
|
||||
grow (image_type&,
|
||||
bool*);
|
||||
|
||||
static void
|
||||
bind (sqlite::bind*,
|
||||
image_type&,
|
||||
sqlite::statement_kind);
|
||||
|
||||
static void
|
||||
bind (sqlite::bind*, id_image_type&);
|
||||
|
||||
static bool
|
||||
init (image_type&,
|
||||
const object_type&,
|
||||
sqlite::statement_kind);
|
||||
|
||||
static void
|
||||
init (object_type&,
|
||||
const image_type&,
|
||||
database*);
|
||||
|
||||
static void
|
||||
init (id_image_type&, const id_type&);
|
||||
|
||||
typedef sqlite::object_statements<object_type> statements_type;
|
||||
|
||||
typedef sqlite::query_base query_base_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 const char query_statement[];
|
||||
static const char erase_query_statement[];
|
||||
|
||||
static const char table_name[];
|
||||
|
||||
static void
|
||||
persist (database&, const 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&);
|
||||
|
||||
static result<object_type>
|
||||
query (database&, const query_base_type&);
|
||||
|
||||
static unsigned long long
|
||||
erase_query (database&, const query_base_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< ::models::GovernmentAddress, id_common >:
|
||||
public access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >
|
||||
{
|
||||
};
|
||||
|
||||
// GovernmentAddress
|
||||
//
|
||||
}
|
||||
|
||||
#include "GovernmentAddress-odb.ixx"
|
||||
|
||||
#include <odb/post.hxx>
|
||||
|
||||
#endif // GOVERNMENT_ADDRESS_ODB_HXX
|
||||
@@ -0,0 +1,61 @@
|
||||
// This file was generated by ODB, object-relational mapping (ORM)
|
||||
// compiler for C++.
|
||||
//
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// GovernmentAddress
|
||||
//
|
||||
|
||||
inline
|
||||
access::object_traits< ::models::GovernmentAddress >::id_type
|
||||
access::object_traits< ::models::GovernmentAddress >::
|
||||
id (const object_type& o)
|
||||
{
|
||||
return o.id;
|
||||
}
|
||||
|
||||
inline
|
||||
void access::object_traits< ::models::GovernmentAddress >::
|
||||
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< ::models::GovernmentAddress >::
|
||||
callback (database& db, const object_type& x, callback_event e)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
ODB_POTENTIALLY_UNUSED (x);
|
||||
ODB_POTENTIALLY_UNUSED (e);
|
||||
}
|
||||
}
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// GovernmentAddress
|
||||
//
|
||||
|
||||
inline
|
||||
void access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::
|
||||
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< ::models::GovernmentAddress, id_sqlite >::
|
||||
load_ (statements_type& sts,
|
||||
object_type& obj,
|
||||
bool)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (sts);
|
||||
ODB_POTENTIALLY_UNUSED (obj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" database="sqlite" version="1">
|
||||
<changeset version="2">
|
||||
<add-table name="GovernmentAddress" kind="object">
|
||||
<column name="id" type="TEXT" null="false"/>
|
||||
<column name="addressLabel" type="TEXT" null="false"/>
|
||||
<column name="regionLookupKey" type="TEXT" null="false"/>
|
||||
<primary-key>
|
||||
<column name="id"/>
|
||||
</primary-key>
|
||||
</add-table>
|
||||
</changeset>
|
||||
|
||||
<model version="1"/>
|
||||
</changelog>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,505 @@
|
||||
// This file was generated by ODB, object-relational mapping (ORM)
|
||||
// compiler for C++.
|
||||
//
|
||||
|
||||
#ifndef TRIP_ATTEMPT_RESULT_ODB_HXX
|
||||
#define TRIP_ATTEMPT_RESULT_ODB_HXX
|
||||
|
||||
#include <odb/version.hxx>
|
||||
|
||||
#if (ODB_VERSION != 20400UL)
|
||||
#error ODB runtime version mismatch
|
||||
#endif
|
||||
|
||||
#include <odb/pre.hxx>
|
||||
|
||||
#include "TripAttemptResult.h"
|
||||
|
||||
#include <memory>
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
#include <odb/core.hxx>
|
||||
#include <odb/traits.hxx>
|
||||
#include <odb/callback.hxx>
|
||||
#include <odb/wrapper-traits.hxx>
|
||||
#include <odb/pointer-traits.hxx>
|
||||
#include <odb/container-traits.hxx>
|
||||
#include <odb/no-op-cache-traits.hxx>
|
||||
#include <odb/result.hxx>
|
||||
#include <odb/simple-object-result.hxx>
|
||||
|
||||
#include <odb/details/unused.hxx>
|
||||
#include <odb/details/shared-ptr.hxx>
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// TripAttemptResult
|
||||
//
|
||||
template <>
|
||||
struct class_traits< ::models::TripAttemptResult >
|
||||
{
|
||||
static const class_kind kind = class_object;
|
||||
};
|
||||
|
||||
template <>
|
||||
class access::object_traits< ::models::TripAttemptResult >
|
||||
{
|
||||
public:
|
||||
typedef ::models::TripAttemptResult object_type;
|
||||
typedef ::models::TripAttemptResult* pointer_type;
|
||||
typedef odb::pointer_traits<pointer_type> pointer_traits;
|
||||
|
||||
static const bool polymorphic = false;
|
||||
|
||||
typedef ::std::string id_type;
|
||||
|
||||
static const bool auto_id = false;
|
||||
|
||||
static const bool abstract = false;
|
||||
|
||||
static id_type
|
||||
id (const object_type&);
|
||||
|
||||
typedef
|
||||
no_op_pointer_cache_traits<pointer_type>
|
||||
pointer_cache_traits;
|
||||
|
||||
typedef
|
||||
no_op_reference_cache_traits<object_type>
|
||||
reference_cache_traits;
|
||||
|
||||
static void
|
||||
callback (database&, object_type&, callback_event);
|
||||
|
||||
static void
|
||||
callback (database&, const object_type&, callback_event);
|
||||
};
|
||||
}
|
||||
|
||||
#include <odb/details/buffer.hxx>
|
||||
|
||||
#include <odb/sqlite/version.hxx>
|
||||
#include <odb/sqlite/forward.hxx>
|
||||
#include <odb/sqlite/binding.hxx>
|
||||
#include <odb/sqlite/sqlite-types.hxx>
|
||||
#include <odb/sqlite/query.hxx>
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// TripAttemptResult
|
||||
//
|
||||
template <typename A>
|
||||
struct query_columns< ::models::TripAttemptResult, id_sqlite, A >
|
||||
{
|
||||
// id
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
id_type_;
|
||||
|
||||
static const id_type_ id;
|
||||
|
||||
// result
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
result_type_;
|
||||
|
||||
static const result_type_ result;
|
||||
|
||||
// retryReason
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
retryReason_type_;
|
||||
|
||||
static const retryReason_type_ retryReason;
|
||||
|
||||
// governmentSuspensionReason
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
governmentSuspensionReason_type_;
|
||||
|
||||
static const governmentSuspensionReason_type_ governmentSuspensionReason;
|
||||
|
||||
// governmentTerminationReason
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
governmentTerminationReason_type_;
|
||||
|
||||
static const governmentTerminationReason_type_ governmentTerminationReason;
|
||||
|
||||
// complianceSuspensionReason
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
complianceSuspensionReason_type_;
|
||||
|
||||
static const complianceSuspensionReason_type_ complianceSuspensionReason;
|
||||
|
||||
// complianceTerminationReason
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
complianceTerminationReason_type_;
|
||||
|
||||
static const complianceTerminationReason_type_ complianceTerminationReason;
|
||||
|
||||
// policySuspensionReason
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
policySuspensionReason_type_;
|
||||
|
||||
static const policySuspensionReason_type_ policySuspensionReason;
|
||||
|
||||
// policyTerminationReason
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
policyTerminationReason_type_;
|
||||
|
||||
static const policyTerminationReason_type_ policyTerminationReason;
|
||||
|
||||
// cancelationReason
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
cancelationReason_type_;
|
||||
|
||||
static const cancelationReason_type_ cancelationReason;
|
||||
|
||||
// failureReason
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
failureReason_type_;
|
||||
|
||||
static const failureReason_type_ failureReason;
|
||||
|
||||
// details
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
details_type_;
|
||||
|
||||
static const details_type_ details;
|
||||
};
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_sqlite, A >::id_type_
|
||||
query_columns< ::models::TripAttemptResult, id_sqlite, A >::
|
||||
id (A::table_name, "\"id\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_sqlite, A >::result_type_
|
||||
query_columns< ::models::TripAttemptResult, id_sqlite, A >::
|
||||
result (A::table_name, "\"result\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_sqlite, A >::retryReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_sqlite, A >::
|
||||
retryReason (A::table_name, "\"retryReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_sqlite, A >::governmentSuspensionReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_sqlite, A >::
|
||||
governmentSuspensionReason (A::table_name, "\"governmentSuspensionReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_sqlite, A >::governmentTerminationReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_sqlite, A >::
|
||||
governmentTerminationReason (A::table_name, "\"governmentTerminationReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_sqlite, A >::complianceSuspensionReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_sqlite, A >::
|
||||
complianceSuspensionReason (A::table_name, "\"complianceSuspensionReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_sqlite, A >::complianceTerminationReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_sqlite, A >::
|
||||
complianceTerminationReason (A::table_name, "\"complianceTerminationReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_sqlite, A >::policySuspensionReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_sqlite, A >::
|
||||
policySuspensionReason (A::table_name, "\"policySuspensionReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_sqlite, A >::policyTerminationReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_sqlite, A >::
|
||||
policyTerminationReason (A::table_name, "\"policyTerminationReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_sqlite, A >::cancelationReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_sqlite, A >::
|
||||
cancelationReason (A::table_name, "\"cancelationReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_sqlite, A >::failureReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_sqlite, A >::
|
||||
failureReason (A::table_name, "\"failureReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_sqlite, A >::details_type_
|
||||
query_columns< ::models::TripAttemptResult, id_sqlite, A >::
|
||||
details (A::table_name, "\"details\"", 0);
|
||||
|
||||
template <typename A>
|
||||
struct pointer_query_columns< ::models::TripAttemptResult, id_sqlite, A >:
|
||||
query_columns< ::models::TripAttemptResult, id_sqlite, A >
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
class access::object_traits_impl< ::models::TripAttemptResult, id_sqlite >:
|
||||
public access::object_traits< ::models::TripAttemptResult >
|
||||
{
|
||||
public:
|
||||
struct id_image_type
|
||||
{
|
||||
details::buffer id_value;
|
||||
std::size_t id_size;
|
||||
bool id_null;
|
||||
|
||||
std::size_t version;
|
||||
};
|
||||
|
||||
struct image_type
|
||||
{
|
||||
// id
|
||||
//
|
||||
details::buffer id_value;
|
||||
std::size_t id_size;
|
||||
bool id_null;
|
||||
|
||||
// result
|
||||
//
|
||||
details::buffer result_value;
|
||||
std::size_t result_size;
|
||||
bool result_null;
|
||||
|
||||
// retryReason
|
||||
//
|
||||
details::buffer retryReason_value;
|
||||
std::size_t retryReason_size;
|
||||
bool retryReason_null;
|
||||
|
||||
// governmentSuspensionReason
|
||||
//
|
||||
details::buffer governmentSuspensionReason_value;
|
||||
std::size_t governmentSuspensionReason_size;
|
||||
bool governmentSuspensionReason_null;
|
||||
|
||||
// governmentTerminationReason
|
||||
//
|
||||
details::buffer governmentTerminationReason_value;
|
||||
std::size_t governmentTerminationReason_size;
|
||||
bool governmentTerminationReason_null;
|
||||
|
||||
// complianceSuspensionReason
|
||||
//
|
||||
details::buffer complianceSuspensionReason_value;
|
||||
std::size_t complianceSuspensionReason_size;
|
||||
bool complianceSuspensionReason_null;
|
||||
|
||||
// complianceTerminationReason
|
||||
//
|
||||
details::buffer complianceTerminationReason_value;
|
||||
std::size_t complianceTerminationReason_size;
|
||||
bool complianceTerminationReason_null;
|
||||
|
||||
// policySuspensionReason
|
||||
//
|
||||
details::buffer policySuspensionReason_value;
|
||||
std::size_t policySuspensionReason_size;
|
||||
bool policySuspensionReason_null;
|
||||
|
||||
// policyTerminationReason
|
||||
//
|
||||
details::buffer policyTerminationReason_value;
|
||||
std::size_t policyTerminationReason_size;
|
||||
bool policyTerminationReason_null;
|
||||
|
||||
// cancelationReason
|
||||
//
|
||||
details::buffer cancelationReason_value;
|
||||
std::size_t cancelationReason_size;
|
||||
bool cancelationReason_null;
|
||||
|
||||
// failureReason
|
||||
//
|
||||
details::buffer failureReason_value;
|
||||
std::size_t failureReason_size;
|
||||
bool failureReason_null;
|
||||
|
||||
// details
|
||||
//
|
||||
details::buffer details_value;
|
||||
std::size_t details_size;
|
||||
bool details_null;
|
||||
|
||||
std::size_t version;
|
||||
};
|
||||
|
||||
struct extra_statement_cache_type;
|
||||
|
||||
using object_traits<object_type>::id;
|
||||
|
||||
static id_type
|
||||
id (const image_type&);
|
||||
|
||||
static bool
|
||||
grow (image_type&,
|
||||
bool*);
|
||||
|
||||
static void
|
||||
bind (sqlite::bind*,
|
||||
image_type&,
|
||||
sqlite::statement_kind);
|
||||
|
||||
static void
|
||||
bind (sqlite::bind*, id_image_type&);
|
||||
|
||||
static bool
|
||||
init (image_type&,
|
||||
const object_type&,
|
||||
sqlite::statement_kind);
|
||||
|
||||
static void
|
||||
init (object_type&,
|
||||
const image_type&,
|
||||
database*);
|
||||
|
||||
static void
|
||||
init (id_image_type&, const id_type&);
|
||||
|
||||
typedef sqlite::object_statements<object_type> statements_type;
|
||||
|
||||
typedef sqlite::query_base query_base_type;
|
||||
|
||||
static const std::size_t column_count = 12UL;
|
||||
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 const char query_statement[];
|
||||
static const char erase_query_statement[];
|
||||
|
||||
static const char table_name[];
|
||||
|
||||
static void
|
||||
persist (database&, const 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&);
|
||||
|
||||
static result<object_type>
|
||||
query (database&, const query_base_type&);
|
||||
|
||||
static unsigned long long
|
||||
erase_query (database&, const query_base_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< ::models::TripAttemptResult, id_common >:
|
||||
public access::object_traits_impl< ::models::TripAttemptResult, id_sqlite >
|
||||
{
|
||||
};
|
||||
|
||||
// TripAttemptResult
|
||||
//
|
||||
}
|
||||
|
||||
#include "TripAttemptResult-odb.ixx"
|
||||
|
||||
#include <odb/post.hxx>
|
||||
|
||||
#endif // TRIP_ATTEMPT_RESULT_ODB_HXX
|
||||
@@ -0,0 +1,61 @@
|
||||
// This file was generated by ODB, object-relational mapping (ORM)
|
||||
// compiler for C++.
|
||||
//
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// TripAttemptResult
|
||||
//
|
||||
|
||||
inline
|
||||
access::object_traits< ::models::TripAttemptResult >::id_type
|
||||
access::object_traits< ::models::TripAttemptResult >::
|
||||
id (const object_type& o)
|
||||
{
|
||||
return o.id;
|
||||
}
|
||||
|
||||
inline
|
||||
void access::object_traits< ::models::TripAttemptResult >::
|
||||
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< ::models::TripAttemptResult >::
|
||||
callback (database& db, const object_type& x, callback_event e)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
ODB_POTENTIALLY_UNUSED (x);
|
||||
ODB_POTENTIALLY_UNUSED (e);
|
||||
}
|
||||
}
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// TripAttemptResult
|
||||
//
|
||||
|
||||
inline
|
||||
void access::object_traits_impl< ::models::TripAttemptResult, id_sqlite >::
|
||||
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< ::models::TripAttemptResult, id_sqlite >::
|
||||
load_ (statements_type& sts,
|
||||
object_type& obj,
|
||||
bool)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (sts);
|
||||
ODB_POTENTIALLY_UNUSED (obj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" database="sqlite" version="1">
|
||||
<changeset version="2">
|
||||
<add-table name="TripAttemptResult" kind="object">
|
||||
<column name="id" type="TEXT" null="false"/>
|
||||
<column name="result" type="TEXT" null="false"/>
|
||||
<column name="retryReason" type="TEXT" null="false"/>
|
||||
<column name="governmentSuspensionReason" type="TEXT" null="false"/>
|
||||
<column name="governmentTerminationReason" type="TEXT" null="false"/>
|
||||
<column name="complianceSuspensionReason" type="TEXT" null="false"/>
|
||||
<column name="complianceTerminationReason" type="TEXT" null="false"/>
|
||||
<column name="policySuspensionReason" type="TEXT" null="false"/>
|
||||
<column name="policyTerminationReason" type="TEXT" null="false"/>
|
||||
<column name="cancelationReason" type="TEXT" null="false"/>
|
||||
<column name="failureReason" type="TEXT" null="false"/>
|
||||
<column name="details" type="TEXT" null="false"/>
|
||||
<primary-key>
|
||||
<column name="id"/>
|
||||
</primary-key>
|
||||
</add-table>
|
||||
</changeset>
|
||||
|
||||
<model version="1"/>
|
||||
</changelog>
|
||||
@@ -0,0 +1,8 @@
|
||||
/* This file was generated by ODB, object-relational mapping (ORM)
|
||||
* compiler for C++.
|
||||
*/
|
||||
|
||||
UPDATE "schema_version"
|
||||
SET "migration" = FALSE
|
||||
WHERE "name" = '';
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/* This file was generated by ODB, object-relational mapping (ORM)
|
||||
* compiler for C++.
|
||||
*/
|
||||
|
||||
CREATE TABLE "Agent" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"role" TEXT NOT NULL,
|
||||
"persistent" BOOLEAN NOT NULL,
|
||||
"displayName" TEXT NOT NULL,
|
||||
"trustScore" INTEGER NOT NULL);
|
||||
|
||||
UPDATE "schema_version"
|
||||
SET "version" = 2, "migration" = TRUE
|
||||
WHERE "name" = '';
|
||||
|
||||
864
db/test-schema-v1.2/generated-sql-ddl/postgre/Agent-odb.cxx
Normal file
864
db/test-schema-v1.2/generated-sql-ddl/postgre/Agent-odb.cxx
Normal file
@@ -0,0 +1,864 @@
|
||||
// This file was generated by ODB, object-relational mapping (ORM)
|
||||
// compiler for C++.
|
||||
//
|
||||
|
||||
#include <odb/pre.hxx>
|
||||
|
||||
#include "Agent-odb.hxx"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring> // std::memcpy
|
||||
|
||||
|
||||
#include <odb/pgsql/traits.hxx>
|
||||
#include <odb/pgsql/database.hxx>
|
||||
#include <odb/pgsql/transaction.hxx>
|
||||
#include <odb/pgsql/connection.hxx>
|
||||
#include <odb/pgsql/statement.hxx>
|
||||
#include <odb/pgsql/statement-cache.hxx>
|
||||
#include <odb/pgsql/simple-object-statements.hxx>
|
||||
#include <odb/pgsql/container-statements.hxx>
|
||||
#include <odb/pgsql/exceptions.hxx>
|
||||
#include <odb/pgsql/simple-object-result.hxx>
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// Agent
|
||||
//
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
persist_statement_name[] = "persist_models_Agent";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
find_statement_name[] = "find_models_Agent";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
update_statement_name[] = "update_models_Agent";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
erase_statement_name[] = "erase_models_Agent";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
query_statement_name[] = "query_models_Agent";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
erase_query_statement_name[] = "erase_query_models_Agent";
|
||||
|
||||
const unsigned int access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
persist_statement_types[] =
|
||||
{
|
||||
pgsql::text_oid,
|
||||
pgsql::text_oid,
|
||||
pgsql::bool_oid,
|
||||
pgsql::text_oid,
|
||||
pgsql::int4_oid
|
||||
};
|
||||
|
||||
const unsigned int access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
find_statement_types[] =
|
||||
{
|
||||
pgsql::text_oid
|
||||
};
|
||||
|
||||
const unsigned int access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
update_statement_types[] =
|
||||
{
|
||||
pgsql::text_oid,
|
||||
pgsql::bool_oid,
|
||||
pgsql::text_oid,
|
||||
pgsql::int4_oid,
|
||||
pgsql::text_oid
|
||||
};
|
||||
|
||||
struct access::object_traits_impl< ::models::Agent, id_pgsql >::extra_statement_cache_type
|
||||
{
|
||||
extra_statement_cache_type (
|
||||
pgsql::connection&,
|
||||
image_type&,
|
||||
id_image_type&,
|
||||
pgsql::binding&,
|
||||
pgsql::binding&,
|
||||
pgsql::native_binding&,
|
||||
const unsigned int*)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
access::object_traits_impl< ::models::Agent, id_pgsql >::id_type
|
||||
access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
id (const image_type& i)
|
||||
{
|
||||
pgsql::database* db (0);
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
id_type id;
|
||||
{
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::set_value (
|
||||
id,
|
||||
i.id_value,
|
||||
i.id_size,
|
||||
i.id_null);
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
bool access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
grow (image_type& i,
|
||||
bool* t)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (i);
|
||||
ODB_POTENTIALLY_UNUSED (t);
|
||||
|
||||
bool grew (false);
|
||||
|
||||
// id
|
||||
//
|
||||
if (t[0UL])
|
||||
{
|
||||
i.id_value.capacity (i.id_size);
|
||||
grew = true;
|
||||
}
|
||||
|
||||
// role
|
||||
//
|
||||
if (t[1UL])
|
||||
{
|
||||
i.role_value.capacity (i.role_size);
|
||||
grew = true;
|
||||
}
|
||||
|
||||
// persistent
|
||||
//
|
||||
t[2UL] = 0;
|
||||
|
||||
// displayName
|
||||
//
|
||||
if (t[3UL])
|
||||
{
|
||||
i.displayName_value.capacity (i.displayName_size);
|
||||
grew = true;
|
||||
}
|
||||
|
||||
// trustScore
|
||||
//
|
||||
t[4UL] = 0;
|
||||
|
||||
return grew;
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
bind (pgsql::bind* b,
|
||||
image_type& i,
|
||||
pgsql::statement_kind sk)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (sk);
|
||||
|
||||
using namespace pgsql;
|
||||
|
||||
std::size_t n (0);
|
||||
|
||||
// id
|
||||
//
|
||||
if (sk != statement_update)
|
||||
{
|
||||
b[n].type = pgsql::bind::text;
|
||||
b[n].buffer = i.id_value.data ();
|
||||
b[n].capacity = i.id_value.capacity ();
|
||||
b[n].size = &i.id_size;
|
||||
b[n].is_null = &i.id_null;
|
||||
n++;
|
||||
}
|
||||
|
||||
// role
|
||||
//
|
||||
b[n].type = pgsql::bind::text;
|
||||
b[n].buffer = i.role_value.data ();
|
||||
b[n].capacity = i.role_value.capacity ();
|
||||
b[n].size = &i.role_size;
|
||||
b[n].is_null = &i.role_null;
|
||||
n++;
|
||||
|
||||
// persistent
|
||||
//
|
||||
b[n].type = pgsql::bind::boolean_;
|
||||
b[n].buffer = &i.persistent_value;
|
||||
b[n].is_null = &i.persistent_null;
|
||||
n++;
|
||||
|
||||
// displayName
|
||||
//
|
||||
b[n].type = pgsql::bind::text;
|
||||
b[n].buffer = i.displayName_value.data ();
|
||||
b[n].capacity = i.displayName_value.capacity ();
|
||||
b[n].size = &i.displayName_size;
|
||||
b[n].is_null = &i.displayName_null;
|
||||
n++;
|
||||
|
||||
// trustScore
|
||||
//
|
||||
b[n].type = pgsql::bind::integer;
|
||||
b[n].buffer = &i.trustScore_value;
|
||||
b[n].is_null = &i.trustScore_null;
|
||||
n++;
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
bind (pgsql::bind* b, id_image_type& i)
|
||||
{
|
||||
std::size_t n (0);
|
||||
b[n].type = pgsql::bind::text;
|
||||
b[n].buffer = i.id_value.data ();
|
||||
b[n].capacity = i.id_value.capacity ();
|
||||
b[n].size = &i.id_size;
|
||||
b[n].is_null = &i.id_null;
|
||||
}
|
||||
|
||||
bool access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
init (image_type& i,
|
||||
const object_type& o,
|
||||
pgsql::statement_kind sk)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (i);
|
||||
ODB_POTENTIALLY_UNUSED (o);
|
||||
ODB_POTENTIALLY_UNUSED (sk);
|
||||
|
||||
using namespace pgsql;
|
||||
|
||||
bool grew (false);
|
||||
|
||||
// id
|
||||
//
|
||||
if (sk == statement_insert)
|
||||
{
|
||||
::std::string const& v =
|
||||
o.id;
|
||||
|
||||
bool is_null (false);
|
||||
std::size_t size (0);
|
||||
std::size_t cap (i.id_value.capacity ());
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::set_image (
|
||||
i.id_value,
|
||||
size,
|
||||
is_null,
|
||||
v);
|
||||
i.id_null = is_null;
|
||||
i.id_size = size;
|
||||
grew = grew || (cap != i.id_value.capacity ());
|
||||
}
|
||||
|
||||
// role
|
||||
//
|
||||
{
|
||||
::std::string const& v =
|
||||
o.role;
|
||||
|
||||
bool is_null (false);
|
||||
std::size_t size (0);
|
||||
std::size_t cap (i.role_value.capacity ());
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::set_image (
|
||||
i.role_value,
|
||||
size,
|
||||
is_null,
|
||||
v);
|
||||
i.role_null = is_null;
|
||||
i.role_size = size;
|
||||
grew = grew || (cap != i.role_value.capacity ());
|
||||
}
|
||||
|
||||
// persistent
|
||||
//
|
||||
{
|
||||
bool const& v =
|
||||
o.persistent;
|
||||
|
||||
bool is_null (false);
|
||||
pgsql::value_traits<
|
||||
bool,
|
||||
pgsql::id_boolean >::set_image (
|
||||
i.persistent_value, is_null, v);
|
||||
i.persistent_null = is_null;
|
||||
}
|
||||
|
||||
// displayName
|
||||
//
|
||||
{
|
||||
::std::string const& v =
|
||||
o.displayName;
|
||||
|
||||
bool is_null (false);
|
||||
std::size_t size (0);
|
||||
std::size_t cap (i.displayName_value.capacity ());
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::set_image (
|
||||
i.displayName_value,
|
||||
size,
|
||||
is_null,
|
||||
v);
|
||||
i.displayName_null = is_null;
|
||||
i.displayName_size = size;
|
||||
grew = grew || (cap != i.displayName_value.capacity ());
|
||||
}
|
||||
|
||||
// trustScore
|
||||
//
|
||||
{
|
||||
::int32_t const& v =
|
||||
o.trustScore;
|
||||
|
||||
bool is_null (false);
|
||||
pgsql::value_traits<
|
||||
::int32_t,
|
||||
pgsql::id_integer >::set_image (
|
||||
i.trustScore_value, is_null, v);
|
||||
i.trustScore_null = is_null;
|
||||
}
|
||||
|
||||
return grew;
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
init (object_type& o,
|
||||
const image_type& i,
|
||||
database* db)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (o);
|
||||
ODB_POTENTIALLY_UNUSED (i);
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
// id
|
||||
//
|
||||
{
|
||||
::std::string& v =
|
||||
o.id;
|
||||
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::set_value (
|
||||
v,
|
||||
i.id_value,
|
||||
i.id_size,
|
||||
i.id_null);
|
||||
}
|
||||
|
||||
// role
|
||||
//
|
||||
{
|
||||
::std::string& v =
|
||||
o.role;
|
||||
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::set_value (
|
||||
v,
|
||||
i.role_value,
|
||||
i.role_size,
|
||||
i.role_null);
|
||||
}
|
||||
|
||||
// persistent
|
||||
//
|
||||
{
|
||||
bool& v =
|
||||
o.persistent;
|
||||
|
||||
pgsql::value_traits<
|
||||
bool,
|
||||
pgsql::id_boolean >::set_value (
|
||||
v,
|
||||
i.persistent_value,
|
||||
i.persistent_null);
|
||||
}
|
||||
|
||||
// displayName
|
||||
//
|
||||
{
|
||||
::std::string& v =
|
||||
o.displayName;
|
||||
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::set_value (
|
||||
v,
|
||||
i.displayName_value,
|
||||
i.displayName_size,
|
||||
i.displayName_null);
|
||||
}
|
||||
|
||||
// trustScore
|
||||
//
|
||||
{
|
||||
::int32_t& v =
|
||||
o.trustScore;
|
||||
|
||||
pgsql::value_traits<
|
||||
::int32_t,
|
||||
pgsql::id_integer >::set_value (
|
||||
v,
|
||||
i.trustScore_value,
|
||||
i.trustScore_null);
|
||||
}
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
init (id_image_type& i, const id_type& id)
|
||||
{
|
||||
bool grew (false);
|
||||
{
|
||||
bool is_null (false);
|
||||
std::size_t size (0);
|
||||
std::size_t cap (i.id_value.capacity ());
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::set_image (
|
||||
i.id_value,
|
||||
size,
|
||||
is_null,
|
||||
id);
|
||||
i.id_null = is_null;
|
||||
i.id_size = size;
|
||||
grew = grew || (cap != i.id_value.capacity ());
|
||||
}
|
||||
|
||||
if (grew)
|
||||
i.version++;
|
||||
}
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_pgsql >::persist_statement[] =
|
||||
"INSERT INTO \"Agent\" "
|
||||
"(\"id\", "
|
||||
"\"role\", "
|
||||
"\"persistent\", "
|
||||
"\"displayName\", "
|
||||
"\"trustScore\") "
|
||||
"VALUES "
|
||||
"($1, $2, $3, $4, $5)";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_pgsql >::find_statement[] =
|
||||
"SELECT "
|
||||
"\"Agent\".\"id\", "
|
||||
"\"Agent\".\"role\", "
|
||||
"\"Agent\".\"persistent\", "
|
||||
"\"Agent\".\"displayName\", "
|
||||
"\"Agent\".\"trustScore\" "
|
||||
"FROM \"Agent\" "
|
||||
"WHERE \"Agent\".\"id\"=$1";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_pgsql >::update_statement[] =
|
||||
"UPDATE \"Agent\" "
|
||||
"SET "
|
||||
"\"role\"=$1, "
|
||||
"\"persistent\"=$2, "
|
||||
"\"displayName\"=$3, "
|
||||
"\"trustScore\"=$4 "
|
||||
"WHERE \"id\"=$5";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_pgsql >::erase_statement[] =
|
||||
"DELETE FROM \"Agent\" "
|
||||
"WHERE \"id\"=$1";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_pgsql >::query_statement[] =
|
||||
"SELECT "
|
||||
"\"Agent\".\"id\", "
|
||||
"\"Agent\".\"role\", "
|
||||
"\"Agent\".\"persistent\", "
|
||||
"\"Agent\".\"displayName\", "
|
||||
"\"Agent\".\"trustScore\" "
|
||||
"FROM \"Agent\"";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_pgsql >::erase_query_statement[] =
|
||||
"DELETE FROM \"Agent\"";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_pgsql >::table_name[] =
|
||||
"\"Agent\"";
|
||||
|
||||
void access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
persist (database& db, const object_type& obj)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
using namespace pgsql;
|
||||
|
||||
pgsql::connection& conn (
|
||||
pgsql::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
callback (db,
|
||||
obj,
|
||||
callback_event::pre_persist);
|
||||
|
||||
image_type& im (sts.image ());
|
||||
binding& imb (sts.insert_image_binding ());
|
||||
|
||||
if (init (im, obj, statement_insert))
|
||||
im.version++;
|
||||
|
||||
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 ();
|
||||
|
||||
callback (db,
|
||||
obj,
|
||||
callback_event::post_persist);
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
update (database& db, const object_type& obj)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
using namespace pgsql;
|
||||
using pgsql::update_statement;
|
||||
|
||||
callback (db, obj, callback_event::pre_update);
|
||||
|
||||
pgsql::transaction& tr (pgsql::transaction::current ());
|
||||
pgsql::connection& conn (tr.connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
const id_type& id (
|
||||
obj.id);
|
||||
id_image_type& idi (sts.id_image ());
|
||||
init (idi, id);
|
||||
|
||||
image_type& im (sts.image ());
|
||||
if (init (im, obj, statement_update))
|
||||
im.version++;
|
||||
|
||||
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< ::models::Agent, id_pgsql >::
|
||||
erase (database& db, const id_type& id)
|
||||
{
|
||||
using namespace pgsql;
|
||||
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
pgsql::connection& conn (
|
||||
pgsql::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
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< ::models::Agent, id_pgsql >::pointer_type
|
||||
access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
find (database& db, const id_type& id)
|
||||
{
|
||||
using namespace pgsql;
|
||||
|
||||
{
|
||||
pointer_type p (pointer_cache_traits::find (db, id));
|
||||
|
||||
if (!pointer_traits::null_ptr (p))
|
||||
return p;
|
||||
}
|
||||
|
||||
pgsql::connection& conn (
|
||||
pgsql::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
statements_type::auto_lock l (sts);
|
||||
|
||||
if (l.locked ())
|
||||
{
|
||||
if (!find_ (sts, &id))
|
||||
return pointer_type ();
|
||||
}
|
||||
|
||||
pointer_type p (
|
||||
access::object_factory<object_type, pointer_type>::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);
|
||||
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< ::models::Agent, id_pgsql >::
|
||||
find (database& db, const id_type& id, object_type& obj)
|
||||
{
|
||||
using namespace pgsql;
|
||||
|
||||
pgsql::connection& conn (
|
||||
pgsql::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
statements_type::auto_lock l (sts);
|
||||
|
||||
if (!find_ (sts, &id))
|
||||
return false;
|
||||
|
||||
select_statement& st (sts.find_statement ());
|
||||
ODB_POTENTIALLY_UNUSED (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);
|
||||
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< ::models::Agent, id_pgsql >::
|
||||
reload (database& db, object_type& obj)
|
||||
{
|
||||
using namespace pgsql;
|
||||
|
||||
pgsql::connection& conn (
|
||||
pgsql::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
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);
|
||||
|
||||
callback (db, obj, callback_event::pre_load);
|
||||
init (obj, sts.image (), &db);
|
||||
load_ (sts, obj, true);
|
||||
sts.load_delayed (0);
|
||||
l.unlock ();
|
||||
callback (db, obj, callback_event::post_load);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
find_ (statements_type& sts,
|
||||
const id_type* id)
|
||||
{
|
||||
using namespace pgsql;
|
||||
|
||||
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::truncated)
|
||||
{
|
||||
if (grow (im, sts.select_image_truncated ()))
|
||||
im.version++;
|
||||
|
||||
if (im.version != sts.select_image_version ())
|
||||
{
|
||||
bind (imb.bind, im, statement_select);
|
||||
sts.select_image_version (im.version);
|
||||
imb.version++;
|
||||
st.refetch ();
|
||||
}
|
||||
}
|
||||
|
||||
return r != select_statement::no_data;
|
||||
}
|
||||
|
||||
result< access::object_traits_impl< ::models::Agent, id_pgsql >::object_type >
|
||||
access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
query (database&, const query_base_type& q)
|
||||
{
|
||||
using namespace pgsql;
|
||||
using odb::details::shared;
|
||||
using odb::details::shared_ptr;
|
||||
|
||||
pgsql::connection& conn (
|
||||
pgsql::transaction::current ().connection ());
|
||||
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
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++;
|
||||
}
|
||||
|
||||
std::string text (query_statement);
|
||||
if (!q.empty ())
|
||||
{
|
||||
text += " ";
|
||||
text += q.clause ();
|
||||
}
|
||||
|
||||
q.init_parameters ();
|
||||
shared_ptr<select_statement> st (
|
||||
new (shared) select_statement (
|
||||
sts.connection (),
|
||||
query_statement_name,
|
||||
text,
|
||||
false,
|
||||
true,
|
||||
q.parameter_types (),
|
||||
q.parameter_count (),
|
||||
q.parameters_binding (),
|
||||
imb));
|
||||
|
||||
st->execute ();
|
||||
st->deallocate ();
|
||||
|
||||
shared_ptr< odb::object_result_impl<object_type> > r (
|
||||
new (shared) pgsql::object_result_impl<object_type> (
|
||||
q, st, sts, 0));
|
||||
|
||||
return result<object_type> (r);
|
||||
}
|
||||
|
||||
unsigned long long access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
erase_query (database&, const query_base_type& q)
|
||||
{
|
||||
using namespace pgsql;
|
||||
|
||||
pgsql::connection& conn (
|
||||
pgsql::transaction::current ().connection ());
|
||||
|
||||
std::string text (erase_query_statement);
|
||||
if (!q.empty ())
|
||||
{
|
||||
text += ' ';
|
||||
text += q.clause ();
|
||||
}
|
||||
|
||||
q.init_parameters ();
|
||||
delete_statement st (
|
||||
conn,
|
||||
erase_query_statement_name,
|
||||
text,
|
||||
q.parameter_types (),
|
||||
q.parameter_count (),
|
||||
q.parameters_binding ());
|
||||
|
||||
return st.execute ();
|
||||
}
|
||||
}
|
||||
|
||||
#include <odb/post.hxx>
|
||||
353
db/test-schema-v1.2/generated-sql-ddl/postgre/Agent-odb.hxx
Normal file
353
db/test-schema-v1.2/generated-sql-ddl/postgre/Agent-odb.hxx
Normal file
@@ -0,0 +1,353 @@
|
||||
// This file was generated by ODB, object-relational mapping (ORM)
|
||||
// compiler for C++.
|
||||
//
|
||||
|
||||
#ifndef AGENT_ODB_HXX
|
||||
#define AGENT_ODB_HXX
|
||||
|
||||
#include <odb/version.hxx>
|
||||
|
||||
#if (ODB_VERSION != 20400UL)
|
||||
#error ODB runtime version mismatch
|
||||
#endif
|
||||
|
||||
#include <odb/pre.hxx>
|
||||
|
||||
#include "Agent.h"
|
||||
|
||||
#include <memory>
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
#include <odb/core.hxx>
|
||||
#include <odb/traits.hxx>
|
||||
#include <odb/callback.hxx>
|
||||
#include <odb/wrapper-traits.hxx>
|
||||
#include <odb/pointer-traits.hxx>
|
||||
#include <odb/container-traits.hxx>
|
||||
#include <odb/no-op-cache-traits.hxx>
|
||||
#include <odb/result.hxx>
|
||||
#include <odb/simple-object-result.hxx>
|
||||
|
||||
#include <odb/details/unused.hxx>
|
||||
#include <odb/details/shared-ptr.hxx>
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// Agent
|
||||
//
|
||||
template <>
|
||||
struct class_traits< ::models::Agent >
|
||||
{
|
||||
static const class_kind kind = class_object;
|
||||
};
|
||||
|
||||
template <>
|
||||
class access::object_traits< ::models::Agent >
|
||||
{
|
||||
public:
|
||||
typedef ::models::Agent object_type;
|
||||
typedef ::models::Agent* pointer_type;
|
||||
typedef odb::pointer_traits<pointer_type> pointer_traits;
|
||||
|
||||
static const bool polymorphic = false;
|
||||
|
||||
typedef ::std::string id_type;
|
||||
|
||||
static const bool auto_id = false;
|
||||
|
||||
static const bool abstract = false;
|
||||
|
||||
static id_type
|
||||
id (const object_type&);
|
||||
|
||||
typedef
|
||||
no_op_pointer_cache_traits<pointer_type>
|
||||
pointer_cache_traits;
|
||||
|
||||
typedef
|
||||
no_op_reference_cache_traits<object_type>
|
||||
reference_cache_traits;
|
||||
|
||||
static void
|
||||
callback (database&, object_type&, callback_event);
|
||||
|
||||
static void
|
||||
callback (database&, const object_type&, callback_event);
|
||||
};
|
||||
}
|
||||
|
||||
#include <odb/details/buffer.hxx>
|
||||
|
||||
#include <odb/pgsql/version.hxx>
|
||||
#include <odb/pgsql/forward.hxx>
|
||||
#include <odb/pgsql/binding.hxx>
|
||||
#include <odb/pgsql/pgsql-types.hxx>
|
||||
#include <odb/pgsql/query.hxx>
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// Agent
|
||||
//
|
||||
template <typename A>
|
||||
struct query_columns< ::models::Agent, id_pgsql, A >
|
||||
{
|
||||
// id
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
id_type_;
|
||||
|
||||
static const id_type_ id;
|
||||
|
||||
// role
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
role_type_;
|
||||
|
||||
static const role_type_ role;
|
||||
|
||||
// persistent
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
bool,
|
||||
pgsql::id_boolean >::query_type,
|
||||
pgsql::id_boolean >
|
||||
persistent_type_;
|
||||
|
||||
static const persistent_type_ persistent;
|
||||
|
||||
// displayName
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
displayName_type_;
|
||||
|
||||
static const displayName_type_ displayName;
|
||||
|
||||
// trustScore
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::int32_t,
|
||||
pgsql::id_integer >::query_type,
|
||||
pgsql::id_integer >
|
||||
trustScore_type_;
|
||||
|
||||
static const trustScore_type_ trustScore;
|
||||
};
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::Agent, id_pgsql, A >::id_type_
|
||||
query_columns< ::models::Agent, id_pgsql, A >::
|
||||
id (A::table_name, "\"id\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::Agent, id_pgsql, A >::role_type_
|
||||
query_columns< ::models::Agent, id_pgsql, A >::
|
||||
role (A::table_name, "\"role\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::Agent, id_pgsql, A >::persistent_type_
|
||||
query_columns< ::models::Agent, id_pgsql, A >::
|
||||
persistent (A::table_name, "\"persistent\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::Agent, id_pgsql, A >::displayName_type_
|
||||
query_columns< ::models::Agent, id_pgsql, A >::
|
||||
displayName (A::table_name, "\"displayName\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::Agent, id_pgsql, A >::trustScore_type_
|
||||
query_columns< ::models::Agent, id_pgsql, A >::
|
||||
trustScore (A::table_name, "\"trustScore\"", 0);
|
||||
|
||||
template <typename A>
|
||||
struct pointer_query_columns< ::models::Agent, id_pgsql, A >:
|
||||
query_columns< ::models::Agent, id_pgsql, A >
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
class access::object_traits_impl< ::models::Agent, id_pgsql >:
|
||||
public access::object_traits< ::models::Agent >
|
||||
{
|
||||
public:
|
||||
struct id_image_type
|
||||
{
|
||||
details::buffer id_value;
|
||||
std::size_t id_size;
|
||||
bool id_null;
|
||||
|
||||
std::size_t version;
|
||||
};
|
||||
|
||||
struct image_type
|
||||
{
|
||||
// id
|
||||
//
|
||||
details::buffer id_value;
|
||||
std::size_t id_size;
|
||||
bool id_null;
|
||||
|
||||
// role
|
||||
//
|
||||
details::buffer role_value;
|
||||
std::size_t role_size;
|
||||
bool role_null;
|
||||
|
||||
// persistent
|
||||
//
|
||||
bool persistent_value;
|
||||
bool persistent_null;
|
||||
|
||||
// displayName
|
||||
//
|
||||
details::buffer displayName_value;
|
||||
std::size_t displayName_size;
|
||||
bool displayName_null;
|
||||
|
||||
// trustScore
|
||||
//
|
||||
int trustScore_value;
|
||||
bool trustScore_null;
|
||||
|
||||
std::size_t version;
|
||||
};
|
||||
|
||||
struct extra_statement_cache_type;
|
||||
|
||||
using object_traits<object_type>::id;
|
||||
|
||||
static id_type
|
||||
id (const image_type&);
|
||||
|
||||
static bool
|
||||
grow (image_type&,
|
||||
bool*);
|
||||
|
||||
static void
|
||||
bind (pgsql::bind*,
|
||||
image_type&,
|
||||
pgsql::statement_kind);
|
||||
|
||||
static void
|
||||
bind (pgsql::bind*, id_image_type&);
|
||||
|
||||
static bool
|
||||
init (image_type&,
|
||||
const object_type&,
|
||||
pgsql::statement_kind);
|
||||
|
||||
static void
|
||||
init (object_type&,
|
||||
const image_type&,
|
||||
database*);
|
||||
|
||||
static void
|
||||
init (id_image_type&, const id_type&);
|
||||
|
||||
typedef pgsql::object_statements<object_type> statements_type;
|
||||
|
||||
typedef pgsql::query_base query_base_type;
|
||||
|
||||
static const std::size_t column_count = 5UL;
|
||||
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 const char query_statement[];
|
||||
static const char erase_query_statement[];
|
||||
|
||||
static const char table_name[];
|
||||
|
||||
static void
|
||||
persist (database&, const 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&);
|
||||
|
||||
static result<object_type>
|
||||
query (database&, const query_base_type&);
|
||||
|
||||
static unsigned long long
|
||||
erase_query (database&, const query_base_type&);
|
||||
|
||||
static const char persist_statement_name[];
|
||||
static const char find_statement_name[];
|
||||
static const char update_statement_name[];
|
||||
static const char erase_statement_name[];
|
||||
static const char query_statement_name[];
|
||||
static const char erase_query_statement_name[];
|
||||
|
||||
static const unsigned int persist_statement_types[];
|
||||
static const unsigned int find_statement_types[];
|
||||
static const unsigned int update_statement_types[];
|
||||
|
||||
public:
|
||||
static bool
|
||||
find_ (statements_type&,
|
||||
const id_type*);
|
||||
|
||||
static void
|
||||
load_ (statements_type&,
|
||||
object_type&,
|
||||
bool reload);
|
||||
};
|
||||
|
||||
template <>
|
||||
class access::object_traits_impl< ::models::Agent, id_common >:
|
||||
public access::object_traits_impl< ::models::Agent, id_pgsql >
|
||||
{
|
||||
};
|
||||
|
||||
// Agent
|
||||
//
|
||||
}
|
||||
|
||||
#include "Agent-odb.ixx"
|
||||
|
||||
#include <odb/post.hxx>
|
||||
|
||||
#endif // AGENT_ODB_HXX
|
||||
61
db/test-schema-v1.2/generated-sql-ddl/postgre/Agent-odb.ixx
Normal file
61
db/test-schema-v1.2/generated-sql-ddl/postgre/Agent-odb.ixx
Normal file
@@ -0,0 +1,61 @@
|
||||
// This file was generated by ODB, object-relational mapping (ORM)
|
||||
// compiler for C++.
|
||||
//
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// Agent
|
||||
//
|
||||
|
||||
inline
|
||||
access::object_traits< ::models::Agent >::id_type
|
||||
access::object_traits< ::models::Agent >::
|
||||
id (const object_type& o)
|
||||
{
|
||||
return o.id;
|
||||
}
|
||||
|
||||
inline
|
||||
void access::object_traits< ::models::Agent >::
|
||||
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< ::models::Agent >::
|
||||
callback (database& db, const object_type& x, callback_event e)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
ODB_POTENTIALLY_UNUSED (x);
|
||||
ODB_POTENTIALLY_UNUSED (e);
|
||||
}
|
||||
}
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// Agent
|
||||
//
|
||||
|
||||
inline
|
||||
void access::object_traits_impl< ::models::Agent, id_pgsql >::
|
||||
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< ::models::Agent, id_pgsql >::
|
||||
load_ (statements_type& sts,
|
||||
object_type& obj,
|
||||
bool)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (sts);
|
||||
ODB_POTENTIALLY_UNUSED (obj);
|
||||
}
|
||||
}
|
||||
|
||||
24
db/test-schema-v1.2/generated-sql-ddl/postgre/Agent.sql
Normal file
24
db/test-schema-v1.2/generated-sql-ddl/postgre/Agent.sql
Normal file
@@ -0,0 +1,24 @@
|
||||
/* This file was generated by ODB, object-relational mapping (ORM)
|
||||
* compiler for C++.
|
||||
*/
|
||||
|
||||
DROP TABLE IF EXISTS "Agent" CASCADE;
|
||||
|
||||
DROP TABLE IF EXISTS "schema_version";
|
||||
|
||||
CREATE TABLE "Agent" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"role" TEXT NOT NULL,
|
||||
"persistent" BOOLEAN NOT NULL,
|
||||
"displayName" TEXT NOT NULL,
|
||||
"trustScore" INTEGER NOT NULL);
|
||||
|
||||
CREATE TABLE "schema_version" (
|
||||
"name" TEXT NOT NULL PRIMARY KEY,
|
||||
"version" BIGINT NOT NULL,
|
||||
"migration" BOOLEAN NOT NULL);
|
||||
|
||||
INSERT INTO "schema_version" (
|
||||
"name", "version", "migration")
|
||||
VALUES ('', 2, FALSE);
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
/* This file was generated by ODB, object-relational mapping (ORM)
|
||||
* compiler for C++.
|
||||
*/
|
||||
|
||||
UPDATE "schema_version"
|
||||
SET "migration" = FALSE
|
||||
WHERE "name" = '';
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
/* This file was generated by ODB, object-relational mapping (ORM)
|
||||
* compiler for C++.
|
||||
*/
|
||||
|
||||
CREATE TABLE "GovernmentAddress" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"addressLabel" TEXT NOT NULL,
|
||||
"regionLookupKey" TEXT NOT NULL);
|
||||
|
||||
UPDATE "schema_version"
|
||||
SET "version" = 2, "migration" = TRUE
|
||||
WHERE "name" = '';
|
||||
|
||||
@@ -0,0 +1,774 @@
|
||||
// This file was generated by ODB, object-relational mapping (ORM)
|
||||
// compiler for C++.
|
||||
//
|
||||
|
||||
#include <odb/pre.hxx>
|
||||
|
||||
#include "GovernmentAddress-odb.hxx"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring> // std::memcpy
|
||||
|
||||
|
||||
#include <odb/pgsql/traits.hxx>
|
||||
#include <odb/pgsql/database.hxx>
|
||||
#include <odb/pgsql/transaction.hxx>
|
||||
#include <odb/pgsql/connection.hxx>
|
||||
#include <odb/pgsql/statement.hxx>
|
||||
#include <odb/pgsql/statement-cache.hxx>
|
||||
#include <odb/pgsql/simple-object-statements.hxx>
|
||||
#include <odb/pgsql/container-statements.hxx>
|
||||
#include <odb/pgsql/exceptions.hxx>
|
||||
#include <odb/pgsql/simple-object-result.hxx>
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// GovernmentAddress
|
||||
//
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
persist_statement_name[] = "persist_models_GovernmentAddress";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
find_statement_name[] = "find_models_GovernmentAddress";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
update_statement_name[] = "update_models_GovernmentAddress";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
erase_statement_name[] = "erase_models_GovernmentAddress";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
query_statement_name[] = "query_models_GovernmentAddress";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
erase_query_statement_name[] = "erase_query_models_GovernmentAddress";
|
||||
|
||||
const unsigned int access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
persist_statement_types[] =
|
||||
{
|
||||
pgsql::text_oid,
|
||||
pgsql::text_oid,
|
||||
pgsql::text_oid
|
||||
};
|
||||
|
||||
const unsigned int access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
find_statement_types[] =
|
||||
{
|
||||
pgsql::text_oid
|
||||
};
|
||||
|
||||
const unsigned int access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
update_statement_types[] =
|
||||
{
|
||||
pgsql::text_oid,
|
||||
pgsql::text_oid,
|
||||
pgsql::text_oid
|
||||
};
|
||||
|
||||
struct access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::extra_statement_cache_type
|
||||
{
|
||||
extra_statement_cache_type (
|
||||
pgsql::connection&,
|
||||
image_type&,
|
||||
id_image_type&,
|
||||
pgsql::binding&,
|
||||
pgsql::binding&,
|
||||
pgsql::native_binding&,
|
||||
const unsigned int*)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::id_type
|
||||
access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
id (const image_type& i)
|
||||
{
|
||||
pgsql::database* db (0);
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
id_type id;
|
||||
{
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::set_value (
|
||||
id,
|
||||
i.id_value,
|
||||
i.id_size,
|
||||
i.id_null);
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
bool access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
grow (image_type& i,
|
||||
bool* t)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (i);
|
||||
ODB_POTENTIALLY_UNUSED (t);
|
||||
|
||||
bool grew (false);
|
||||
|
||||
// id
|
||||
//
|
||||
if (t[0UL])
|
||||
{
|
||||
i.id_value.capacity (i.id_size);
|
||||
grew = true;
|
||||
}
|
||||
|
||||
// addressLabel
|
||||
//
|
||||
if (t[1UL])
|
||||
{
|
||||
i.addressLabel_value.capacity (i.addressLabel_size);
|
||||
grew = true;
|
||||
}
|
||||
|
||||
// regionLookupKey
|
||||
//
|
||||
if (t[2UL])
|
||||
{
|
||||
i.regionLookupKey_value.capacity (i.regionLookupKey_size);
|
||||
grew = true;
|
||||
}
|
||||
|
||||
return grew;
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
bind (pgsql::bind* b,
|
||||
image_type& i,
|
||||
pgsql::statement_kind sk)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (sk);
|
||||
|
||||
using namespace pgsql;
|
||||
|
||||
std::size_t n (0);
|
||||
|
||||
// id
|
||||
//
|
||||
if (sk != statement_update)
|
||||
{
|
||||
b[n].type = pgsql::bind::text;
|
||||
b[n].buffer = i.id_value.data ();
|
||||
b[n].capacity = i.id_value.capacity ();
|
||||
b[n].size = &i.id_size;
|
||||
b[n].is_null = &i.id_null;
|
||||
n++;
|
||||
}
|
||||
|
||||
// addressLabel
|
||||
//
|
||||
b[n].type = pgsql::bind::text;
|
||||
b[n].buffer = i.addressLabel_value.data ();
|
||||
b[n].capacity = i.addressLabel_value.capacity ();
|
||||
b[n].size = &i.addressLabel_size;
|
||||
b[n].is_null = &i.addressLabel_null;
|
||||
n++;
|
||||
|
||||
// regionLookupKey
|
||||
//
|
||||
b[n].type = pgsql::bind::text;
|
||||
b[n].buffer = i.regionLookupKey_value.data ();
|
||||
b[n].capacity = i.regionLookupKey_value.capacity ();
|
||||
b[n].size = &i.regionLookupKey_size;
|
||||
b[n].is_null = &i.regionLookupKey_null;
|
||||
n++;
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
bind (pgsql::bind* b, id_image_type& i)
|
||||
{
|
||||
std::size_t n (0);
|
||||
b[n].type = pgsql::bind::text;
|
||||
b[n].buffer = i.id_value.data ();
|
||||
b[n].capacity = i.id_value.capacity ();
|
||||
b[n].size = &i.id_size;
|
||||
b[n].is_null = &i.id_null;
|
||||
}
|
||||
|
||||
bool access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
init (image_type& i,
|
||||
const object_type& o,
|
||||
pgsql::statement_kind sk)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (i);
|
||||
ODB_POTENTIALLY_UNUSED (o);
|
||||
ODB_POTENTIALLY_UNUSED (sk);
|
||||
|
||||
using namespace pgsql;
|
||||
|
||||
bool grew (false);
|
||||
|
||||
// id
|
||||
//
|
||||
if (sk == statement_insert)
|
||||
{
|
||||
::std::string const& v =
|
||||
o.id;
|
||||
|
||||
bool is_null (false);
|
||||
std::size_t size (0);
|
||||
std::size_t cap (i.id_value.capacity ());
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::set_image (
|
||||
i.id_value,
|
||||
size,
|
||||
is_null,
|
||||
v);
|
||||
i.id_null = is_null;
|
||||
i.id_size = size;
|
||||
grew = grew || (cap != i.id_value.capacity ());
|
||||
}
|
||||
|
||||
// addressLabel
|
||||
//
|
||||
{
|
||||
::std::string const& v =
|
||||
o.addressLabel;
|
||||
|
||||
bool is_null (false);
|
||||
std::size_t size (0);
|
||||
std::size_t cap (i.addressLabel_value.capacity ());
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::set_image (
|
||||
i.addressLabel_value,
|
||||
size,
|
||||
is_null,
|
||||
v);
|
||||
i.addressLabel_null = is_null;
|
||||
i.addressLabel_size = size;
|
||||
grew = grew || (cap != i.addressLabel_value.capacity ());
|
||||
}
|
||||
|
||||
// regionLookupKey
|
||||
//
|
||||
{
|
||||
::std::string const& v =
|
||||
o.regionLookupKey;
|
||||
|
||||
bool is_null (false);
|
||||
std::size_t size (0);
|
||||
std::size_t cap (i.regionLookupKey_value.capacity ());
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::set_image (
|
||||
i.regionLookupKey_value,
|
||||
size,
|
||||
is_null,
|
||||
v);
|
||||
i.regionLookupKey_null = is_null;
|
||||
i.regionLookupKey_size = size;
|
||||
grew = grew || (cap != i.regionLookupKey_value.capacity ());
|
||||
}
|
||||
|
||||
return grew;
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
init (object_type& o,
|
||||
const image_type& i,
|
||||
database* db)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (o);
|
||||
ODB_POTENTIALLY_UNUSED (i);
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
// id
|
||||
//
|
||||
{
|
||||
::std::string& v =
|
||||
o.id;
|
||||
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::set_value (
|
||||
v,
|
||||
i.id_value,
|
||||
i.id_size,
|
||||
i.id_null);
|
||||
}
|
||||
|
||||
// addressLabel
|
||||
//
|
||||
{
|
||||
::std::string& v =
|
||||
o.addressLabel;
|
||||
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::set_value (
|
||||
v,
|
||||
i.addressLabel_value,
|
||||
i.addressLabel_size,
|
||||
i.addressLabel_null);
|
||||
}
|
||||
|
||||
// regionLookupKey
|
||||
//
|
||||
{
|
||||
::std::string& v =
|
||||
o.regionLookupKey;
|
||||
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::set_value (
|
||||
v,
|
||||
i.regionLookupKey_value,
|
||||
i.regionLookupKey_size,
|
||||
i.regionLookupKey_null);
|
||||
}
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
init (id_image_type& i, const id_type& id)
|
||||
{
|
||||
bool grew (false);
|
||||
{
|
||||
bool is_null (false);
|
||||
std::size_t size (0);
|
||||
std::size_t cap (i.id_value.capacity ());
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::set_image (
|
||||
i.id_value,
|
||||
size,
|
||||
is_null,
|
||||
id);
|
||||
i.id_null = is_null;
|
||||
i.id_size = size;
|
||||
grew = grew || (cap != i.id_value.capacity ());
|
||||
}
|
||||
|
||||
if (grew)
|
||||
i.version++;
|
||||
}
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::persist_statement[] =
|
||||
"INSERT INTO \"GovernmentAddress\" "
|
||||
"(\"id\", "
|
||||
"\"addressLabel\", "
|
||||
"\"regionLookupKey\") "
|
||||
"VALUES "
|
||||
"($1, $2, $3)";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::find_statement[] =
|
||||
"SELECT "
|
||||
"\"GovernmentAddress\".\"id\", "
|
||||
"\"GovernmentAddress\".\"addressLabel\", "
|
||||
"\"GovernmentAddress\".\"regionLookupKey\" "
|
||||
"FROM \"GovernmentAddress\" "
|
||||
"WHERE \"GovernmentAddress\".\"id\"=$1";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::update_statement[] =
|
||||
"UPDATE \"GovernmentAddress\" "
|
||||
"SET "
|
||||
"\"addressLabel\"=$1, "
|
||||
"\"regionLookupKey\"=$2 "
|
||||
"WHERE \"id\"=$3";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::erase_statement[] =
|
||||
"DELETE FROM \"GovernmentAddress\" "
|
||||
"WHERE \"id\"=$1";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::query_statement[] =
|
||||
"SELECT "
|
||||
"\"GovernmentAddress\".\"id\", "
|
||||
"\"GovernmentAddress\".\"addressLabel\", "
|
||||
"\"GovernmentAddress\".\"regionLookupKey\" "
|
||||
"FROM \"GovernmentAddress\"";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::erase_query_statement[] =
|
||||
"DELETE FROM \"GovernmentAddress\"";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::table_name[] =
|
||||
"\"GovernmentAddress\"";
|
||||
|
||||
void access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
persist (database& db, const object_type& obj)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
using namespace pgsql;
|
||||
|
||||
pgsql::connection& conn (
|
||||
pgsql::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
callback (db,
|
||||
obj,
|
||||
callback_event::pre_persist);
|
||||
|
||||
image_type& im (sts.image ());
|
||||
binding& imb (sts.insert_image_binding ());
|
||||
|
||||
if (init (im, obj, statement_insert))
|
||||
im.version++;
|
||||
|
||||
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 ();
|
||||
|
||||
callback (db,
|
||||
obj,
|
||||
callback_event::post_persist);
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
update (database& db, const object_type& obj)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
using namespace pgsql;
|
||||
using pgsql::update_statement;
|
||||
|
||||
callback (db, obj, callback_event::pre_update);
|
||||
|
||||
pgsql::transaction& tr (pgsql::transaction::current ());
|
||||
pgsql::connection& conn (tr.connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
const id_type& id (
|
||||
obj.id);
|
||||
id_image_type& idi (sts.id_image ());
|
||||
init (idi, id);
|
||||
|
||||
image_type& im (sts.image ());
|
||||
if (init (im, obj, statement_update))
|
||||
im.version++;
|
||||
|
||||
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< ::models::GovernmentAddress, id_pgsql >::
|
||||
erase (database& db, const id_type& id)
|
||||
{
|
||||
using namespace pgsql;
|
||||
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
pgsql::connection& conn (
|
||||
pgsql::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
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< ::models::GovernmentAddress, id_pgsql >::pointer_type
|
||||
access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
find (database& db, const id_type& id)
|
||||
{
|
||||
using namespace pgsql;
|
||||
|
||||
{
|
||||
pointer_type p (pointer_cache_traits::find (db, id));
|
||||
|
||||
if (!pointer_traits::null_ptr (p))
|
||||
return p;
|
||||
}
|
||||
|
||||
pgsql::connection& conn (
|
||||
pgsql::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
statements_type::auto_lock l (sts);
|
||||
|
||||
if (l.locked ())
|
||||
{
|
||||
if (!find_ (sts, &id))
|
||||
return pointer_type ();
|
||||
}
|
||||
|
||||
pointer_type p (
|
||||
access::object_factory<object_type, pointer_type>::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);
|
||||
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< ::models::GovernmentAddress, id_pgsql >::
|
||||
find (database& db, const id_type& id, object_type& obj)
|
||||
{
|
||||
using namespace pgsql;
|
||||
|
||||
pgsql::connection& conn (
|
||||
pgsql::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
statements_type::auto_lock l (sts);
|
||||
|
||||
if (!find_ (sts, &id))
|
||||
return false;
|
||||
|
||||
select_statement& st (sts.find_statement ());
|
||||
ODB_POTENTIALLY_UNUSED (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);
|
||||
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< ::models::GovernmentAddress, id_pgsql >::
|
||||
reload (database& db, object_type& obj)
|
||||
{
|
||||
using namespace pgsql;
|
||||
|
||||
pgsql::connection& conn (
|
||||
pgsql::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
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);
|
||||
|
||||
callback (db, obj, callback_event::pre_load);
|
||||
init (obj, sts.image (), &db);
|
||||
load_ (sts, obj, true);
|
||||
sts.load_delayed (0);
|
||||
l.unlock ();
|
||||
callback (db, obj, callback_event::post_load);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
find_ (statements_type& sts,
|
||||
const id_type* id)
|
||||
{
|
||||
using namespace pgsql;
|
||||
|
||||
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::truncated)
|
||||
{
|
||||
if (grow (im, sts.select_image_truncated ()))
|
||||
im.version++;
|
||||
|
||||
if (im.version != sts.select_image_version ())
|
||||
{
|
||||
bind (imb.bind, im, statement_select);
|
||||
sts.select_image_version (im.version);
|
||||
imb.version++;
|
||||
st.refetch ();
|
||||
}
|
||||
}
|
||||
|
||||
return r != select_statement::no_data;
|
||||
}
|
||||
|
||||
result< access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::object_type >
|
||||
access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
query (database&, const query_base_type& q)
|
||||
{
|
||||
using namespace pgsql;
|
||||
using odb::details::shared;
|
||||
using odb::details::shared_ptr;
|
||||
|
||||
pgsql::connection& conn (
|
||||
pgsql::transaction::current ().connection ());
|
||||
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
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++;
|
||||
}
|
||||
|
||||
std::string text (query_statement);
|
||||
if (!q.empty ())
|
||||
{
|
||||
text += " ";
|
||||
text += q.clause ();
|
||||
}
|
||||
|
||||
q.init_parameters ();
|
||||
shared_ptr<select_statement> st (
|
||||
new (shared) select_statement (
|
||||
sts.connection (),
|
||||
query_statement_name,
|
||||
text,
|
||||
false,
|
||||
true,
|
||||
q.parameter_types (),
|
||||
q.parameter_count (),
|
||||
q.parameters_binding (),
|
||||
imb));
|
||||
|
||||
st->execute ();
|
||||
st->deallocate ();
|
||||
|
||||
shared_ptr< odb::object_result_impl<object_type> > r (
|
||||
new (shared) pgsql::object_result_impl<object_type> (
|
||||
q, st, sts, 0));
|
||||
|
||||
return result<object_type> (r);
|
||||
}
|
||||
|
||||
unsigned long long access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
erase_query (database&, const query_base_type& q)
|
||||
{
|
||||
using namespace pgsql;
|
||||
|
||||
pgsql::connection& conn (
|
||||
pgsql::transaction::current ().connection ());
|
||||
|
||||
std::string text (erase_query_statement);
|
||||
if (!q.empty ())
|
||||
{
|
||||
text += ' ';
|
||||
text += q.clause ();
|
||||
}
|
||||
|
||||
q.init_parameters ();
|
||||
delete_statement st (
|
||||
conn,
|
||||
erase_query_statement_name,
|
||||
text,
|
||||
q.parameter_types (),
|
||||
q.parameter_count (),
|
||||
q.parameters_binding ());
|
||||
|
||||
return st.execute ();
|
||||
}
|
||||
}
|
||||
|
||||
#include <odb/post.hxx>
|
||||
@@ -0,0 +1,309 @@
|
||||
// This file was generated by ODB, object-relational mapping (ORM)
|
||||
// compiler for C++.
|
||||
//
|
||||
|
||||
#ifndef GOVERNMENT_ADDRESS_ODB_HXX
|
||||
#define GOVERNMENT_ADDRESS_ODB_HXX
|
||||
|
||||
#include <odb/version.hxx>
|
||||
|
||||
#if (ODB_VERSION != 20400UL)
|
||||
#error ODB runtime version mismatch
|
||||
#endif
|
||||
|
||||
#include <odb/pre.hxx>
|
||||
|
||||
#include "GovernmentAddress.h"
|
||||
|
||||
#include <memory>
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
#include <odb/core.hxx>
|
||||
#include <odb/traits.hxx>
|
||||
#include <odb/callback.hxx>
|
||||
#include <odb/wrapper-traits.hxx>
|
||||
#include <odb/pointer-traits.hxx>
|
||||
#include <odb/container-traits.hxx>
|
||||
#include <odb/no-op-cache-traits.hxx>
|
||||
#include <odb/result.hxx>
|
||||
#include <odb/simple-object-result.hxx>
|
||||
|
||||
#include <odb/details/unused.hxx>
|
||||
#include <odb/details/shared-ptr.hxx>
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// GovernmentAddress
|
||||
//
|
||||
template <>
|
||||
struct class_traits< ::models::GovernmentAddress >
|
||||
{
|
||||
static const class_kind kind = class_object;
|
||||
};
|
||||
|
||||
template <>
|
||||
class access::object_traits< ::models::GovernmentAddress >
|
||||
{
|
||||
public:
|
||||
typedef ::models::GovernmentAddress object_type;
|
||||
typedef ::models::GovernmentAddress* pointer_type;
|
||||
typedef odb::pointer_traits<pointer_type> pointer_traits;
|
||||
|
||||
static const bool polymorphic = false;
|
||||
|
||||
typedef ::std::string id_type;
|
||||
|
||||
static const bool auto_id = false;
|
||||
|
||||
static const bool abstract = false;
|
||||
|
||||
static id_type
|
||||
id (const object_type&);
|
||||
|
||||
typedef
|
||||
no_op_pointer_cache_traits<pointer_type>
|
||||
pointer_cache_traits;
|
||||
|
||||
typedef
|
||||
no_op_reference_cache_traits<object_type>
|
||||
reference_cache_traits;
|
||||
|
||||
static void
|
||||
callback (database&, object_type&, callback_event);
|
||||
|
||||
static void
|
||||
callback (database&, const object_type&, callback_event);
|
||||
};
|
||||
}
|
||||
|
||||
#include <odb/details/buffer.hxx>
|
||||
|
||||
#include <odb/pgsql/version.hxx>
|
||||
#include <odb/pgsql/forward.hxx>
|
||||
#include <odb/pgsql/binding.hxx>
|
||||
#include <odb/pgsql/pgsql-types.hxx>
|
||||
#include <odb/pgsql/query.hxx>
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// GovernmentAddress
|
||||
//
|
||||
template <typename A>
|
||||
struct query_columns< ::models::GovernmentAddress, id_pgsql, A >
|
||||
{
|
||||
// id
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
id_type_;
|
||||
|
||||
static const id_type_ id;
|
||||
|
||||
// addressLabel
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
addressLabel_type_;
|
||||
|
||||
static const addressLabel_type_ addressLabel;
|
||||
|
||||
// regionLookupKey
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
regionLookupKey_type_;
|
||||
|
||||
static const regionLookupKey_type_ regionLookupKey;
|
||||
};
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::GovernmentAddress, id_pgsql, A >::id_type_
|
||||
query_columns< ::models::GovernmentAddress, id_pgsql, A >::
|
||||
id (A::table_name, "\"id\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::GovernmentAddress, id_pgsql, A >::addressLabel_type_
|
||||
query_columns< ::models::GovernmentAddress, id_pgsql, A >::
|
||||
addressLabel (A::table_name, "\"addressLabel\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::GovernmentAddress, id_pgsql, A >::regionLookupKey_type_
|
||||
query_columns< ::models::GovernmentAddress, id_pgsql, A >::
|
||||
regionLookupKey (A::table_name, "\"regionLookupKey\"", 0);
|
||||
|
||||
template <typename A>
|
||||
struct pointer_query_columns< ::models::GovernmentAddress, id_pgsql, A >:
|
||||
query_columns< ::models::GovernmentAddress, id_pgsql, A >
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
class access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >:
|
||||
public access::object_traits< ::models::GovernmentAddress >
|
||||
{
|
||||
public:
|
||||
struct id_image_type
|
||||
{
|
||||
details::buffer id_value;
|
||||
std::size_t id_size;
|
||||
bool id_null;
|
||||
|
||||
std::size_t version;
|
||||
};
|
||||
|
||||
struct image_type
|
||||
{
|
||||
// id
|
||||
//
|
||||
details::buffer id_value;
|
||||
std::size_t id_size;
|
||||
bool id_null;
|
||||
|
||||
// addressLabel
|
||||
//
|
||||
details::buffer addressLabel_value;
|
||||
std::size_t addressLabel_size;
|
||||
bool addressLabel_null;
|
||||
|
||||
// regionLookupKey
|
||||
//
|
||||
details::buffer regionLookupKey_value;
|
||||
std::size_t regionLookupKey_size;
|
||||
bool regionLookupKey_null;
|
||||
|
||||
std::size_t version;
|
||||
};
|
||||
|
||||
struct extra_statement_cache_type;
|
||||
|
||||
using object_traits<object_type>::id;
|
||||
|
||||
static id_type
|
||||
id (const image_type&);
|
||||
|
||||
static bool
|
||||
grow (image_type&,
|
||||
bool*);
|
||||
|
||||
static void
|
||||
bind (pgsql::bind*,
|
||||
image_type&,
|
||||
pgsql::statement_kind);
|
||||
|
||||
static void
|
||||
bind (pgsql::bind*, id_image_type&);
|
||||
|
||||
static bool
|
||||
init (image_type&,
|
||||
const object_type&,
|
||||
pgsql::statement_kind);
|
||||
|
||||
static void
|
||||
init (object_type&,
|
||||
const image_type&,
|
||||
database*);
|
||||
|
||||
static void
|
||||
init (id_image_type&, const id_type&);
|
||||
|
||||
typedef pgsql::object_statements<object_type> statements_type;
|
||||
|
||||
typedef pgsql::query_base query_base_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 const char query_statement[];
|
||||
static const char erase_query_statement[];
|
||||
|
||||
static const char table_name[];
|
||||
|
||||
static void
|
||||
persist (database&, const 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&);
|
||||
|
||||
static result<object_type>
|
||||
query (database&, const query_base_type&);
|
||||
|
||||
static unsigned long long
|
||||
erase_query (database&, const query_base_type&);
|
||||
|
||||
static const char persist_statement_name[];
|
||||
static const char find_statement_name[];
|
||||
static const char update_statement_name[];
|
||||
static const char erase_statement_name[];
|
||||
static const char query_statement_name[];
|
||||
static const char erase_query_statement_name[];
|
||||
|
||||
static const unsigned int persist_statement_types[];
|
||||
static const unsigned int find_statement_types[];
|
||||
static const unsigned int update_statement_types[];
|
||||
|
||||
public:
|
||||
static bool
|
||||
find_ (statements_type&,
|
||||
const id_type*);
|
||||
|
||||
static void
|
||||
load_ (statements_type&,
|
||||
object_type&,
|
||||
bool reload);
|
||||
};
|
||||
|
||||
template <>
|
||||
class access::object_traits_impl< ::models::GovernmentAddress, id_common >:
|
||||
public access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >
|
||||
{
|
||||
};
|
||||
|
||||
// GovernmentAddress
|
||||
//
|
||||
}
|
||||
|
||||
#include "GovernmentAddress-odb.ixx"
|
||||
|
||||
#include <odb/post.hxx>
|
||||
|
||||
#endif // GOVERNMENT_ADDRESS_ODB_HXX
|
||||
@@ -0,0 +1,61 @@
|
||||
// This file was generated by ODB, object-relational mapping (ORM)
|
||||
// compiler for C++.
|
||||
//
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// GovernmentAddress
|
||||
//
|
||||
|
||||
inline
|
||||
access::object_traits< ::models::GovernmentAddress >::id_type
|
||||
access::object_traits< ::models::GovernmentAddress >::
|
||||
id (const object_type& o)
|
||||
{
|
||||
return o.id;
|
||||
}
|
||||
|
||||
inline
|
||||
void access::object_traits< ::models::GovernmentAddress >::
|
||||
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< ::models::GovernmentAddress >::
|
||||
callback (database& db, const object_type& x, callback_event e)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
ODB_POTENTIALLY_UNUSED (x);
|
||||
ODB_POTENTIALLY_UNUSED (e);
|
||||
}
|
||||
}
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// GovernmentAddress
|
||||
//
|
||||
|
||||
inline
|
||||
void access::object_traits_impl< ::models::GovernmentAddress, id_pgsql >::
|
||||
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< ::models::GovernmentAddress, id_pgsql >::
|
||||
load_ (statements_type& sts,
|
||||
object_type& obj,
|
||||
bool)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (sts);
|
||||
ODB_POTENTIALLY_UNUSED (obj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/* This file was generated by ODB, object-relational mapping (ORM)
|
||||
* compiler for C++.
|
||||
*/
|
||||
|
||||
DROP TABLE IF EXISTS "GovernmentAddress" CASCADE;
|
||||
|
||||
DROP TABLE IF EXISTS "schema_version";
|
||||
|
||||
CREATE TABLE "GovernmentAddress" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"addressLabel" TEXT NOT NULL,
|
||||
"regionLookupKey" TEXT NOT NULL);
|
||||
|
||||
CREATE TABLE "schema_version" (
|
||||
"name" TEXT NOT NULL PRIMARY KEY,
|
||||
"version" BIGINT NOT NULL,
|
||||
"migration" BOOLEAN NOT NULL);
|
||||
|
||||
INSERT INTO "schema_version" (
|
||||
"name", "version", "migration")
|
||||
VALUES ('', 2, FALSE);
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
/* This file was generated by ODB, object-relational mapping (ORM)
|
||||
* compiler for C++.
|
||||
*/
|
||||
|
||||
UPDATE "schema_version"
|
||||
SET "migration" = FALSE
|
||||
WHERE "name" = '';
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/* This file was generated by ODB, object-relational mapping (ORM)
|
||||
* compiler for C++.
|
||||
*/
|
||||
|
||||
CREATE TABLE "TripAttemptResult" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"result" TEXT NOT NULL,
|
||||
"retryReason" TEXT NOT NULL,
|
||||
"governmentSuspensionReason" TEXT NOT NULL,
|
||||
"governmentTerminationReason" TEXT NOT NULL,
|
||||
"complianceSuspensionReason" TEXT NOT NULL,
|
||||
"complianceTerminationReason" TEXT NOT NULL,
|
||||
"policySuspensionReason" TEXT NOT NULL,
|
||||
"policyTerminationReason" TEXT NOT NULL,
|
||||
"cancelationReason" TEXT NOT NULL,
|
||||
"failureReason" TEXT NOT NULL,
|
||||
"details" TEXT NOT NULL);
|
||||
|
||||
UPDATE "schema_version"
|
||||
SET "version" = 2, "migration" = TRUE
|
||||
WHERE "name" = '';
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,516 @@
|
||||
// This file was generated by ODB, object-relational mapping (ORM)
|
||||
// compiler for C++.
|
||||
//
|
||||
|
||||
#ifndef TRIP_ATTEMPT_RESULT_ODB_HXX
|
||||
#define TRIP_ATTEMPT_RESULT_ODB_HXX
|
||||
|
||||
#include <odb/version.hxx>
|
||||
|
||||
#if (ODB_VERSION != 20400UL)
|
||||
#error ODB runtime version mismatch
|
||||
#endif
|
||||
|
||||
#include <odb/pre.hxx>
|
||||
|
||||
#include "TripAttemptResult.h"
|
||||
|
||||
#include <memory>
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
#include <odb/core.hxx>
|
||||
#include <odb/traits.hxx>
|
||||
#include <odb/callback.hxx>
|
||||
#include <odb/wrapper-traits.hxx>
|
||||
#include <odb/pointer-traits.hxx>
|
||||
#include <odb/container-traits.hxx>
|
||||
#include <odb/no-op-cache-traits.hxx>
|
||||
#include <odb/result.hxx>
|
||||
#include <odb/simple-object-result.hxx>
|
||||
|
||||
#include <odb/details/unused.hxx>
|
||||
#include <odb/details/shared-ptr.hxx>
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// TripAttemptResult
|
||||
//
|
||||
template <>
|
||||
struct class_traits< ::models::TripAttemptResult >
|
||||
{
|
||||
static const class_kind kind = class_object;
|
||||
};
|
||||
|
||||
template <>
|
||||
class access::object_traits< ::models::TripAttemptResult >
|
||||
{
|
||||
public:
|
||||
typedef ::models::TripAttemptResult object_type;
|
||||
typedef ::models::TripAttemptResult* pointer_type;
|
||||
typedef odb::pointer_traits<pointer_type> pointer_traits;
|
||||
|
||||
static const bool polymorphic = false;
|
||||
|
||||
typedef ::std::string id_type;
|
||||
|
||||
static const bool auto_id = false;
|
||||
|
||||
static const bool abstract = false;
|
||||
|
||||
static id_type
|
||||
id (const object_type&);
|
||||
|
||||
typedef
|
||||
no_op_pointer_cache_traits<pointer_type>
|
||||
pointer_cache_traits;
|
||||
|
||||
typedef
|
||||
no_op_reference_cache_traits<object_type>
|
||||
reference_cache_traits;
|
||||
|
||||
static void
|
||||
callback (database&, object_type&, callback_event);
|
||||
|
||||
static void
|
||||
callback (database&, const object_type&, callback_event);
|
||||
};
|
||||
}
|
||||
|
||||
#include <odb/details/buffer.hxx>
|
||||
|
||||
#include <odb/pgsql/version.hxx>
|
||||
#include <odb/pgsql/forward.hxx>
|
||||
#include <odb/pgsql/binding.hxx>
|
||||
#include <odb/pgsql/pgsql-types.hxx>
|
||||
#include <odb/pgsql/query.hxx>
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// TripAttemptResult
|
||||
//
|
||||
template <typename A>
|
||||
struct query_columns< ::models::TripAttemptResult, id_pgsql, A >
|
||||
{
|
||||
// id
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
id_type_;
|
||||
|
||||
static const id_type_ id;
|
||||
|
||||
// result
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
result_type_;
|
||||
|
||||
static const result_type_ result;
|
||||
|
||||
// retryReason
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
retryReason_type_;
|
||||
|
||||
static const retryReason_type_ retryReason;
|
||||
|
||||
// governmentSuspensionReason
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
governmentSuspensionReason_type_;
|
||||
|
||||
static const governmentSuspensionReason_type_ governmentSuspensionReason;
|
||||
|
||||
// governmentTerminationReason
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
governmentTerminationReason_type_;
|
||||
|
||||
static const governmentTerminationReason_type_ governmentTerminationReason;
|
||||
|
||||
// complianceSuspensionReason
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
complianceSuspensionReason_type_;
|
||||
|
||||
static const complianceSuspensionReason_type_ complianceSuspensionReason;
|
||||
|
||||
// complianceTerminationReason
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
complianceTerminationReason_type_;
|
||||
|
||||
static const complianceTerminationReason_type_ complianceTerminationReason;
|
||||
|
||||
// policySuspensionReason
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
policySuspensionReason_type_;
|
||||
|
||||
static const policySuspensionReason_type_ policySuspensionReason;
|
||||
|
||||
// policyTerminationReason
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
policyTerminationReason_type_;
|
||||
|
||||
static const policyTerminationReason_type_ policyTerminationReason;
|
||||
|
||||
// cancelationReason
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
cancelationReason_type_;
|
||||
|
||||
static const cancelationReason_type_ cancelationReason;
|
||||
|
||||
// failureReason
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
failureReason_type_;
|
||||
|
||||
static const failureReason_type_ failureReason;
|
||||
|
||||
// details
|
||||
//
|
||||
typedef
|
||||
pgsql::query_column<
|
||||
pgsql::value_traits<
|
||||
::std::string,
|
||||
pgsql::id_string >::query_type,
|
||||
pgsql::id_string >
|
||||
details_type_;
|
||||
|
||||
static const details_type_ details;
|
||||
};
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_pgsql, A >::id_type_
|
||||
query_columns< ::models::TripAttemptResult, id_pgsql, A >::
|
||||
id (A::table_name, "\"id\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_pgsql, A >::result_type_
|
||||
query_columns< ::models::TripAttemptResult, id_pgsql, A >::
|
||||
result (A::table_name, "\"result\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_pgsql, A >::retryReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_pgsql, A >::
|
||||
retryReason (A::table_name, "\"retryReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_pgsql, A >::governmentSuspensionReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_pgsql, A >::
|
||||
governmentSuspensionReason (A::table_name, "\"governmentSuspensionReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_pgsql, A >::governmentTerminationReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_pgsql, A >::
|
||||
governmentTerminationReason (A::table_name, "\"governmentTerminationReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_pgsql, A >::complianceSuspensionReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_pgsql, A >::
|
||||
complianceSuspensionReason (A::table_name, "\"complianceSuspensionReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_pgsql, A >::complianceTerminationReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_pgsql, A >::
|
||||
complianceTerminationReason (A::table_name, "\"complianceTerminationReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_pgsql, A >::policySuspensionReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_pgsql, A >::
|
||||
policySuspensionReason (A::table_name, "\"policySuspensionReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_pgsql, A >::policyTerminationReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_pgsql, A >::
|
||||
policyTerminationReason (A::table_name, "\"policyTerminationReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_pgsql, A >::cancelationReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_pgsql, A >::
|
||||
cancelationReason (A::table_name, "\"cancelationReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_pgsql, A >::failureReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_pgsql, A >::
|
||||
failureReason (A::table_name, "\"failureReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_pgsql, A >::details_type_
|
||||
query_columns< ::models::TripAttemptResult, id_pgsql, A >::
|
||||
details (A::table_name, "\"details\"", 0);
|
||||
|
||||
template <typename A>
|
||||
struct pointer_query_columns< ::models::TripAttemptResult, id_pgsql, A >:
|
||||
query_columns< ::models::TripAttemptResult, id_pgsql, A >
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
class access::object_traits_impl< ::models::TripAttemptResult, id_pgsql >:
|
||||
public access::object_traits< ::models::TripAttemptResult >
|
||||
{
|
||||
public:
|
||||
struct id_image_type
|
||||
{
|
||||
details::buffer id_value;
|
||||
std::size_t id_size;
|
||||
bool id_null;
|
||||
|
||||
std::size_t version;
|
||||
};
|
||||
|
||||
struct image_type
|
||||
{
|
||||
// id
|
||||
//
|
||||
details::buffer id_value;
|
||||
std::size_t id_size;
|
||||
bool id_null;
|
||||
|
||||
// result
|
||||
//
|
||||
details::buffer result_value;
|
||||
std::size_t result_size;
|
||||
bool result_null;
|
||||
|
||||
// retryReason
|
||||
//
|
||||
details::buffer retryReason_value;
|
||||
std::size_t retryReason_size;
|
||||
bool retryReason_null;
|
||||
|
||||
// governmentSuspensionReason
|
||||
//
|
||||
details::buffer governmentSuspensionReason_value;
|
||||
std::size_t governmentSuspensionReason_size;
|
||||
bool governmentSuspensionReason_null;
|
||||
|
||||
// governmentTerminationReason
|
||||
//
|
||||
details::buffer governmentTerminationReason_value;
|
||||
std::size_t governmentTerminationReason_size;
|
||||
bool governmentTerminationReason_null;
|
||||
|
||||
// complianceSuspensionReason
|
||||
//
|
||||
details::buffer complianceSuspensionReason_value;
|
||||
std::size_t complianceSuspensionReason_size;
|
||||
bool complianceSuspensionReason_null;
|
||||
|
||||
// complianceTerminationReason
|
||||
//
|
||||
details::buffer complianceTerminationReason_value;
|
||||
std::size_t complianceTerminationReason_size;
|
||||
bool complianceTerminationReason_null;
|
||||
|
||||
// policySuspensionReason
|
||||
//
|
||||
details::buffer policySuspensionReason_value;
|
||||
std::size_t policySuspensionReason_size;
|
||||
bool policySuspensionReason_null;
|
||||
|
||||
// policyTerminationReason
|
||||
//
|
||||
details::buffer policyTerminationReason_value;
|
||||
std::size_t policyTerminationReason_size;
|
||||
bool policyTerminationReason_null;
|
||||
|
||||
// cancelationReason
|
||||
//
|
||||
details::buffer cancelationReason_value;
|
||||
std::size_t cancelationReason_size;
|
||||
bool cancelationReason_null;
|
||||
|
||||
// failureReason
|
||||
//
|
||||
details::buffer failureReason_value;
|
||||
std::size_t failureReason_size;
|
||||
bool failureReason_null;
|
||||
|
||||
// details
|
||||
//
|
||||
details::buffer details_value;
|
||||
std::size_t details_size;
|
||||
bool details_null;
|
||||
|
||||
std::size_t version;
|
||||
};
|
||||
|
||||
struct extra_statement_cache_type;
|
||||
|
||||
using object_traits<object_type>::id;
|
||||
|
||||
static id_type
|
||||
id (const image_type&);
|
||||
|
||||
static bool
|
||||
grow (image_type&,
|
||||
bool*);
|
||||
|
||||
static void
|
||||
bind (pgsql::bind*,
|
||||
image_type&,
|
||||
pgsql::statement_kind);
|
||||
|
||||
static void
|
||||
bind (pgsql::bind*, id_image_type&);
|
||||
|
||||
static bool
|
||||
init (image_type&,
|
||||
const object_type&,
|
||||
pgsql::statement_kind);
|
||||
|
||||
static void
|
||||
init (object_type&,
|
||||
const image_type&,
|
||||
database*);
|
||||
|
||||
static void
|
||||
init (id_image_type&, const id_type&);
|
||||
|
||||
typedef pgsql::object_statements<object_type> statements_type;
|
||||
|
||||
typedef pgsql::query_base query_base_type;
|
||||
|
||||
static const std::size_t column_count = 12UL;
|
||||
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 const char query_statement[];
|
||||
static const char erase_query_statement[];
|
||||
|
||||
static const char table_name[];
|
||||
|
||||
static void
|
||||
persist (database&, const 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&);
|
||||
|
||||
static result<object_type>
|
||||
query (database&, const query_base_type&);
|
||||
|
||||
static unsigned long long
|
||||
erase_query (database&, const query_base_type&);
|
||||
|
||||
static const char persist_statement_name[];
|
||||
static const char find_statement_name[];
|
||||
static const char update_statement_name[];
|
||||
static const char erase_statement_name[];
|
||||
static const char query_statement_name[];
|
||||
static const char erase_query_statement_name[];
|
||||
|
||||
static const unsigned int persist_statement_types[];
|
||||
static const unsigned int find_statement_types[];
|
||||
static const unsigned int update_statement_types[];
|
||||
|
||||
public:
|
||||
static bool
|
||||
find_ (statements_type&,
|
||||
const id_type*);
|
||||
|
||||
static void
|
||||
load_ (statements_type&,
|
||||
object_type&,
|
||||
bool reload);
|
||||
};
|
||||
|
||||
template <>
|
||||
class access::object_traits_impl< ::models::TripAttemptResult, id_common >:
|
||||
public access::object_traits_impl< ::models::TripAttemptResult, id_pgsql >
|
||||
{
|
||||
};
|
||||
|
||||
// TripAttemptResult
|
||||
//
|
||||
}
|
||||
|
||||
#include "TripAttemptResult-odb.ixx"
|
||||
|
||||
#include <odb/post.hxx>
|
||||
|
||||
#endif // TRIP_ATTEMPT_RESULT_ODB_HXX
|
||||
@@ -0,0 +1,61 @@
|
||||
// This file was generated by ODB, object-relational mapping (ORM)
|
||||
// compiler for C++.
|
||||
//
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// TripAttemptResult
|
||||
//
|
||||
|
||||
inline
|
||||
access::object_traits< ::models::TripAttemptResult >::id_type
|
||||
access::object_traits< ::models::TripAttemptResult >::
|
||||
id (const object_type& o)
|
||||
{
|
||||
return o.id;
|
||||
}
|
||||
|
||||
inline
|
||||
void access::object_traits< ::models::TripAttemptResult >::
|
||||
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< ::models::TripAttemptResult >::
|
||||
callback (database& db, const object_type& x, callback_event e)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
ODB_POTENTIALLY_UNUSED (x);
|
||||
ODB_POTENTIALLY_UNUSED (e);
|
||||
}
|
||||
}
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// TripAttemptResult
|
||||
//
|
||||
|
||||
inline
|
||||
void access::object_traits_impl< ::models::TripAttemptResult, id_pgsql >::
|
||||
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< ::models::TripAttemptResult, id_pgsql >::
|
||||
load_ (statements_type& sts,
|
||||
object_type& obj,
|
||||
bool)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (sts);
|
||||
ODB_POTENTIALLY_UNUSED (obj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/* This file was generated by ODB, object-relational mapping (ORM)
|
||||
* compiler for C++.
|
||||
*/
|
||||
|
||||
DROP TABLE IF EXISTS "TripAttemptResult" CASCADE;
|
||||
|
||||
DROP TABLE IF EXISTS "schema_version";
|
||||
|
||||
CREATE TABLE "TripAttemptResult" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"result" TEXT NOT NULL,
|
||||
"retryReason" TEXT NOT NULL,
|
||||
"governmentSuspensionReason" TEXT NOT NULL,
|
||||
"governmentTerminationReason" TEXT NOT NULL,
|
||||
"complianceSuspensionReason" TEXT NOT NULL,
|
||||
"complianceTerminationReason" TEXT NOT NULL,
|
||||
"policySuspensionReason" TEXT NOT NULL,
|
||||
"policyTerminationReason" TEXT NOT NULL,
|
||||
"cancelationReason" TEXT NOT NULL,
|
||||
"failureReason" TEXT NOT NULL,
|
||||
"details" TEXT NOT NULL);
|
||||
|
||||
CREATE TABLE "schema_version" (
|
||||
"name" TEXT NOT NULL PRIMARY KEY,
|
||||
"version" BIGINT NOT NULL,
|
||||
"migration" BOOLEAN NOT NULL);
|
||||
|
||||
INSERT INTO "schema_version" (
|
||||
"name", "version", "migration")
|
||||
VALUES ('', 2, FALSE);
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
/* This file was generated by ODB, object-relational mapping (ORM)
|
||||
* compiler for C++.
|
||||
*/
|
||||
|
||||
UPDATE "schema_version"
|
||||
SET "migration" = 0
|
||||
WHERE "name" = '';
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/* This file was generated by ODB, object-relational mapping (ORM)
|
||||
* compiler for C++.
|
||||
*/
|
||||
|
||||
CREATE TABLE "Agent" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"role" TEXT NOT NULL,
|
||||
"persistent" INTEGER NOT NULL,
|
||||
"displayName" TEXT NOT NULL,
|
||||
"trustScore" INTEGER NOT NULL);
|
||||
|
||||
UPDATE "schema_version"
|
||||
SET "version" = 2, "migration" = 1
|
||||
WHERE "name" = '';
|
||||
|
||||
815
db/test-schema-v1.2/generated-sql-ddl/sqlite/Agent-odb.cxx
Normal file
815
db/test-schema-v1.2/generated-sql-ddl/sqlite/Agent-odb.cxx
Normal file
@@ -0,0 +1,815 @@
|
||||
// This file was generated by ODB, object-relational mapping (ORM)
|
||||
// compiler for C++.
|
||||
//
|
||||
|
||||
#include <odb/pre.hxx>
|
||||
|
||||
#include "Agent-odb.hxx"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring> // std::memcpy
|
||||
|
||||
|
||||
#include <odb/sqlite/traits.hxx>
|
||||
#include <odb/sqlite/database.hxx>
|
||||
#include <odb/sqlite/transaction.hxx>
|
||||
#include <odb/sqlite/connection.hxx>
|
||||
#include <odb/sqlite/statement.hxx>
|
||||
#include <odb/sqlite/statement-cache.hxx>
|
||||
#include <odb/sqlite/simple-object-statements.hxx>
|
||||
#include <odb/sqlite/container-statements.hxx>
|
||||
#include <odb/sqlite/exceptions.hxx>
|
||||
#include <odb/sqlite/simple-object-result.hxx>
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// Agent
|
||||
//
|
||||
|
||||
struct access::object_traits_impl< ::models::Agent, id_sqlite >::extra_statement_cache_type
|
||||
{
|
||||
extra_statement_cache_type (
|
||||
sqlite::connection&,
|
||||
image_type&,
|
||||
id_image_type&,
|
||||
sqlite::binding&,
|
||||
sqlite::binding&)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
access::object_traits_impl< ::models::Agent, id_sqlite >::id_type
|
||||
access::object_traits_impl< ::models::Agent, id_sqlite >::
|
||||
id (const image_type& i)
|
||||
{
|
||||
sqlite::database* db (0);
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
id_type id;
|
||||
{
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::set_value (
|
||||
id,
|
||||
i.id_value,
|
||||
i.id_size,
|
||||
i.id_null);
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
bool access::object_traits_impl< ::models::Agent, id_sqlite >::
|
||||
grow (image_type& i,
|
||||
bool* t)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (i);
|
||||
ODB_POTENTIALLY_UNUSED (t);
|
||||
|
||||
bool grew (false);
|
||||
|
||||
// id
|
||||
//
|
||||
if (t[0UL])
|
||||
{
|
||||
i.id_value.capacity (i.id_size);
|
||||
grew = true;
|
||||
}
|
||||
|
||||
// role
|
||||
//
|
||||
if (t[1UL])
|
||||
{
|
||||
i.role_value.capacity (i.role_size);
|
||||
grew = true;
|
||||
}
|
||||
|
||||
// persistent
|
||||
//
|
||||
t[2UL] = false;
|
||||
|
||||
// displayName
|
||||
//
|
||||
if (t[3UL])
|
||||
{
|
||||
i.displayName_value.capacity (i.displayName_size);
|
||||
grew = true;
|
||||
}
|
||||
|
||||
// trustScore
|
||||
//
|
||||
t[4UL] = false;
|
||||
|
||||
return grew;
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::Agent, id_sqlite >::
|
||||
bind (sqlite::bind* b,
|
||||
image_type& i,
|
||||
sqlite::statement_kind sk)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (sk);
|
||||
|
||||
using namespace sqlite;
|
||||
|
||||
std::size_t n (0);
|
||||
|
||||
// id
|
||||
//
|
||||
if (sk != statement_update)
|
||||
{
|
||||
b[n].type = sqlite::image_traits<
|
||||
::std::string,
|
||||
sqlite::id_text>::bind_value;
|
||||
b[n].buffer = i.id_value.data ();
|
||||
b[n].size = &i.id_size;
|
||||
b[n].capacity = i.id_value.capacity ();
|
||||
b[n].is_null = &i.id_null;
|
||||
n++;
|
||||
}
|
||||
|
||||
// role
|
||||
//
|
||||
b[n].type = sqlite::image_traits<
|
||||
::std::string,
|
||||
sqlite::id_text>::bind_value;
|
||||
b[n].buffer = i.role_value.data ();
|
||||
b[n].size = &i.role_size;
|
||||
b[n].capacity = i.role_value.capacity ();
|
||||
b[n].is_null = &i.role_null;
|
||||
n++;
|
||||
|
||||
// persistent
|
||||
//
|
||||
b[n].type = sqlite::bind::integer;
|
||||
b[n].buffer = &i.persistent_value;
|
||||
b[n].is_null = &i.persistent_null;
|
||||
n++;
|
||||
|
||||
// displayName
|
||||
//
|
||||
b[n].type = sqlite::image_traits<
|
||||
::std::string,
|
||||
sqlite::id_text>::bind_value;
|
||||
b[n].buffer = i.displayName_value.data ();
|
||||
b[n].size = &i.displayName_size;
|
||||
b[n].capacity = i.displayName_value.capacity ();
|
||||
b[n].is_null = &i.displayName_null;
|
||||
n++;
|
||||
|
||||
// trustScore
|
||||
//
|
||||
b[n].type = sqlite::bind::integer;
|
||||
b[n].buffer = &i.trustScore_value;
|
||||
b[n].is_null = &i.trustScore_null;
|
||||
n++;
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::Agent, id_sqlite >::
|
||||
bind (sqlite::bind* b, id_image_type& i)
|
||||
{
|
||||
std::size_t n (0);
|
||||
b[n].type = sqlite::image_traits<
|
||||
::std::string,
|
||||
sqlite::id_text>::bind_value;
|
||||
b[n].buffer = i.id_value.data ();
|
||||
b[n].size = &i.id_size;
|
||||
b[n].capacity = i.id_value.capacity ();
|
||||
b[n].is_null = &i.id_null;
|
||||
}
|
||||
|
||||
bool access::object_traits_impl< ::models::Agent, id_sqlite >::
|
||||
init (image_type& i,
|
||||
const object_type& o,
|
||||
sqlite::statement_kind sk)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (i);
|
||||
ODB_POTENTIALLY_UNUSED (o);
|
||||
ODB_POTENTIALLY_UNUSED (sk);
|
||||
|
||||
using namespace sqlite;
|
||||
|
||||
bool grew (false);
|
||||
|
||||
// id
|
||||
//
|
||||
if (sk == statement_insert)
|
||||
{
|
||||
::std::string const& v =
|
||||
o.id;
|
||||
|
||||
bool is_null (false);
|
||||
std::size_t cap (i.id_value.capacity ());
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::set_image (
|
||||
i.id_value,
|
||||
i.id_size,
|
||||
is_null,
|
||||
v);
|
||||
i.id_null = is_null;
|
||||
grew = grew || (cap != i.id_value.capacity ());
|
||||
}
|
||||
|
||||
// role
|
||||
//
|
||||
{
|
||||
::std::string const& v =
|
||||
o.role;
|
||||
|
||||
bool is_null (false);
|
||||
std::size_t cap (i.role_value.capacity ());
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::set_image (
|
||||
i.role_value,
|
||||
i.role_size,
|
||||
is_null,
|
||||
v);
|
||||
i.role_null = is_null;
|
||||
grew = grew || (cap != i.role_value.capacity ());
|
||||
}
|
||||
|
||||
// persistent
|
||||
//
|
||||
{
|
||||
bool const& v =
|
||||
o.persistent;
|
||||
|
||||
bool is_null (false);
|
||||
sqlite::value_traits<
|
||||
bool,
|
||||
sqlite::id_integer >::set_image (
|
||||
i.persistent_value,
|
||||
is_null,
|
||||
v);
|
||||
i.persistent_null = is_null;
|
||||
}
|
||||
|
||||
// displayName
|
||||
//
|
||||
{
|
||||
::std::string const& v =
|
||||
o.displayName;
|
||||
|
||||
bool is_null (false);
|
||||
std::size_t cap (i.displayName_value.capacity ());
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::set_image (
|
||||
i.displayName_value,
|
||||
i.displayName_size,
|
||||
is_null,
|
||||
v);
|
||||
i.displayName_null = is_null;
|
||||
grew = grew || (cap != i.displayName_value.capacity ());
|
||||
}
|
||||
|
||||
// trustScore
|
||||
//
|
||||
{
|
||||
::int32_t const& v =
|
||||
o.trustScore;
|
||||
|
||||
bool is_null (false);
|
||||
sqlite::value_traits<
|
||||
::int32_t,
|
||||
sqlite::id_integer >::set_image (
|
||||
i.trustScore_value,
|
||||
is_null,
|
||||
v);
|
||||
i.trustScore_null = is_null;
|
||||
}
|
||||
|
||||
return grew;
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::Agent, id_sqlite >::
|
||||
init (object_type& o,
|
||||
const image_type& i,
|
||||
database* db)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (o);
|
||||
ODB_POTENTIALLY_UNUSED (i);
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
// id
|
||||
//
|
||||
{
|
||||
::std::string& v =
|
||||
o.id;
|
||||
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::set_value (
|
||||
v,
|
||||
i.id_value,
|
||||
i.id_size,
|
||||
i.id_null);
|
||||
}
|
||||
|
||||
// role
|
||||
//
|
||||
{
|
||||
::std::string& v =
|
||||
o.role;
|
||||
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::set_value (
|
||||
v,
|
||||
i.role_value,
|
||||
i.role_size,
|
||||
i.role_null);
|
||||
}
|
||||
|
||||
// persistent
|
||||
//
|
||||
{
|
||||
bool& v =
|
||||
o.persistent;
|
||||
|
||||
sqlite::value_traits<
|
||||
bool,
|
||||
sqlite::id_integer >::set_value (
|
||||
v,
|
||||
i.persistent_value,
|
||||
i.persistent_null);
|
||||
}
|
||||
|
||||
// displayName
|
||||
//
|
||||
{
|
||||
::std::string& v =
|
||||
o.displayName;
|
||||
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::set_value (
|
||||
v,
|
||||
i.displayName_value,
|
||||
i.displayName_size,
|
||||
i.displayName_null);
|
||||
}
|
||||
|
||||
// trustScore
|
||||
//
|
||||
{
|
||||
::int32_t& v =
|
||||
o.trustScore;
|
||||
|
||||
sqlite::value_traits<
|
||||
::int32_t,
|
||||
sqlite::id_integer >::set_value (
|
||||
v,
|
||||
i.trustScore_value,
|
||||
i.trustScore_null);
|
||||
}
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::Agent, id_sqlite >::
|
||||
init (id_image_type& i, const id_type& id)
|
||||
{
|
||||
bool grew (false);
|
||||
{
|
||||
bool is_null (false);
|
||||
std::size_t cap (i.id_value.capacity ());
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::set_image (
|
||||
i.id_value,
|
||||
i.id_size,
|
||||
is_null,
|
||||
id);
|
||||
i.id_null = is_null;
|
||||
grew = grew || (cap != i.id_value.capacity ());
|
||||
}
|
||||
|
||||
if (grew)
|
||||
i.version++;
|
||||
}
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_sqlite >::persist_statement[] =
|
||||
"INSERT INTO \"Agent\" "
|
||||
"(\"id\", "
|
||||
"\"role\", "
|
||||
"\"persistent\", "
|
||||
"\"displayName\", "
|
||||
"\"trustScore\") "
|
||||
"VALUES "
|
||||
"(?, ?, ?, ?, ?)";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_sqlite >::find_statement[] =
|
||||
"SELECT "
|
||||
"\"Agent\".\"id\", "
|
||||
"\"Agent\".\"role\", "
|
||||
"\"Agent\".\"persistent\", "
|
||||
"\"Agent\".\"displayName\", "
|
||||
"\"Agent\".\"trustScore\" "
|
||||
"FROM \"Agent\" "
|
||||
"WHERE \"Agent\".\"id\"=?";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_sqlite >::update_statement[] =
|
||||
"UPDATE \"Agent\" "
|
||||
"SET "
|
||||
"\"role\"=?, "
|
||||
"\"persistent\"=?, "
|
||||
"\"displayName\"=?, "
|
||||
"\"trustScore\"=? "
|
||||
"WHERE \"id\"=?";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_sqlite >::erase_statement[] =
|
||||
"DELETE FROM \"Agent\" "
|
||||
"WHERE \"id\"=?";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_sqlite >::query_statement[] =
|
||||
"SELECT "
|
||||
"\"Agent\".\"id\", "
|
||||
"\"Agent\".\"role\", "
|
||||
"\"Agent\".\"persistent\", "
|
||||
"\"Agent\".\"displayName\", "
|
||||
"\"Agent\".\"trustScore\" "
|
||||
"FROM \"Agent\"";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_sqlite >::erase_query_statement[] =
|
||||
"DELETE FROM \"Agent\"";
|
||||
|
||||
const char access::object_traits_impl< ::models::Agent, id_sqlite >::table_name[] =
|
||||
"\"Agent\"";
|
||||
|
||||
void access::object_traits_impl< ::models::Agent, id_sqlite >::
|
||||
persist (database& db, const object_type& obj)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
using namespace sqlite;
|
||||
|
||||
sqlite::connection& conn (
|
||||
sqlite::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
callback (db,
|
||||
obj,
|
||||
callback_event::pre_persist);
|
||||
|
||||
image_type& im (sts.image ());
|
||||
binding& imb (sts.insert_image_binding ());
|
||||
|
||||
if (init (im, obj, statement_insert))
|
||||
im.version++;
|
||||
|
||||
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 ();
|
||||
|
||||
callback (db,
|
||||
obj,
|
||||
callback_event::post_persist);
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::Agent, id_sqlite >::
|
||||
update (database& db, const object_type& obj)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
using namespace sqlite;
|
||||
using sqlite::update_statement;
|
||||
|
||||
callback (db, obj, callback_event::pre_update);
|
||||
|
||||
sqlite::transaction& tr (sqlite::transaction::current ());
|
||||
sqlite::connection& conn (tr.connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
const id_type& id (
|
||||
obj.id);
|
||||
id_image_type& idi (sts.id_image ());
|
||||
init (idi, id);
|
||||
|
||||
image_type& im (sts.image ());
|
||||
if (init (im, obj, statement_update))
|
||||
im.version++;
|
||||
|
||||
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< ::models::Agent, id_sqlite >::
|
||||
erase (database& db, const id_type& id)
|
||||
{
|
||||
using namespace sqlite;
|
||||
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
sqlite::connection& conn (
|
||||
sqlite::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
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< ::models::Agent, id_sqlite >::pointer_type
|
||||
access::object_traits_impl< ::models::Agent, id_sqlite >::
|
||||
find (database& db, const id_type& id)
|
||||
{
|
||||
using namespace sqlite;
|
||||
|
||||
{
|
||||
pointer_type p (pointer_cache_traits::find (db, id));
|
||||
|
||||
if (!pointer_traits::null_ptr (p))
|
||||
return p;
|
||||
}
|
||||
|
||||
sqlite::connection& conn (
|
||||
sqlite::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
statements_type::auto_lock l (sts);
|
||||
|
||||
if (l.locked ())
|
||||
{
|
||||
if (!find_ (sts, &id))
|
||||
return pointer_type ();
|
||||
}
|
||||
|
||||
pointer_type p (
|
||||
access::object_factory<object_type, pointer_type>::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);
|
||||
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< ::models::Agent, id_sqlite >::
|
||||
find (database& db, const id_type& id, object_type& obj)
|
||||
{
|
||||
using namespace sqlite;
|
||||
|
||||
sqlite::connection& conn (
|
||||
sqlite::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
statements_type::auto_lock l (sts);
|
||||
|
||||
if (!find_ (sts, &id))
|
||||
return false;
|
||||
|
||||
select_statement& st (sts.find_statement ());
|
||||
ODB_POTENTIALLY_UNUSED (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);
|
||||
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< ::models::Agent, id_sqlite >::
|
||||
reload (database& db, object_type& obj)
|
||||
{
|
||||
using namespace sqlite;
|
||||
|
||||
sqlite::connection& conn (
|
||||
sqlite::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
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);
|
||||
|
||||
callback (db, obj, callback_event::pre_load);
|
||||
init (obj, sts.image (), &db);
|
||||
load_ (sts, obj, true);
|
||||
sts.load_delayed (0);
|
||||
l.unlock ();
|
||||
callback (db, obj, callback_event::post_load);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool access::object_traits_impl< ::models::Agent, id_sqlite >::
|
||||
find_ (statements_type& sts,
|
||||
const id_type* id)
|
||||
{
|
||||
using namespace sqlite;
|
||||
|
||||
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::truncated)
|
||||
{
|
||||
if (grow (im, sts.select_image_truncated ()))
|
||||
im.version++;
|
||||
|
||||
if (im.version != sts.select_image_version ())
|
||||
{
|
||||
bind (imb.bind, im, statement_select);
|
||||
sts.select_image_version (im.version);
|
||||
imb.version++;
|
||||
st.refetch ();
|
||||
}
|
||||
}
|
||||
|
||||
return r != select_statement::no_data;
|
||||
}
|
||||
|
||||
result< access::object_traits_impl< ::models::Agent, id_sqlite >::object_type >
|
||||
access::object_traits_impl< ::models::Agent, id_sqlite >::
|
||||
query (database&, const query_base_type& q)
|
||||
{
|
||||
using namespace sqlite;
|
||||
using odb::details::shared;
|
||||
using odb::details::shared_ptr;
|
||||
|
||||
sqlite::connection& conn (
|
||||
sqlite::transaction::current ().connection ());
|
||||
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
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++;
|
||||
}
|
||||
|
||||
std::string text (query_statement);
|
||||
if (!q.empty ())
|
||||
{
|
||||
text += " ";
|
||||
text += q.clause ();
|
||||
}
|
||||
|
||||
q.init_parameters ();
|
||||
shared_ptr<select_statement> st (
|
||||
new (shared) select_statement (
|
||||
conn,
|
||||
text,
|
||||
false,
|
||||
true,
|
||||
q.parameters_binding (),
|
||||
imb));
|
||||
|
||||
st->execute ();
|
||||
|
||||
shared_ptr< odb::object_result_impl<object_type> > r (
|
||||
new (shared) sqlite::object_result_impl<object_type> (
|
||||
q, st, sts, 0));
|
||||
|
||||
return result<object_type> (r);
|
||||
}
|
||||
|
||||
unsigned long long access::object_traits_impl< ::models::Agent, id_sqlite >::
|
||||
erase_query (database&, const query_base_type& q)
|
||||
{
|
||||
using namespace sqlite;
|
||||
|
||||
sqlite::connection& conn (
|
||||
sqlite::transaction::current ().connection ());
|
||||
|
||||
std::string text (erase_query_statement);
|
||||
if (!q.empty ())
|
||||
{
|
||||
text += ' ';
|
||||
text += q.clause ();
|
||||
}
|
||||
|
||||
q.init_parameters ();
|
||||
delete_statement st (
|
||||
conn,
|
||||
text,
|
||||
q.parameters_binding ());
|
||||
|
||||
return st.execute ();
|
||||
}
|
||||
}
|
||||
|
||||
#include <odb/post.hxx>
|
||||
342
db/test-schema-v1.2/generated-sql-ddl/sqlite/Agent-odb.hxx
Normal file
342
db/test-schema-v1.2/generated-sql-ddl/sqlite/Agent-odb.hxx
Normal file
@@ -0,0 +1,342 @@
|
||||
// This file was generated by ODB, object-relational mapping (ORM)
|
||||
// compiler for C++.
|
||||
//
|
||||
|
||||
#ifndef AGENT_ODB_HXX
|
||||
#define AGENT_ODB_HXX
|
||||
|
||||
#include <odb/version.hxx>
|
||||
|
||||
#if (ODB_VERSION != 20400UL)
|
||||
#error ODB runtime version mismatch
|
||||
#endif
|
||||
|
||||
#include <odb/pre.hxx>
|
||||
|
||||
#include "Agent.h"
|
||||
|
||||
#include <memory>
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
#include <odb/core.hxx>
|
||||
#include <odb/traits.hxx>
|
||||
#include <odb/callback.hxx>
|
||||
#include <odb/wrapper-traits.hxx>
|
||||
#include <odb/pointer-traits.hxx>
|
||||
#include <odb/container-traits.hxx>
|
||||
#include <odb/no-op-cache-traits.hxx>
|
||||
#include <odb/result.hxx>
|
||||
#include <odb/simple-object-result.hxx>
|
||||
|
||||
#include <odb/details/unused.hxx>
|
||||
#include <odb/details/shared-ptr.hxx>
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// Agent
|
||||
//
|
||||
template <>
|
||||
struct class_traits< ::models::Agent >
|
||||
{
|
||||
static const class_kind kind = class_object;
|
||||
};
|
||||
|
||||
template <>
|
||||
class access::object_traits< ::models::Agent >
|
||||
{
|
||||
public:
|
||||
typedef ::models::Agent object_type;
|
||||
typedef ::models::Agent* pointer_type;
|
||||
typedef odb::pointer_traits<pointer_type> pointer_traits;
|
||||
|
||||
static const bool polymorphic = false;
|
||||
|
||||
typedef ::std::string id_type;
|
||||
|
||||
static const bool auto_id = false;
|
||||
|
||||
static const bool abstract = false;
|
||||
|
||||
static id_type
|
||||
id (const object_type&);
|
||||
|
||||
typedef
|
||||
no_op_pointer_cache_traits<pointer_type>
|
||||
pointer_cache_traits;
|
||||
|
||||
typedef
|
||||
no_op_reference_cache_traits<object_type>
|
||||
reference_cache_traits;
|
||||
|
||||
static void
|
||||
callback (database&, object_type&, callback_event);
|
||||
|
||||
static void
|
||||
callback (database&, const object_type&, callback_event);
|
||||
};
|
||||
}
|
||||
|
||||
#include <odb/details/buffer.hxx>
|
||||
|
||||
#include <odb/sqlite/version.hxx>
|
||||
#include <odb/sqlite/forward.hxx>
|
||||
#include <odb/sqlite/binding.hxx>
|
||||
#include <odb/sqlite/sqlite-types.hxx>
|
||||
#include <odb/sqlite/query.hxx>
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// Agent
|
||||
//
|
||||
template <typename A>
|
||||
struct query_columns< ::models::Agent, id_sqlite, A >
|
||||
{
|
||||
// id
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
id_type_;
|
||||
|
||||
static const id_type_ id;
|
||||
|
||||
// role
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
role_type_;
|
||||
|
||||
static const role_type_ role;
|
||||
|
||||
// persistent
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
bool,
|
||||
sqlite::id_integer >::query_type,
|
||||
sqlite::id_integer >
|
||||
persistent_type_;
|
||||
|
||||
static const persistent_type_ persistent;
|
||||
|
||||
// displayName
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
displayName_type_;
|
||||
|
||||
static const displayName_type_ displayName;
|
||||
|
||||
// trustScore
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::int32_t,
|
||||
sqlite::id_integer >::query_type,
|
||||
sqlite::id_integer >
|
||||
trustScore_type_;
|
||||
|
||||
static const trustScore_type_ trustScore;
|
||||
};
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::Agent, id_sqlite, A >::id_type_
|
||||
query_columns< ::models::Agent, id_sqlite, A >::
|
||||
id (A::table_name, "\"id\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::Agent, id_sqlite, A >::role_type_
|
||||
query_columns< ::models::Agent, id_sqlite, A >::
|
||||
role (A::table_name, "\"role\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::Agent, id_sqlite, A >::persistent_type_
|
||||
query_columns< ::models::Agent, id_sqlite, A >::
|
||||
persistent (A::table_name, "\"persistent\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::Agent, id_sqlite, A >::displayName_type_
|
||||
query_columns< ::models::Agent, id_sqlite, A >::
|
||||
displayName (A::table_name, "\"displayName\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::Agent, id_sqlite, A >::trustScore_type_
|
||||
query_columns< ::models::Agent, id_sqlite, A >::
|
||||
trustScore (A::table_name, "\"trustScore\"", 0);
|
||||
|
||||
template <typename A>
|
||||
struct pointer_query_columns< ::models::Agent, id_sqlite, A >:
|
||||
query_columns< ::models::Agent, id_sqlite, A >
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
class access::object_traits_impl< ::models::Agent, id_sqlite >:
|
||||
public access::object_traits< ::models::Agent >
|
||||
{
|
||||
public:
|
||||
struct id_image_type
|
||||
{
|
||||
details::buffer id_value;
|
||||
std::size_t id_size;
|
||||
bool id_null;
|
||||
|
||||
std::size_t version;
|
||||
};
|
||||
|
||||
struct image_type
|
||||
{
|
||||
// id
|
||||
//
|
||||
details::buffer id_value;
|
||||
std::size_t id_size;
|
||||
bool id_null;
|
||||
|
||||
// role
|
||||
//
|
||||
details::buffer role_value;
|
||||
std::size_t role_size;
|
||||
bool role_null;
|
||||
|
||||
// persistent
|
||||
//
|
||||
long long persistent_value;
|
||||
bool persistent_null;
|
||||
|
||||
// displayName
|
||||
//
|
||||
details::buffer displayName_value;
|
||||
std::size_t displayName_size;
|
||||
bool displayName_null;
|
||||
|
||||
// trustScore
|
||||
//
|
||||
long long trustScore_value;
|
||||
bool trustScore_null;
|
||||
|
||||
std::size_t version;
|
||||
};
|
||||
|
||||
struct extra_statement_cache_type;
|
||||
|
||||
using object_traits<object_type>::id;
|
||||
|
||||
static id_type
|
||||
id (const image_type&);
|
||||
|
||||
static bool
|
||||
grow (image_type&,
|
||||
bool*);
|
||||
|
||||
static void
|
||||
bind (sqlite::bind*,
|
||||
image_type&,
|
||||
sqlite::statement_kind);
|
||||
|
||||
static void
|
||||
bind (sqlite::bind*, id_image_type&);
|
||||
|
||||
static bool
|
||||
init (image_type&,
|
||||
const object_type&,
|
||||
sqlite::statement_kind);
|
||||
|
||||
static void
|
||||
init (object_type&,
|
||||
const image_type&,
|
||||
database*);
|
||||
|
||||
static void
|
||||
init (id_image_type&, const id_type&);
|
||||
|
||||
typedef sqlite::object_statements<object_type> statements_type;
|
||||
|
||||
typedef sqlite::query_base query_base_type;
|
||||
|
||||
static const std::size_t column_count = 5UL;
|
||||
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 const char query_statement[];
|
||||
static const char erase_query_statement[];
|
||||
|
||||
static const char table_name[];
|
||||
|
||||
static void
|
||||
persist (database&, const 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&);
|
||||
|
||||
static result<object_type>
|
||||
query (database&, const query_base_type&);
|
||||
|
||||
static unsigned long long
|
||||
erase_query (database&, const query_base_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< ::models::Agent, id_common >:
|
||||
public access::object_traits_impl< ::models::Agent, id_sqlite >
|
||||
{
|
||||
};
|
||||
|
||||
// Agent
|
||||
//
|
||||
}
|
||||
|
||||
#include "Agent-odb.ixx"
|
||||
|
||||
#include <odb/post.hxx>
|
||||
|
||||
#endif // AGENT_ODB_HXX
|
||||
61
db/test-schema-v1.2/generated-sql-ddl/sqlite/Agent-odb.ixx
Normal file
61
db/test-schema-v1.2/generated-sql-ddl/sqlite/Agent-odb.ixx
Normal file
@@ -0,0 +1,61 @@
|
||||
// This file was generated by ODB, object-relational mapping (ORM)
|
||||
// compiler for C++.
|
||||
//
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// Agent
|
||||
//
|
||||
|
||||
inline
|
||||
access::object_traits< ::models::Agent >::id_type
|
||||
access::object_traits< ::models::Agent >::
|
||||
id (const object_type& o)
|
||||
{
|
||||
return o.id;
|
||||
}
|
||||
|
||||
inline
|
||||
void access::object_traits< ::models::Agent >::
|
||||
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< ::models::Agent >::
|
||||
callback (database& db, const object_type& x, callback_event e)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
ODB_POTENTIALLY_UNUSED (x);
|
||||
ODB_POTENTIALLY_UNUSED (e);
|
||||
}
|
||||
}
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// Agent
|
||||
//
|
||||
|
||||
inline
|
||||
void access::object_traits_impl< ::models::Agent, id_sqlite >::
|
||||
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< ::models::Agent, id_sqlite >::
|
||||
load_ (statements_type& sts,
|
||||
object_type& obj,
|
||||
bool)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (sts);
|
||||
ODB_POTENTIALLY_UNUSED (obj);
|
||||
}
|
||||
}
|
||||
|
||||
25
db/test-schema-v1.2/generated-sql-ddl/sqlite/Agent.sql
Normal file
25
db/test-schema-v1.2/generated-sql-ddl/sqlite/Agent.sql
Normal file
@@ -0,0 +1,25 @@
|
||||
/* This file was generated by ODB, object-relational mapping (ORM)
|
||||
* compiler for C++.
|
||||
*/
|
||||
|
||||
DROP TABLE IF EXISTS "Agent";
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "schema_version" (
|
||||
"name" TEXT NOT NULL PRIMARY KEY,
|
||||
"version" INTEGER NOT NULL,
|
||||
"migration" INTEGER NOT NULL);
|
||||
|
||||
DELETE FROM "schema_version"
|
||||
WHERE "name" = '';
|
||||
|
||||
CREATE TABLE "Agent" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"role" TEXT NOT NULL,
|
||||
"persistent" INTEGER NOT NULL,
|
||||
"displayName" TEXT NOT NULL,
|
||||
"trustScore" INTEGER NOT NULL);
|
||||
|
||||
INSERT OR IGNORE INTO "schema_version" (
|
||||
"name", "version", "migration")
|
||||
VALUES ('', 2, 0);
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
/* This file was generated by ODB, object-relational mapping (ORM)
|
||||
* compiler for C++.
|
||||
*/
|
||||
|
||||
UPDATE "schema_version"
|
||||
SET "migration" = 0
|
||||
WHERE "name" = '';
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
/* This file was generated by ODB, object-relational mapping (ORM)
|
||||
* compiler for C++.
|
||||
*/
|
||||
|
||||
CREATE TABLE "GovernmentAddress" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"addressLabel" TEXT NOT NULL,
|
||||
"regionLookupKey" TEXT NOT NULL);
|
||||
|
||||
UPDATE "schema_version"
|
||||
SET "version" = 2, "migration" = 1
|
||||
WHERE "name" = '';
|
||||
|
||||
@@ -0,0 +1,725 @@
|
||||
// This file was generated by ODB, object-relational mapping (ORM)
|
||||
// compiler for C++.
|
||||
//
|
||||
|
||||
#include <odb/pre.hxx>
|
||||
|
||||
#include "GovernmentAddress-odb.hxx"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring> // std::memcpy
|
||||
|
||||
|
||||
#include <odb/sqlite/traits.hxx>
|
||||
#include <odb/sqlite/database.hxx>
|
||||
#include <odb/sqlite/transaction.hxx>
|
||||
#include <odb/sqlite/connection.hxx>
|
||||
#include <odb/sqlite/statement.hxx>
|
||||
#include <odb/sqlite/statement-cache.hxx>
|
||||
#include <odb/sqlite/simple-object-statements.hxx>
|
||||
#include <odb/sqlite/container-statements.hxx>
|
||||
#include <odb/sqlite/exceptions.hxx>
|
||||
#include <odb/sqlite/simple-object-result.hxx>
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// GovernmentAddress
|
||||
//
|
||||
|
||||
struct access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::extra_statement_cache_type
|
||||
{
|
||||
extra_statement_cache_type (
|
||||
sqlite::connection&,
|
||||
image_type&,
|
||||
id_image_type&,
|
||||
sqlite::binding&,
|
||||
sqlite::binding&)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::id_type
|
||||
access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::
|
||||
id (const image_type& i)
|
||||
{
|
||||
sqlite::database* db (0);
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
id_type id;
|
||||
{
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::set_value (
|
||||
id,
|
||||
i.id_value,
|
||||
i.id_size,
|
||||
i.id_null);
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
bool access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::
|
||||
grow (image_type& i,
|
||||
bool* t)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (i);
|
||||
ODB_POTENTIALLY_UNUSED (t);
|
||||
|
||||
bool grew (false);
|
||||
|
||||
// id
|
||||
//
|
||||
if (t[0UL])
|
||||
{
|
||||
i.id_value.capacity (i.id_size);
|
||||
grew = true;
|
||||
}
|
||||
|
||||
// addressLabel
|
||||
//
|
||||
if (t[1UL])
|
||||
{
|
||||
i.addressLabel_value.capacity (i.addressLabel_size);
|
||||
grew = true;
|
||||
}
|
||||
|
||||
// regionLookupKey
|
||||
//
|
||||
if (t[2UL])
|
||||
{
|
||||
i.regionLookupKey_value.capacity (i.regionLookupKey_size);
|
||||
grew = true;
|
||||
}
|
||||
|
||||
return grew;
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::
|
||||
bind (sqlite::bind* b,
|
||||
image_type& i,
|
||||
sqlite::statement_kind sk)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (sk);
|
||||
|
||||
using namespace sqlite;
|
||||
|
||||
std::size_t n (0);
|
||||
|
||||
// id
|
||||
//
|
||||
if (sk != statement_update)
|
||||
{
|
||||
b[n].type = sqlite::image_traits<
|
||||
::std::string,
|
||||
sqlite::id_text>::bind_value;
|
||||
b[n].buffer = i.id_value.data ();
|
||||
b[n].size = &i.id_size;
|
||||
b[n].capacity = i.id_value.capacity ();
|
||||
b[n].is_null = &i.id_null;
|
||||
n++;
|
||||
}
|
||||
|
||||
// addressLabel
|
||||
//
|
||||
b[n].type = sqlite::image_traits<
|
||||
::std::string,
|
||||
sqlite::id_text>::bind_value;
|
||||
b[n].buffer = i.addressLabel_value.data ();
|
||||
b[n].size = &i.addressLabel_size;
|
||||
b[n].capacity = i.addressLabel_value.capacity ();
|
||||
b[n].is_null = &i.addressLabel_null;
|
||||
n++;
|
||||
|
||||
// regionLookupKey
|
||||
//
|
||||
b[n].type = sqlite::image_traits<
|
||||
::std::string,
|
||||
sqlite::id_text>::bind_value;
|
||||
b[n].buffer = i.regionLookupKey_value.data ();
|
||||
b[n].size = &i.regionLookupKey_size;
|
||||
b[n].capacity = i.regionLookupKey_value.capacity ();
|
||||
b[n].is_null = &i.regionLookupKey_null;
|
||||
n++;
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::
|
||||
bind (sqlite::bind* b, id_image_type& i)
|
||||
{
|
||||
std::size_t n (0);
|
||||
b[n].type = sqlite::image_traits<
|
||||
::std::string,
|
||||
sqlite::id_text>::bind_value;
|
||||
b[n].buffer = i.id_value.data ();
|
||||
b[n].size = &i.id_size;
|
||||
b[n].capacity = i.id_value.capacity ();
|
||||
b[n].is_null = &i.id_null;
|
||||
}
|
||||
|
||||
bool access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::
|
||||
init (image_type& i,
|
||||
const object_type& o,
|
||||
sqlite::statement_kind sk)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (i);
|
||||
ODB_POTENTIALLY_UNUSED (o);
|
||||
ODB_POTENTIALLY_UNUSED (sk);
|
||||
|
||||
using namespace sqlite;
|
||||
|
||||
bool grew (false);
|
||||
|
||||
// id
|
||||
//
|
||||
if (sk == statement_insert)
|
||||
{
|
||||
::std::string const& v =
|
||||
o.id;
|
||||
|
||||
bool is_null (false);
|
||||
std::size_t cap (i.id_value.capacity ());
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::set_image (
|
||||
i.id_value,
|
||||
i.id_size,
|
||||
is_null,
|
||||
v);
|
||||
i.id_null = is_null;
|
||||
grew = grew || (cap != i.id_value.capacity ());
|
||||
}
|
||||
|
||||
// addressLabel
|
||||
//
|
||||
{
|
||||
::std::string const& v =
|
||||
o.addressLabel;
|
||||
|
||||
bool is_null (false);
|
||||
std::size_t cap (i.addressLabel_value.capacity ());
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::set_image (
|
||||
i.addressLabel_value,
|
||||
i.addressLabel_size,
|
||||
is_null,
|
||||
v);
|
||||
i.addressLabel_null = is_null;
|
||||
grew = grew || (cap != i.addressLabel_value.capacity ());
|
||||
}
|
||||
|
||||
// regionLookupKey
|
||||
//
|
||||
{
|
||||
::std::string const& v =
|
||||
o.regionLookupKey;
|
||||
|
||||
bool is_null (false);
|
||||
std::size_t cap (i.regionLookupKey_value.capacity ());
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::set_image (
|
||||
i.regionLookupKey_value,
|
||||
i.regionLookupKey_size,
|
||||
is_null,
|
||||
v);
|
||||
i.regionLookupKey_null = is_null;
|
||||
grew = grew || (cap != i.regionLookupKey_value.capacity ());
|
||||
}
|
||||
|
||||
return grew;
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::
|
||||
init (object_type& o,
|
||||
const image_type& i,
|
||||
database* db)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (o);
|
||||
ODB_POTENTIALLY_UNUSED (i);
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
// id
|
||||
//
|
||||
{
|
||||
::std::string& v =
|
||||
o.id;
|
||||
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::set_value (
|
||||
v,
|
||||
i.id_value,
|
||||
i.id_size,
|
||||
i.id_null);
|
||||
}
|
||||
|
||||
// addressLabel
|
||||
//
|
||||
{
|
||||
::std::string& v =
|
||||
o.addressLabel;
|
||||
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::set_value (
|
||||
v,
|
||||
i.addressLabel_value,
|
||||
i.addressLabel_size,
|
||||
i.addressLabel_null);
|
||||
}
|
||||
|
||||
// regionLookupKey
|
||||
//
|
||||
{
|
||||
::std::string& v =
|
||||
o.regionLookupKey;
|
||||
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::set_value (
|
||||
v,
|
||||
i.regionLookupKey_value,
|
||||
i.regionLookupKey_size,
|
||||
i.regionLookupKey_null);
|
||||
}
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::
|
||||
init (id_image_type& i, const id_type& id)
|
||||
{
|
||||
bool grew (false);
|
||||
{
|
||||
bool is_null (false);
|
||||
std::size_t cap (i.id_value.capacity ());
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::set_image (
|
||||
i.id_value,
|
||||
i.id_size,
|
||||
is_null,
|
||||
id);
|
||||
i.id_null = is_null;
|
||||
grew = grew || (cap != i.id_value.capacity ());
|
||||
}
|
||||
|
||||
if (grew)
|
||||
i.version++;
|
||||
}
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::persist_statement[] =
|
||||
"INSERT INTO \"GovernmentAddress\" "
|
||||
"(\"id\", "
|
||||
"\"addressLabel\", "
|
||||
"\"regionLookupKey\") "
|
||||
"VALUES "
|
||||
"(?, ?, ?)";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::find_statement[] =
|
||||
"SELECT "
|
||||
"\"GovernmentAddress\".\"id\", "
|
||||
"\"GovernmentAddress\".\"addressLabel\", "
|
||||
"\"GovernmentAddress\".\"regionLookupKey\" "
|
||||
"FROM \"GovernmentAddress\" "
|
||||
"WHERE \"GovernmentAddress\".\"id\"=?";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::update_statement[] =
|
||||
"UPDATE \"GovernmentAddress\" "
|
||||
"SET "
|
||||
"\"addressLabel\"=?, "
|
||||
"\"regionLookupKey\"=? "
|
||||
"WHERE \"id\"=?";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::erase_statement[] =
|
||||
"DELETE FROM \"GovernmentAddress\" "
|
||||
"WHERE \"id\"=?";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::query_statement[] =
|
||||
"SELECT "
|
||||
"\"GovernmentAddress\".\"id\", "
|
||||
"\"GovernmentAddress\".\"addressLabel\", "
|
||||
"\"GovernmentAddress\".\"regionLookupKey\" "
|
||||
"FROM \"GovernmentAddress\"";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::erase_query_statement[] =
|
||||
"DELETE FROM \"GovernmentAddress\"";
|
||||
|
||||
const char access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::table_name[] =
|
||||
"\"GovernmentAddress\"";
|
||||
|
||||
void access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::
|
||||
persist (database& db, const object_type& obj)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
using namespace sqlite;
|
||||
|
||||
sqlite::connection& conn (
|
||||
sqlite::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
callback (db,
|
||||
obj,
|
||||
callback_event::pre_persist);
|
||||
|
||||
image_type& im (sts.image ());
|
||||
binding& imb (sts.insert_image_binding ());
|
||||
|
||||
if (init (im, obj, statement_insert))
|
||||
im.version++;
|
||||
|
||||
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 ();
|
||||
|
||||
callback (db,
|
||||
obj,
|
||||
callback_event::post_persist);
|
||||
}
|
||||
|
||||
void access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::
|
||||
update (database& db, const object_type& obj)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
using namespace sqlite;
|
||||
using sqlite::update_statement;
|
||||
|
||||
callback (db, obj, callback_event::pre_update);
|
||||
|
||||
sqlite::transaction& tr (sqlite::transaction::current ());
|
||||
sqlite::connection& conn (tr.connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
const id_type& id (
|
||||
obj.id);
|
||||
id_image_type& idi (sts.id_image ());
|
||||
init (idi, id);
|
||||
|
||||
image_type& im (sts.image ());
|
||||
if (init (im, obj, statement_update))
|
||||
im.version++;
|
||||
|
||||
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< ::models::GovernmentAddress, id_sqlite >::
|
||||
erase (database& db, const id_type& id)
|
||||
{
|
||||
using namespace sqlite;
|
||||
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
|
||||
sqlite::connection& conn (
|
||||
sqlite::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
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< ::models::GovernmentAddress, id_sqlite >::pointer_type
|
||||
access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::
|
||||
find (database& db, const id_type& id)
|
||||
{
|
||||
using namespace sqlite;
|
||||
|
||||
{
|
||||
pointer_type p (pointer_cache_traits::find (db, id));
|
||||
|
||||
if (!pointer_traits::null_ptr (p))
|
||||
return p;
|
||||
}
|
||||
|
||||
sqlite::connection& conn (
|
||||
sqlite::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
statements_type::auto_lock l (sts);
|
||||
|
||||
if (l.locked ())
|
||||
{
|
||||
if (!find_ (sts, &id))
|
||||
return pointer_type ();
|
||||
}
|
||||
|
||||
pointer_type p (
|
||||
access::object_factory<object_type, pointer_type>::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);
|
||||
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< ::models::GovernmentAddress, id_sqlite >::
|
||||
find (database& db, const id_type& id, object_type& obj)
|
||||
{
|
||||
using namespace sqlite;
|
||||
|
||||
sqlite::connection& conn (
|
||||
sqlite::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
statements_type::auto_lock l (sts);
|
||||
|
||||
if (!find_ (sts, &id))
|
||||
return false;
|
||||
|
||||
select_statement& st (sts.find_statement ());
|
||||
ODB_POTENTIALLY_UNUSED (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);
|
||||
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< ::models::GovernmentAddress, id_sqlite >::
|
||||
reload (database& db, object_type& obj)
|
||||
{
|
||||
using namespace sqlite;
|
||||
|
||||
sqlite::connection& conn (
|
||||
sqlite::transaction::current ().connection ());
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
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);
|
||||
|
||||
callback (db, obj, callback_event::pre_load);
|
||||
init (obj, sts.image (), &db);
|
||||
load_ (sts, obj, true);
|
||||
sts.load_delayed (0);
|
||||
l.unlock ();
|
||||
callback (db, obj, callback_event::post_load);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::
|
||||
find_ (statements_type& sts,
|
||||
const id_type* id)
|
||||
{
|
||||
using namespace sqlite;
|
||||
|
||||
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::truncated)
|
||||
{
|
||||
if (grow (im, sts.select_image_truncated ()))
|
||||
im.version++;
|
||||
|
||||
if (im.version != sts.select_image_version ())
|
||||
{
|
||||
bind (imb.bind, im, statement_select);
|
||||
sts.select_image_version (im.version);
|
||||
imb.version++;
|
||||
st.refetch ();
|
||||
}
|
||||
}
|
||||
|
||||
return r != select_statement::no_data;
|
||||
}
|
||||
|
||||
result< access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::object_type >
|
||||
access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::
|
||||
query (database&, const query_base_type& q)
|
||||
{
|
||||
using namespace sqlite;
|
||||
using odb::details::shared;
|
||||
using odb::details::shared_ptr;
|
||||
|
||||
sqlite::connection& conn (
|
||||
sqlite::transaction::current ().connection ());
|
||||
|
||||
statements_type& sts (
|
||||
conn.statement_cache ().find_object<object_type> ());
|
||||
|
||||
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++;
|
||||
}
|
||||
|
||||
std::string text (query_statement);
|
||||
if (!q.empty ())
|
||||
{
|
||||
text += " ";
|
||||
text += q.clause ();
|
||||
}
|
||||
|
||||
q.init_parameters ();
|
||||
shared_ptr<select_statement> st (
|
||||
new (shared) select_statement (
|
||||
conn,
|
||||
text,
|
||||
false,
|
||||
true,
|
||||
q.parameters_binding (),
|
||||
imb));
|
||||
|
||||
st->execute ();
|
||||
|
||||
shared_ptr< odb::object_result_impl<object_type> > r (
|
||||
new (shared) sqlite::object_result_impl<object_type> (
|
||||
q, st, sts, 0));
|
||||
|
||||
return result<object_type> (r);
|
||||
}
|
||||
|
||||
unsigned long long access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::
|
||||
erase_query (database&, const query_base_type& q)
|
||||
{
|
||||
using namespace sqlite;
|
||||
|
||||
sqlite::connection& conn (
|
||||
sqlite::transaction::current ().connection ());
|
||||
|
||||
std::string text (erase_query_statement);
|
||||
if (!q.empty ())
|
||||
{
|
||||
text += ' ';
|
||||
text += q.clause ();
|
||||
}
|
||||
|
||||
q.init_parameters ();
|
||||
delete_statement st (
|
||||
conn,
|
||||
text,
|
||||
q.parameters_binding ());
|
||||
|
||||
return st.execute ();
|
||||
}
|
||||
}
|
||||
|
||||
#include <odb/post.hxx>
|
||||
@@ -0,0 +1,298 @@
|
||||
// This file was generated by ODB, object-relational mapping (ORM)
|
||||
// compiler for C++.
|
||||
//
|
||||
|
||||
#ifndef GOVERNMENT_ADDRESS_ODB_HXX
|
||||
#define GOVERNMENT_ADDRESS_ODB_HXX
|
||||
|
||||
#include <odb/version.hxx>
|
||||
|
||||
#if (ODB_VERSION != 20400UL)
|
||||
#error ODB runtime version mismatch
|
||||
#endif
|
||||
|
||||
#include <odb/pre.hxx>
|
||||
|
||||
#include "GovernmentAddress.h"
|
||||
|
||||
#include <memory>
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
#include <odb/core.hxx>
|
||||
#include <odb/traits.hxx>
|
||||
#include <odb/callback.hxx>
|
||||
#include <odb/wrapper-traits.hxx>
|
||||
#include <odb/pointer-traits.hxx>
|
||||
#include <odb/container-traits.hxx>
|
||||
#include <odb/no-op-cache-traits.hxx>
|
||||
#include <odb/result.hxx>
|
||||
#include <odb/simple-object-result.hxx>
|
||||
|
||||
#include <odb/details/unused.hxx>
|
||||
#include <odb/details/shared-ptr.hxx>
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// GovernmentAddress
|
||||
//
|
||||
template <>
|
||||
struct class_traits< ::models::GovernmentAddress >
|
||||
{
|
||||
static const class_kind kind = class_object;
|
||||
};
|
||||
|
||||
template <>
|
||||
class access::object_traits< ::models::GovernmentAddress >
|
||||
{
|
||||
public:
|
||||
typedef ::models::GovernmentAddress object_type;
|
||||
typedef ::models::GovernmentAddress* pointer_type;
|
||||
typedef odb::pointer_traits<pointer_type> pointer_traits;
|
||||
|
||||
static const bool polymorphic = false;
|
||||
|
||||
typedef ::std::string id_type;
|
||||
|
||||
static const bool auto_id = false;
|
||||
|
||||
static const bool abstract = false;
|
||||
|
||||
static id_type
|
||||
id (const object_type&);
|
||||
|
||||
typedef
|
||||
no_op_pointer_cache_traits<pointer_type>
|
||||
pointer_cache_traits;
|
||||
|
||||
typedef
|
||||
no_op_reference_cache_traits<object_type>
|
||||
reference_cache_traits;
|
||||
|
||||
static void
|
||||
callback (database&, object_type&, callback_event);
|
||||
|
||||
static void
|
||||
callback (database&, const object_type&, callback_event);
|
||||
};
|
||||
}
|
||||
|
||||
#include <odb/details/buffer.hxx>
|
||||
|
||||
#include <odb/sqlite/version.hxx>
|
||||
#include <odb/sqlite/forward.hxx>
|
||||
#include <odb/sqlite/binding.hxx>
|
||||
#include <odb/sqlite/sqlite-types.hxx>
|
||||
#include <odb/sqlite/query.hxx>
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// GovernmentAddress
|
||||
//
|
||||
template <typename A>
|
||||
struct query_columns< ::models::GovernmentAddress, id_sqlite, A >
|
||||
{
|
||||
// id
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
id_type_;
|
||||
|
||||
static const id_type_ id;
|
||||
|
||||
// addressLabel
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
addressLabel_type_;
|
||||
|
||||
static const addressLabel_type_ addressLabel;
|
||||
|
||||
// regionLookupKey
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
regionLookupKey_type_;
|
||||
|
||||
static const regionLookupKey_type_ regionLookupKey;
|
||||
};
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::GovernmentAddress, id_sqlite, A >::id_type_
|
||||
query_columns< ::models::GovernmentAddress, id_sqlite, A >::
|
||||
id (A::table_name, "\"id\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::GovernmentAddress, id_sqlite, A >::addressLabel_type_
|
||||
query_columns< ::models::GovernmentAddress, id_sqlite, A >::
|
||||
addressLabel (A::table_name, "\"addressLabel\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::GovernmentAddress, id_sqlite, A >::regionLookupKey_type_
|
||||
query_columns< ::models::GovernmentAddress, id_sqlite, A >::
|
||||
regionLookupKey (A::table_name, "\"regionLookupKey\"", 0);
|
||||
|
||||
template <typename A>
|
||||
struct pointer_query_columns< ::models::GovernmentAddress, id_sqlite, A >:
|
||||
query_columns< ::models::GovernmentAddress, id_sqlite, A >
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
class access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >:
|
||||
public access::object_traits< ::models::GovernmentAddress >
|
||||
{
|
||||
public:
|
||||
struct id_image_type
|
||||
{
|
||||
details::buffer id_value;
|
||||
std::size_t id_size;
|
||||
bool id_null;
|
||||
|
||||
std::size_t version;
|
||||
};
|
||||
|
||||
struct image_type
|
||||
{
|
||||
// id
|
||||
//
|
||||
details::buffer id_value;
|
||||
std::size_t id_size;
|
||||
bool id_null;
|
||||
|
||||
// addressLabel
|
||||
//
|
||||
details::buffer addressLabel_value;
|
||||
std::size_t addressLabel_size;
|
||||
bool addressLabel_null;
|
||||
|
||||
// regionLookupKey
|
||||
//
|
||||
details::buffer regionLookupKey_value;
|
||||
std::size_t regionLookupKey_size;
|
||||
bool regionLookupKey_null;
|
||||
|
||||
std::size_t version;
|
||||
};
|
||||
|
||||
struct extra_statement_cache_type;
|
||||
|
||||
using object_traits<object_type>::id;
|
||||
|
||||
static id_type
|
||||
id (const image_type&);
|
||||
|
||||
static bool
|
||||
grow (image_type&,
|
||||
bool*);
|
||||
|
||||
static void
|
||||
bind (sqlite::bind*,
|
||||
image_type&,
|
||||
sqlite::statement_kind);
|
||||
|
||||
static void
|
||||
bind (sqlite::bind*, id_image_type&);
|
||||
|
||||
static bool
|
||||
init (image_type&,
|
||||
const object_type&,
|
||||
sqlite::statement_kind);
|
||||
|
||||
static void
|
||||
init (object_type&,
|
||||
const image_type&,
|
||||
database*);
|
||||
|
||||
static void
|
||||
init (id_image_type&, const id_type&);
|
||||
|
||||
typedef sqlite::object_statements<object_type> statements_type;
|
||||
|
||||
typedef sqlite::query_base query_base_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 const char query_statement[];
|
||||
static const char erase_query_statement[];
|
||||
|
||||
static const char table_name[];
|
||||
|
||||
static void
|
||||
persist (database&, const 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&);
|
||||
|
||||
static result<object_type>
|
||||
query (database&, const query_base_type&);
|
||||
|
||||
static unsigned long long
|
||||
erase_query (database&, const query_base_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< ::models::GovernmentAddress, id_common >:
|
||||
public access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >
|
||||
{
|
||||
};
|
||||
|
||||
// GovernmentAddress
|
||||
//
|
||||
}
|
||||
|
||||
#include "GovernmentAddress-odb.ixx"
|
||||
|
||||
#include <odb/post.hxx>
|
||||
|
||||
#endif // GOVERNMENT_ADDRESS_ODB_HXX
|
||||
@@ -0,0 +1,61 @@
|
||||
// This file was generated by ODB, object-relational mapping (ORM)
|
||||
// compiler for C++.
|
||||
//
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// GovernmentAddress
|
||||
//
|
||||
|
||||
inline
|
||||
access::object_traits< ::models::GovernmentAddress >::id_type
|
||||
access::object_traits< ::models::GovernmentAddress >::
|
||||
id (const object_type& o)
|
||||
{
|
||||
return o.id;
|
||||
}
|
||||
|
||||
inline
|
||||
void access::object_traits< ::models::GovernmentAddress >::
|
||||
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< ::models::GovernmentAddress >::
|
||||
callback (database& db, const object_type& x, callback_event e)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
ODB_POTENTIALLY_UNUSED (x);
|
||||
ODB_POTENTIALLY_UNUSED (e);
|
||||
}
|
||||
}
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// GovernmentAddress
|
||||
//
|
||||
|
||||
inline
|
||||
void access::object_traits_impl< ::models::GovernmentAddress, id_sqlite >::
|
||||
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< ::models::GovernmentAddress, id_sqlite >::
|
||||
load_ (statements_type& sts,
|
||||
object_type& obj,
|
||||
bool)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (sts);
|
||||
ODB_POTENTIALLY_UNUSED (obj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/* This file was generated by ODB, object-relational mapping (ORM)
|
||||
* compiler for C++.
|
||||
*/
|
||||
|
||||
DROP TABLE IF EXISTS "GovernmentAddress";
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "schema_version" (
|
||||
"name" TEXT NOT NULL PRIMARY KEY,
|
||||
"version" INTEGER NOT NULL,
|
||||
"migration" INTEGER NOT NULL);
|
||||
|
||||
DELETE FROM "schema_version"
|
||||
WHERE "name" = '';
|
||||
|
||||
CREATE TABLE "GovernmentAddress" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"addressLabel" TEXT NOT NULL,
|
||||
"regionLookupKey" TEXT NOT NULL);
|
||||
|
||||
INSERT OR IGNORE INTO "schema_version" (
|
||||
"name", "version", "migration")
|
||||
VALUES ('', 2, 0);
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
/* This file was generated by ODB, object-relational mapping (ORM)
|
||||
* compiler for C++.
|
||||
*/
|
||||
|
||||
UPDATE "schema_version"
|
||||
SET "migration" = 0
|
||||
WHERE "name" = '';
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/* This file was generated by ODB, object-relational mapping (ORM)
|
||||
* compiler for C++.
|
||||
*/
|
||||
|
||||
CREATE TABLE "TripAttemptResult" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"result" TEXT NOT NULL,
|
||||
"retryReason" TEXT NOT NULL,
|
||||
"governmentSuspensionReason" TEXT NOT NULL,
|
||||
"governmentTerminationReason" TEXT NOT NULL,
|
||||
"complianceSuspensionReason" TEXT NOT NULL,
|
||||
"complianceTerminationReason" TEXT NOT NULL,
|
||||
"policySuspensionReason" TEXT NOT NULL,
|
||||
"policyTerminationReason" TEXT NOT NULL,
|
||||
"cancelationReason" TEXT NOT NULL,
|
||||
"failureReason" TEXT NOT NULL,
|
||||
"details" TEXT NOT NULL);
|
||||
|
||||
UPDATE "schema_version"
|
||||
SET "version" = 2, "migration" = 1
|
||||
WHERE "name" = '';
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,505 @@
|
||||
// This file was generated by ODB, object-relational mapping (ORM)
|
||||
// compiler for C++.
|
||||
//
|
||||
|
||||
#ifndef TRIP_ATTEMPT_RESULT_ODB_HXX
|
||||
#define TRIP_ATTEMPT_RESULT_ODB_HXX
|
||||
|
||||
#include <odb/version.hxx>
|
||||
|
||||
#if (ODB_VERSION != 20400UL)
|
||||
#error ODB runtime version mismatch
|
||||
#endif
|
||||
|
||||
#include <odb/pre.hxx>
|
||||
|
||||
#include "TripAttemptResult.h"
|
||||
|
||||
#include <memory>
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
#include <odb/core.hxx>
|
||||
#include <odb/traits.hxx>
|
||||
#include <odb/callback.hxx>
|
||||
#include <odb/wrapper-traits.hxx>
|
||||
#include <odb/pointer-traits.hxx>
|
||||
#include <odb/container-traits.hxx>
|
||||
#include <odb/no-op-cache-traits.hxx>
|
||||
#include <odb/result.hxx>
|
||||
#include <odb/simple-object-result.hxx>
|
||||
|
||||
#include <odb/details/unused.hxx>
|
||||
#include <odb/details/shared-ptr.hxx>
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// TripAttemptResult
|
||||
//
|
||||
template <>
|
||||
struct class_traits< ::models::TripAttemptResult >
|
||||
{
|
||||
static const class_kind kind = class_object;
|
||||
};
|
||||
|
||||
template <>
|
||||
class access::object_traits< ::models::TripAttemptResult >
|
||||
{
|
||||
public:
|
||||
typedef ::models::TripAttemptResult object_type;
|
||||
typedef ::models::TripAttemptResult* pointer_type;
|
||||
typedef odb::pointer_traits<pointer_type> pointer_traits;
|
||||
|
||||
static const bool polymorphic = false;
|
||||
|
||||
typedef ::std::string id_type;
|
||||
|
||||
static const bool auto_id = false;
|
||||
|
||||
static const bool abstract = false;
|
||||
|
||||
static id_type
|
||||
id (const object_type&);
|
||||
|
||||
typedef
|
||||
no_op_pointer_cache_traits<pointer_type>
|
||||
pointer_cache_traits;
|
||||
|
||||
typedef
|
||||
no_op_reference_cache_traits<object_type>
|
||||
reference_cache_traits;
|
||||
|
||||
static void
|
||||
callback (database&, object_type&, callback_event);
|
||||
|
||||
static void
|
||||
callback (database&, const object_type&, callback_event);
|
||||
};
|
||||
}
|
||||
|
||||
#include <odb/details/buffer.hxx>
|
||||
|
||||
#include <odb/sqlite/version.hxx>
|
||||
#include <odb/sqlite/forward.hxx>
|
||||
#include <odb/sqlite/binding.hxx>
|
||||
#include <odb/sqlite/sqlite-types.hxx>
|
||||
#include <odb/sqlite/query.hxx>
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// TripAttemptResult
|
||||
//
|
||||
template <typename A>
|
||||
struct query_columns< ::models::TripAttemptResult, id_sqlite, A >
|
||||
{
|
||||
// id
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
id_type_;
|
||||
|
||||
static const id_type_ id;
|
||||
|
||||
// result
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
result_type_;
|
||||
|
||||
static const result_type_ result;
|
||||
|
||||
// retryReason
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
retryReason_type_;
|
||||
|
||||
static const retryReason_type_ retryReason;
|
||||
|
||||
// governmentSuspensionReason
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
governmentSuspensionReason_type_;
|
||||
|
||||
static const governmentSuspensionReason_type_ governmentSuspensionReason;
|
||||
|
||||
// governmentTerminationReason
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
governmentTerminationReason_type_;
|
||||
|
||||
static const governmentTerminationReason_type_ governmentTerminationReason;
|
||||
|
||||
// complianceSuspensionReason
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
complianceSuspensionReason_type_;
|
||||
|
||||
static const complianceSuspensionReason_type_ complianceSuspensionReason;
|
||||
|
||||
// complianceTerminationReason
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
complianceTerminationReason_type_;
|
||||
|
||||
static const complianceTerminationReason_type_ complianceTerminationReason;
|
||||
|
||||
// policySuspensionReason
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
policySuspensionReason_type_;
|
||||
|
||||
static const policySuspensionReason_type_ policySuspensionReason;
|
||||
|
||||
// policyTerminationReason
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
policyTerminationReason_type_;
|
||||
|
||||
static const policyTerminationReason_type_ policyTerminationReason;
|
||||
|
||||
// cancelationReason
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
cancelationReason_type_;
|
||||
|
||||
static const cancelationReason_type_ cancelationReason;
|
||||
|
||||
// failureReason
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
failureReason_type_;
|
||||
|
||||
static const failureReason_type_ failureReason;
|
||||
|
||||
// details
|
||||
//
|
||||
typedef
|
||||
sqlite::query_column<
|
||||
sqlite::value_traits<
|
||||
::std::string,
|
||||
sqlite::id_text >::query_type,
|
||||
sqlite::id_text >
|
||||
details_type_;
|
||||
|
||||
static const details_type_ details;
|
||||
};
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_sqlite, A >::id_type_
|
||||
query_columns< ::models::TripAttemptResult, id_sqlite, A >::
|
||||
id (A::table_name, "\"id\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_sqlite, A >::result_type_
|
||||
query_columns< ::models::TripAttemptResult, id_sqlite, A >::
|
||||
result (A::table_name, "\"result\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_sqlite, A >::retryReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_sqlite, A >::
|
||||
retryReason (A::table_name, "\"retryReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_sqlite, A >::governmentSuspensionReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_sqlite, A >::
|
||||
governmentSuspensionReason (A::table_name, "\"governmentSuspensionReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_sqlite, A >::governmentTerminationReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_sqlite, A >::
|
||||
governmentTerminationReason (A::table_name, "\"governmentTerminationReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_sqlite, A >::complianceSuspensionReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_sqlite, A >::
|
||||
complianceSuspensionReason (A::table_name, "\"complianceSuspensionReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_sqlite, A >::complianceTerminationReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_sqlite, A >::
|
||||
complianceTerminationReason (A::table_name, "\"complianceTerminationReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_sqlite, A >::policySuspensionReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_sqlite, A >::
|
||||
policySuspensionReason (A::table_name, "\"policySuspensionReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_sqlite, A >::policyTerminationReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_sqlite, A >::
|
||||
policyTerminationReason (A::table_name, "\"policyTerminationReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_sqlite, A >::cancelationReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_sqlite, A >::
|
||||
cancelationReason (A::table_name, "\"cancelationReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_sqlite, A >::failureReason_type_
|
||||
query_columns< ::models::TripAttemptResult, id_sqlite, A >::
|
||||
failureReason (A::table_name, "\"failureReason\"", 0);
|
||||
|
||||
template <typename A>
|
||||
const typename query_columns< ::models::TripAttemptResult, id_sqlite, A >::details_type_
|
||||
query_columns< ::models::TripAttemptResult, id_sqlite, A >::
|
||||
details (A::table_name, "\"details\"", 0);
|
||||
|
||||
template <typename A>
|
||||
struct pointer_query_columns< ::models::TripAttemptResult, id_sqlite, A >:
|
||||
query_columns< ::models::TripAttemptResult, id_sqlite, A >
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
class access::object_traits_impl< ::models::TripAttemptResult, id_sqlite >:
|
||||
public access::object_traits< ::models::TripAttemptResult >
|
||||
{
|
||||
public:
|
||||
struct id_image_type
|
||||
{
|
||||
details::buffer id_value;
|
||||
std::size_t id_size;
|
||||
bool id_null;
|
||||
|
||||
std::size_t version;
|
||||
};
|
||||
|
||||
struct image_type
|
||||
{
|
||||
// id
|
||||
//
|
||||
details::buffer id_value;
|
||||
std::size_t id_size;
|
||||
bool id_null;
|
||||
|
||||
// result
|
||||
//
|
||||
details::buffer result_value;
|
||||
std::size_t result_size;
|
||||
bool result_null;
|
||||
|
||||
// retryReason
|
||||
//
|
||||
details::buffer retryReason_value;
|
||||
std::size_t retryReason_size;
|
||||
bool retryReason_null;
|
||||
|
||||
// governmentSuspensionReason
|
||||
//
|
||||
details::buffer governmentSuspensionReason_value;
|
||||
std::size_t governmentSuspensionReason_size;
|
||||
bool governmentSuspensionReason_null;
|
||||
|
||||
// governmentTerminationReason
|
||||
//
|
||||
details::buffer governmentTerminationReason_value;
|
||||
std::size_t governmentTerminationReason_size;
|
||||
bool governmentTerminationReason_null;
|
||||
|
||||
// complianceSuspensionReason
|
||||
//
|
||||
details::buffer complianceSuspensionReason_value;
|
||||
std::size_t complianceSuspensionReason_size;
|
||||
bool complianceSuspensionReason_null;
|
||||
|
||||
// complianceTerminationReason
|
||||
//
|
||||
details::buffer complianceTerminationReason_value;
|
||||
std::size_t complianceTerminationReason_size;
|
||||
bool complianceTerminationReason_null;
|
||||
|
||||
// policySuspensionReason
|
||||
//
|
||||
details::buffer policySuspensionReason_value;
|
||||
std::size_t policySuspensionReason_size;
|
||||
bool policySuspensionReason_null;
|
||||
|
||||
// policyTerminationReason
|
||||
//
|
||||
details::buffer policyTerminationReason_value;
|
||||
std::size_t policyTerminationReason_size;
|
||||
bool policyTerminationReason_null;
|
||||
|
||||
// cancelationReason
|
||||
//
|
||||
details::buffer cancelationReason_value;
|
||||
std::size_t cancelationReason_size;
|
||||
bool cancelationReason_null;
|
||||
|
||||
// failureReason
|
||||
//
|
||||
details::buffer failureReason_value;
|
||||
std::size_t failureReason_size;
|
||||
bool failureReason_null;
|
||||
|
||||
// details
|
||||
//
|
||||
details::buffer details_value;
|
||||
std::size_t details_size;
|
||||
bool details_null;
|
||||
|
||||
std::size_t version;
|
||||
};
|
||||
|
||||
struct extra_statement_cache_type;
|
||||
|
||||
using object_traits<object_type>::id;
|
||||
|
||||
static id_type
|
||||
id (const image_type&);
|
||||
|
||||
static bool
|
||||
grow (image_type&,
|
||||
bool*);
|
||||
|
||||
static void
|
||||
bind (sqlite::bind*,
|
||||
image_type&,
|
||||
sqlite::statement_kind);
|
||||
|
||||
static void
|
||||
bind (sqlite::bind*, id_image_type&);
|
||||
|
||||
static bool
|
||||
init (image_type&,
|
||||
const object_type&,
|
||||
sqlite::statement_kind);
|
||||
|
||||
static void
|
||||
init (object_type&,
|
||||
const image_type&,
|
||||
database*);
|
||||
|
||||
static void
|
||||
init (id_image_type&, const id_type&);
|
||||
|
||||
typedef sqlite::object_statements<object_type> statements_type;
|
||||
|
||||
typedef sqlite::query_base query_base_type;
|
||||
|
||||
static const std::size_t column_count = 12UL;
|
||||
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 const char query_statement[];
|
||||
static const char erase_query_statement[];
|
||||
|
||||
static const char table_name[];
|
||||
|
||||
static void
|
||||
persist (database&, const 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&);
|
||||
|
||||
static result<object_type>
|
||||
query (database&, const query_base_type&);
|
||||
|
||||
static unsigned long long
|
||||
erase_query (database&, const query_base_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< ::models::TripAttemptResult, id_common >:
|
||||
public access::object_traits_impl< ::models::TripAttemptResult, id_sqlite >
|
||||
{
|
||||
};
|
||||
|
||||
// TripAttemptResult
|
||||
//
|
||||
}
|
||||
|
||||
#include "TripAttemptResult-odb.ixx"
|
||||
|
||||
#include <odb/post.hxx>
|
||||
|
||||
#endif // TRIP_ATTEMPT_RESULT_ODB_HXX
|
||||
@@ -0,0 +1,61 @@
|
||||
// This file was generated by ODB, object-relational mapping (ORM)
|
||||
// compiler for C++.
|
||||
//
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// TripAttemptResult
|
||||
//
|
||||
|
||||
inline
|
||||
access::object_traits< ::models::TripAttemptResult >::id_type
|
||||
access::object_traits< ::models::TripAttemptResult >::
|
||||
id (const object_type& o)
|
||||
{
|
||||
return o.id;
|
||||
}
|
||||
|
||||
inline
|
||||
void access::object_traits< ::models::TripAttemptResult >::
|
||||
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< ::models::TripAttemptResult >::
|
||||
callback (database& db, const object_type& x, callback_event e)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (db);
|
||||
ODB_POTENTIALLY_UNUSED (x);
|
||||
ODB_POTENTIALLY_UNUSED (e);
|
||||
}
|
||||
}
|
||||
|
||||
namespace odb
|
||||
{
|
||||
// TripAttemptResult
|
||||
//
|
||||
|
||||
inline
|
||||
void access::object_traits_impl< ::models::TripAttemptResult, id_sqlite >::
|
||||
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< ::models::TripAttemptResult, id_sqlite >::
|
||||
load_ (statements_type& sts,
|
||||
object_type& obj,
|
||||
bool)
|
||||
{
|
||||
ODB_POTENTIALLY_UNUSED (sts);
|
||||
ODB_POTENTIALLY_UNUSED (obj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/* This file was generated by ODB, object-relational mapping (ORM)
|
||||
* compiler for C++.
|
||||
*/
|
||||
|
||||
DROP TABLE IF EXISTS "TripAttemptResult";
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "schema_version" (
|
||||
"name" TEXT NOT NULL PRIMARY KEY,
|
||||
"version" INTEGER NOT NULL,
|
||||
"migration" INTEGER NOT NULL);
|
||||
|
||||
DELETE FROM "schema_version"
|
||||
WHERE "name" = '';
|
||||
|
||||
CREATE TABLE "TripAttemptResult" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"result" TEXT NOT NULL,
|
||||
"retryReason" TEXT NOT NULL,
|
||||
"governmentSuspensionReason" TEXT NOT NULL,
|
||||
"governmentTerminationReason" TEXT NOT NULL,
|
||||
"complianceSuspensionReason" TEXT NOT NULL,
|
||||
"complianceTerminationReason" TEXT NOT NULL,
|
||||
"policySuspensionReason" TEXT NOT NULL,
|
||||
"policyTerminationReason" TEXT NOT NULL,
|
||||
"cancelationReason" TEXT NOT NULL,
|
||||
"failureReason" TEXT NOT NULL,
|
||||
"details" TEXT NOT NULL);
|
||||
|
||||
INSERT OR IGNORE INTO "schema_version" (
|
||||
"name", "version", "migration")
|
||||
VALUES ('', 2, 0);
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# OpenAPI Generator Ignore
|
||||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
||||
|
||||
# Use this file to prevent files from being overwritten by the generator.
|
||||
# The patterns follow closely to .gitignore or .dockerignore.
|
||||
|
||||
# As an example, the C# client generator defines ApiClient.cs.
|
||||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
||||
@@ -0,0 +1,10 @@
|
||||
.openapi-generator-ignore
|
||||
docs/Agent.md
|
||||
docs/GovernmentAddress.md
|
||||
docs/TripAttemptResult.md
|
||||
index.ts
|
||||
models/Agent.ts
|
||||
models/GovernmentAddress.ts
|
||||
models/TripAttemptResult.ts
|
||||
models/index.ts
|
||||
runtime.ts
|
||||
@@ -0,0 +1 @@
|
||||
7.20.0
|
||||
42
db/test-schema-v1.2/generated-ts-types/docs/Agent.md
Normal file
42
db/test-schema-v1.2/generated-ts-types/docs/Agent.md
Normal file
@@ -0,0 +1,42 @@
|
||||
|
||||
# Agent
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type
|
||||
------------ | -------------
|
||||
`id` | string
|
||||
`role` | string
|
||||
`persistent` | boolean
|
||||
`displayName` | string
|
||||
`trustScore` | number
|
||||
|
||||
## Example
|
||||
|
||||
```typescript
|
||||
import type { Agent } from ''
|
||||
|
||||
// TODO: Update the object below with actual values
|
||||
const example = {
|
||||
"id": null,
|
||||
"role": null,
|
||||
"persistent": null,
|
||||
"displayName": null,
|
||||
"trustScore": null,
|
||||
} satisfies Agent
|
||||
|
||||
console.log(example)
|
||||
|
||||
// Convert the instance to a JSON string
|
||||
const exampleJSON: string = JSON.stringify(example)
|
||||
console.log(exampleJSON)
|
||||
|
||||
// Parse the JSON string back to an object
|
||||
const exampleParsed = JSON.parse(exampleJSON) as Agent
|
||||
console.log(exampleParsed)
|
||||
```
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
|
||||
# GovernmentAddress
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type
|
||||
------------ | -------------
|
||||
`id` | string
|
||||
`addressLabel` | string
|
||||
`regionLookupKey` | string
|
||||
|
||||
## Example
|
||||
|
||||
```typescript
|
||||
import type { GovernmentAddress } from ''
|
||||
|
||||
// TODO: Update the object below with actual values
|
||||
const example = {
|
||||
"id": null,
|
||||
"addressLabel": null,
|
||||
"regionLookupKey": null,
|
||||
} satisfies GovernmentAddress
|
||||
|
||||
console.log(example)
|
||||
|
||||
// Convert the instance to a JSON string
|
||||
const exampleJSON: string = JSON.stringify(example)
|
||||
console.log(exampleJSON)
|
||||
|
||||
// Parse the JSON string back to an object
|
||||
const exampleParsed = JSON.parse(exampleJSON) as GovernmentAddress
|
||||
console.log(exampleParsed)
|
||||
```
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
|
||||
# TripAttemptResult
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type
|
||||
------------ | -------------
|
||||
`id` | string
|
||||
`result` | string
|
||||
`retryReason` | string
|
||||
`governmentSuspensionReason` | string
|
||||
`governmentTerminationReason` | string
|
||||
`complianceSuspensionReason` | string
|
||||
`complianceTerminationReason` | string
|
||||
`policySuspensionReason` | string
|
||||
`policyTerminationReason` | string
|
||||
`cancelationReason` | string
|
||||
`failureReason` | string
|
||||
`details` | string
|
||||
|
||||
## Example
|
||||
|
||||
```typescript
|
||||
import type { TripAttemptResult } from ''
|
||||
|
||||
// TODO: Update the object below with actual values
|
||||
const example = {
|
||||
"id": null,
|
||||
"result": null,
|
||||
"retryReason": null,
|
||||
"governmentSuspensionReason": null,
|
||||
"governmentTerminationReason": null,
|
||||
"complianceSuspensionReason": null,
|
||||
"complianceTerminationReason": null,
|
||||
"policySuspensionReason": null,
|
||||
"policyTerminationReason": null,
|
||||
"cancelationReason": null,
|
||||
"failureReason": null,
|
||||
"details": null,
|
||||
} satisfies TripAttemptResult
|
||||
|
||||
console.log(example)
|
||||
|
||||
// Convert the instance to a JSON string
|
||||
const exampleJSON: string = JSON.stringify(example)
|
||||
console.log(exampleJSON)
|
||||
|
||||
// Parse the JSON string back to an object
|
||||
const exampleParsed = JSON.parse(exampleJSON) as TripAttemptResult
|
||||
console.log(exampleParsed)
|
||||
```
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
4
db/test-schema-v1.2/generated-ts-types/index.ts
Normal file
4
db/test-schema-v1.2/generated-ts-types/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export * from './runtime';
|
||||
export * from './models/index';
|
||||
100
db/test-schema-v1.2/generated-ts-types/models/Agent.ts
Normal file
100
db/test-schema-v1.2/generated-ts-types/models/Agent.ts
Normal file
@@ -0,0 +1,100 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* cppbessot-test-schema-v1.2
|
||||
* Self-contained additive test fixture for cppbessot serdes and migration validation.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.2.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
import { mapValues } from '../runtime';
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
* @interface Agent
|
||||
*/
|
||||
export interface Agent {
|
||||
/**
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Agent
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Agent
|
||||
*/
|
||||
role: string;
|
||||
/**
|
||||
*
|
||||
* @type {boolean}
|
||||
* @memberof Agent
|
||||
*/
|
||||
persistent: boolean;
|
||||
/**
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Agent
|
||||
*/
|
||||
displayName?: string;
|
||||
/**
|
||||
*
|
||||
* @type {number}
|
||||
* @memberof Agent
|
||||
*/
|
||||
trustScore?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given object implements the Agent interface.
|
||||
*/
|
||||
export function instanceOfAgent(value: object): value is Agent {
|
||||
if (!('id' in value) || value['id'] === undefined) return false;
|
||||
if (!('role' in value) || value['role'] === undefined) return false;
|
||||
if (!('persistent' in value) || value['persistent'] === undefined) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
export function AgentFromJSON(json: any): Agent {
|
||||
return AgentFromJSONTyped(json, false);
|
||||
}
|
||||
|
||||
export function AgentFromJSONTyped(json: any, ignoreDiscriminator: boolean): Agent {
|
||||
if (json == null) {
|
||||
return json;
|
||||
}
|
||||
return {
|
||||
|
||||
'id': json['id'],
|
||||
'role': json['role'],
|
||||
'persistent': json['persistent'],
|
||||
'displayName': json['displayName'] == null ? undefined : json['displayName'],
|
||||
'trustScore': json['trustScore'] == null ? undefined : json['trustScore'],
|
||||
};
|
||||
}
|
||||
|
||||
export function AgentToJSON(json: any): Agent {
|
||||
return AgentToJSONTyped(json, false);
|
||||
}
|
||||
|
||||
export function AgentToJSONTyped(value?: Agent | null, ignoreDiscriminator: boolean = false): any {
|
||||
if (value == null) {
|
||||
return value;
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
'id': value['id'],
|
||||
'role': value['role'],
|
||||
'persistent': value['persistent'],
|
||||
'displayName': value['displayName'],
|
||||
'trustScore': value['trustScore'],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* cppbessot-test-schema-v1.2
|
||||
* Self-contained additive test fixture for cppbessot serdes and migration validation.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.2.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
import { mapValues } from '../runtime';
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
* @interface GovernmentAddress
|
||||
*/
|
||||
export interface GovernmentAddress {
|
||||
/**
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof GovernmentAddress
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof GovernmentAddress
|
||||
*/
|
||||
addressLabel?: string;
|
||||
/**
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof GovernmentAddress
|
||||
*/
|
||||
regionLookupKey?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given object implements the GovernmentAddress interface.
|
||||
*/
|
||||
export function instanceOfGovernmentAddress(value: object): value is GovernmentAddress {
|
||||
if (!('id' in value) || value['id'] === undefined) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
export function GovernmentAddressFromJSON(json: any): GovernmentAddress {
|
||||
return GovernmentAddressFromJSONTyped(json, false);
|
||||
}
|
||||
|
||||
export function GovernmentAddressFromJSONTyped(json: any, ignoreDiscriminator: boolean): GovernmentAddress {
|
||||
if (json == null) {
|
||||
return json;
|
||||
}
|
||||
return {
|
||||
|
||||
'id': json['id'],
|
||||
'addressLabel': json['addressLabel'] == null ? undefined : json['addressLabel'],
|
||||
'regionLookupKey': json['regionLookupKey'] == null ? undefined : json['regionLookupKey'],
|
||||
};
|
||||
}
|
||||
|
||||
export function GovernmentAddressToJSON(json: any): GovernmentAddress {
|
||||
return GovernmentAddressToJSONTyped(json, false);
|
||||
}
|
||||
|
||||
export function GovernmentAddressToJSONTyped(value?: GovernmentAddress | null, ignoreDiscriminator: boolean = false): any {
|
||||
if (value == null) {
|
||||
return value;
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
'id': value['id'],
|
||||
'addressLabel': value['addressLabel'],
|
||||
'regionLookupKey': value['regionLookupKey'],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* cppbessot-test-schema-v1.2
|
||||
* Self-contained additive test fixture for cppbessot serdes and migration validation.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.2.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
import { mapValues } from '../runtime';
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
* @interface TripAttemptResult
|
||||
*/
|
||||
export interface TripAttemptResult {
|
||||
/**
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof TripAttemptResult
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof TripAttemptResult
|
||||
*/
|
||||
result: string;
|
||||
/**
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof TripAttemptResult
|
||||
*/
|
||||
retryReason?: string;
|
||||
/**
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof TripAttemptResult
|
||||
*/
|
||||
governmentSuspensionReason?: string;
|
||||
/**
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof TripAttemptResult
|
||||
*/
|
||||
governmentTerminationReason?: string;
|
||||
/**
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof TripAttemptResult
|
||||
*/
|
||||
complianceSuspensionReason?: string;
|
||||
/**
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof TripAttemptResult
|
||||
*/
|
||||
complianceTerminationReason?: string;
|
||||
/**
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof TripAttemptResult
|
||||
*/
|
||||
policySuspensionReason?: string;
|
||||
/**
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof TripAttemptResult
|
||||
*/
|
||||
policyTerminationReason?: string;
|
||||
/**
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof TripAttemptResult
|
||||
*/
|
||||
cancelationReason?: string;
|
||||
/**
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof TripAttemptResult
|
||||
*/
|
||||
failureReason?: string;
|
||||
/**
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof TripAttemptResult
|
||||
*/
|
||||
details?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given object implements the TripAttemptResult interface.
|
||||
*/
|
||||
export function instanceOfTripAttemptResult(value: object): value is TripAttemptResult {
|
||||
if (!('id' in value) || value['id'] === undefined) return false;
|
||||
if (!('result' in value) || value['result'] === undefined) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
export function TripAttemptResultFromJSON(json: any): TripAttemptResult {
|
||||
return TripAttemptResultFromJSONTyped(json, false);
|
||||
}
|
||||
|
||||
export function TripAttemptResultFromJSONTyped(json: any, ignoreDiscriminator: boolean): TripAttemptResult {
|
||||
if (json == null) {
|
||||
return json;
|
||||
}
|
||||
return {
|
||||
|
||||
'id': json['id'],
|
||||
'result': json['result'],
|
||||
'retryReason': json['retryReason'] == null ? undefined : json['retryReason'],
|
||||
'governmentSuspensionReason': json['governmentSuspensionReason'] == null ? undefined : json['governmentSuspensionReason'],
|
||||
'governmentTerminationReason': json['governmentTerminationReason'] == null ? undefined : json['governmentTerminationReason'],
|
||||
'complianceSuspensionReason': json['complianceSuspensionReason'] == null ? undefined : json['complianceSuspensionReason'],
|
||||
'complianceTerminationReason': json['complianceTerminationReason'] == null ? undefined : json['complianceTerminationReason'],
|
||||
'policySuspensionReason': json['policySuspensionReason'] == null ? undefined : json['policySuspensionReason'],
|
||||
'policyTerminationReason': json['policyTerminationReason'] == null ? undefined : json['policyTerminationReason'],
|
||||
'cancelationReason': json['cancelationReason'] == null ? undefined : json['cancelationReason'],
|
||||
'failureReason': json['failureReason'] == null ? undefined : json['failureReason'],
|
||||
'details': json['details'] == null ? undefined : json['details'],
|
||||
};
|
||||
}
|
||||
|
||||
export function TripAttemptResultToJSON(json: any): TripAttemptResult {
|
||||
return TripAttemptResultToJSONTyped(json, false);
|
||||
}
|
||||
|
||||
export function TripAttemptResultToJSONTyped(value?: TripAttemptResult | null, ignoreDiscriminator: boolean = false): any {
|
||||
if (value == null) {
|
||||
return value;
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
'id': value['id'],
|
||||
'result': value['result'],
|
||||
'retryReason': value['retryReason'],
|
||||
'governmentSuspensionReason': value['governmentSuspensionReason'],
|
||||
'governmentTerminationReason': value['governmentTerminationReason'],
|
||||
'complianceSuspensionReason': value['complianceSuspensionReason'],
|
||||
'complianceTerminationReason': value['complianceTerminationReason'],
|
||||
'policySuspensionReason': value['policySuspensionReason'],
|
||||
'policyTerminationReason': value['policyTerminationReason'],
|
||||
'cancelationReason': value['cancelationReason'],
|
||||
'failureReason': value['failureReason'],
|
||||
'details': value['details'],
|
||||
};
|
||||
}
|
||||
|
||||
5
db/test-schema-v1.2/generated-ts-types/models/index.ts
Normal file
5
db/test-schema-v1.2/generated-ts-types/models/index.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export * from './Agent';
|
||||
export * from './GovernmentAddress';
|
||||
export * from './TripAttemptResult';
|
||||
432
db/test-schema-v1.2/generated-ts-types/runtime.ts
Normal file
432
db/test-schema-v1.2/generated-ts-types/runtime.ts
Normal file
@@ -0,0 +1,432 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* cppbessot-test-schema-v1.2
|
||||
* Self-contained additive test fixture for cppbessot serdes and migration validation.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.2.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export const BASE_PATH = "http://localhost".replace(/\/+$/, "");
|
||||
|
||||
export interface ConfigurationParameters {
|
||||
basePath?: string; // override base path
|
||||
fetchApi?: FetchAPI; // override for fetch implementation
|
||||
middleware?: Middleware[]; // middleware to apply before/after fetch requests
|
||||
queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings
|
||||
username?: string; // parameter for basic security
|
||||
password?: string; // parameter for basic security
|
||||
apiKey?: string | Promise<string> | ((name: string) => string | Promise<string>); // parameter for apiKey security
|
||||
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string | Promise<string>); // parameter for oauth2 security
|
||||
headers?: HTTPHeaders; //header params we want to use on every request
|
||||
credentials?: RequestCredentials; //value for the credentials param we want to use on each request
|
||||
}
|
||||
|
||||
export class Configuration {
|
||||
constructor(private configuration: ConfigurationParameters = {}) {}
|
||||
|
||||
set config(configuration: Configuration) {
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
get basePath(): string {
|
||||
return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
|
||||
}
|
||||
|
||||
get fetchApi(): FetchAPI | undefined {
|
||||
return this.configuration.fetchApi;
|
||||
}
|
||||
|
||||
get middleware(): Middleware[] {
|
||||
return this.configuration.middleware || [];
|
||||
}
|
||||
|
||||
get queryParamsStringify(): (params: HTTPQuery) => string {
|
||||
return this.configuration.queryParamsStringify || querystring;
|
||||
}
|
||||
|
||||
get username(): string | undefined {
|
||||
return this.configuration.username;
|
||||
}
|
||||
|
||||
get password(): string | undefined {
|
||||
return this.configuration.password;
|
||||
}
|
||||
|
||||
get apiKey(): ((name: string) => string | Promise<string>) | undefined {
|
||||
const apiKey = this.configuration.apiKey;
|
||||
if (apiKey) {
|
||||
return typeof apiKey === 'function' ? apiKey : () => apiKey;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
get accessToken(): ((name?: string, scopes?: string[]) => string | Promise<string>) | undefined {
|
||||
const accessToken = this.configuration.accessToken;
|
||||
if (accessToken) {
|
||||
return typeof accessToken === 'function' ? accessToken : async () => accessToken;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
get headers(): HTTPHeaders | undefined {
|
||||
return this.configuration.headers;
|
||||
}
|
||||
|
||||
get credentials(): RequestCredentials | undefined {
|
||||
return this.configuration.credentials;
|
||||
}
|
||||
}
|
||||
|
||||
export const DefaultConfig = new Configuration();
|
||||
|
||||
/**
|
||||
* This is the base class for all generated API classes.
|
||||
*/
|
||||
export class BaseAPI {
|
||||
|
||||
private static readonly jsonRegex = new RegExp('^(:?application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i');
|
||||
private middleware: Middleware[];
|
||||
|
||||
constructor(protected configuration = DefaultConfig) {
|
||||
this.middleware = configuration.middleware;
|
||||
}
|
||||
|
||||
withMiddleware<T extends BaseAPI>(this: T, ...middlewares: Middleware[]) {
|
||||
const next = this.clone<T>();
|
||||
next.middleware = next.middleware.concat(...middlewares);
|
||||
return next;
|
||||
}
|
||||
|
||||
withPreMiddleware<T extends BaseAPI>(this: T, ...preMiddlewares: Array<Middleware['pre']>) {
|
||||
const middlewares = preMiddlewares.map((pre) => ({ pre }));
|
||||
return this.withMiddleware<T>(...middlewares);
|
||||
}
|
||||
|
||||
withPostMiddleware<T extends BaseAPI>(this: T, ...postMiddlewares: Array<Middleware['post']>) {
|
||||
const middlewares = postMiddlewares.map((post) => ({ post }));
|
||||
return this.withMiddleware<T>(...middlewares);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given MIME is a JSON MIME.
|
||||
* JSON MIME examples:
|
||||
* application/json
|
||||
* application/json; charset=UTF8
|
||||
* APPLICATION/JSON
|
||||
* application/vnd.company+json
|
||||
* @param mime - MIME (Multipurpose Internet Mail Extensions)
|
||||
* @return True if the given MIME is JSON, false otherwise.
|
||||
*/
|
||||
protected isJsonMime(mime: string | null | undefined): boolean {
|
||||
if (!mime) {
|
||||
return false;
|
||||
}
|
||||
return BaseAPI.jsonRegex.test(mime);
|
||||
}
|
||||
|
||||
protected async request(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction): Promise<Response> {
|
||||
const { url, init } = await this.createFetchParams(context, initOverrides);
|
||||
const response = await this.fetchApi(url, init);
|
||||
if (response && (response.status >= 200 && response.status < 300)) {
|
||||
return response;
|
||||
}
|
||||
throw new ResponseError(response, 'Response returned an error code');
|
||||
}
|
||||
|
||||
private async createFetchParams(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction) {
|
||||
let url = this.configuration.basePath + context.path;
|
||||
if (context.query !== undefined && Object.keys(context.query).length !== 0) {
|
||||
// only add the querystring to the URL if there are query parameters.
|
||||
// this is done to avoid urls ending with a "?" character which buggy webservers
|
||||
// do not handle correctly sometimes.
|
||||
url += '?' + this.configuration.queryParamsStringify(context.query);
|
||||
}
|
||||
|
||||
const headers = Object.assign({}, this.configuration.headers, context.headers);
|
||||
Object.keys(headers).forEach(key => headers[key] === undefined ? delete headers[key] : {});
|
||||
|
||||
const initOverrideFn =
|
||||
typeof initOverrides === "function"
|
||||
? initOverrides
|
||||
: async () => initOverrides;
|
||||
|
||||
const initParams = {
|
||||
method: context.method,
|
||||
headers,
|
||||
body: context.body,
|
||||
credentials: this.configuration.credentials,
|
||||
};
|
||||
|
||||
const overriddenInit: RequestInit = {
|
||||
...initParams,
|
||||
...(await initOverrideFn({
|
||||
init: initParams,
|
||||
context,
|
||||
}))
|
||||
};
|
||||
|
||||
let body: any;
|
||||
if (isFormData(overriddenInit.body)
|
||||
|| (overriddenInit.body instanceof URLSearchParams)
|
||||
|| isBlob(overriddenInit.body)) {
|
||||
body = overriddenInit.body;
|
||||
} else if (this.isJsonMime(headers['Content-Type'])) {
|
||||
body = JSON.stringify(overriddenInit.body);
|
||||
} else {
|
||||
body = overriddenInit.body;
|
||||
}
|
||||
|
||||
const init: RequestInit = {
|
||||
...overriddenInit,
|
||||
body
|
||||
};
|
||||
|
||||
return { url, init };
|
||||
}
|
||||
|
||||
private fetchApi = async (url: string, init: RequestInit) => {
|
||||
let fetchParams = { url, init };
|
||||
for (const middleware of this.middleware) {
|
||||
if (middleware.pre) {
|
||||
fetchParams = await middleware.pre({
|
||||
fetch: this.fetchApi,
|
||||
...fetchParams,
|
||||
}) || fetchParams;
|
||||
}
|
||||
}
|
||||
let response: Response | undefined = undefined;
|
||||
try {
|
||||
response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
|
||||
} catch (e) {
|
||||
for (const middleware of this.middleware) {
|
||||
if (middleware.onError) {
|
||||
response = await middleware.onError({
|
||||
fetch: this.fetchApi,
|
||||
url: fetchParams.url,
|
||||
init: fetchParams.init,
|
||||
error: e,
|
||||
response: response ? response.clone() : undefined,
|
||||
}) || response;
|
||||
}
|
||||
}
|
||||
if (response === undefined) {
|
||||
if (e instanceof Error) {
|
||||
throw new FetchError(e, 'The request failed and the interceptors did not return an alternative response');
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const middleware of this.middleware) {
|
||||
if (middleware.post) {
|
||||
response = await middleware.post({
|
||||
fetch: this.fetchApi,
|
||||
url: fetchParams.url,
|
||||
init: fetchParams.init,
|
||||
response: response.clone(),
|
||||
}) || response;
|
||||
}
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a shallow clone of `this` by constructing a new instance
|
||||
* and then shallow cloning data members.
|
||||
*/
|
||||
private clone<T extends BaseAPI>(this: T): T {
|
||||
const constructor = this.constructor as any;
|
||||
const next = new constructor(this.configuration);
|
||||
next.middleware = this.middleware.slice();
|
||||
return next;
|
||||
}
|
||||
};
|
||||
|
||||
function isBlob(value: any): value is Blob {
|
||||
return typeof Blob !== 'undefined' && value instanceof Blob;
|
||||
}
|
||||
|
||||
function isFormData(value: any): value is FormData {
|
||||
return typeof FormData !== "undefined" && value instanceof FormData;
|
||||
}
|
||||
|
||||
export class ResponseError extends Error {
|
||||
override name: "ResponseError" = "ResponseError";
|
||||
constructor(public response: Response, msg?: string) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
|
||||
export class FetchError extends Error {
|
||||
override name: "FetchError" = "FetchError";
|
||||
constructor(public cause: Error, msg?: string) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
|
||||
export class RequiredError extends Error {
|
||||
override name: "RequiredError" = "RequiredError";
|
||||
constructor(public field: string, msg?: string) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
|
||||
export const COLLECTION_FORMATS = {
|
||||
csv: ",",
|
||||
ssv: " ",
|
||||
tsv: "\t",
|
||||
pipes: "|",
|
||||
};
|
||||
|
||||
export type FetchAPI = WindowOrWorkerGlobalScope['fetch'];
|
||||
|
||||
export type Json = any;
|
||||
export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD';
|
||||
export type HTTPHeaders = { [key: string]: string };
|
||||
export type HTTPQuery = { [key: string]: string | number | null | boolean | Array<string | number | null | boolean> | Set<string | number | null | boolean> | HTTPQuery };
|
||||
export type HTTPBody = Json | FormData | URLSearchParams;
|
||||
export type HTTPRequestInit = { headers?: HTTPHeaders; method: HTTPMethod; credentials?: RequestCredentials; body?: HTTPBody };
|
||||
export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original';
|
||||
|
||||
export type InitOverrideFunction = (requestContext: { init: HTTPRequestInit, context: RequestOpts }) => Promise<RequestInit>
|
||||
|
||||
export interface FetchParams {
|
||||
url: string;
|
||||
init: RequestInit;
|
||||
}
|
||||
|
||||
export interface RequestOpts {
|
||||
path: string;
|
||||
method: HTTPMethod;
|
||||
headers: HTTPHeaders;
|
||||
query?: HTTPQuery;
|
||||
body?: HTTPBody;
|
||||
}
|
||||
|
||||
export function querystring(params: HTTPQuery, prefix: string = ''): string {
|
||||
return Object.keys(params)
|
||||
.map(key => querystringSingleKey(key, params[key], prefix))
|
||||
.filter(part => part.length > 0)
|
||||
.join('&');
|
||||
}
|
||||
|
||||
function querystringSingleKey(key: string, value: string | number | null | undefined | boolean | Array<string | number | null | boolean> | Set<string | number | null | boolean> | HTTPQuery, keyPrefix: string = ''): string {
|
||||
const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
|
||||
if (value instanceof Array) {
|
||||
const multiValue = value.map(singleValue => encodeURIComponent(String(singleValue)))
|
||||
.join(`&${encodeURIComponent(fullKey)}=`);
|
||||
return `${encodeURIComponent(fullKey)}=${multiValue}`;
|
||||
}
|
||||
if (value instanceof Set) {
|
||||
const valueAsArray = Array.from(value);
|
||||
return querystringSingleKey(key, valueAsArray, keyPrefix);
|
||||
}
|
||||
if (value instanceof Date) {
|
||||
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
|
||||
}
|
||||
if (value instanceof Object) {
|
||||
return querystring(value as HTTPQuery, fullKey);
|
||||
}
|
||||
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
|
||||
}
|
||||
|
||||
export function exists(json: any, key: string) {
|
||||
const value = json[key];
|
||||
return value !== null && value !== undefined;
|
||||
}
|
||||
|
||||
export function mapValues(data: any, fn: (item: any) => any) {
|
||||
const result: { [key: string]: any } = {};
|
||||
for (const key of Object.keys(data)) {
|
||||
result[key] = fn(data[key]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function canConsumeForm(consumes: Consume[]): boolean {
|
||||
for (const consume of consumes) {
|
||||
if ('multipart/form-data' === consume.contentType) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export interface Consume {
|
||||
contentType: string;
|
||||
}
|
||||
|
||||
export interface RequestContext {
|
||||
fetch: FetchAPI;
|
||||
url: string;
|
||||
init: RequestInit;
|
||||
}
|
||||
|
||||
export interface ResponseContext {
|
||||
fetch: FetchAPI;
|
||||
url: string;
|
||||
init: RequestInit;
|
||||
response: Response;
|
||||
}
|
||||
|
||||
export interface ErrorContext {
|
||||
fetch: FetchAPI;
|
||||
url: string;
|
||||
init: RequestInit;
|
||||
error: unknown;
|
||||
response?: Response;
|
||||
}
|
||||
|
||||
export interface Middleware {
|
||||
pre?(context: RequestContext): Promise<FetchParams | void>;
|
||||
post?(context: ResponseContext): Promise<Response | void>;
|
||||
onError?(context: ErrorContext): Promise<Response | void>;
|
||||
}
|
||||
|
||||
export interface ApiResponse<T> {
|
||||
raw: Response;
|
||||
value(): Promise<T>;
|
||||
}
|
||||
|
||||
export interface ResponseTransformer<T> {
|
||||
(json: any): T;
|
||||
}
|
||||
|
||||
export class JSONApiResponse<T> {
|
||||
constructor(public raw: Response, private transformer: ResponseTransformer<T> = (jsonValue: any) => jsonValue) {}
|
||||
|
||||
async value(): Promise<T> {
|
||||
return this.transformer(await this.raw.json());
|
||||
}
|
||||
}
|
||||
|
||||
export class VoidApiResponse {
|
||||
constructor(public raw: Response) {}
|
||||
|
||||
async value(): Promise<void> {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export class BlobApiResponse {
|
||||
constructor(public raw: Response) {}
|
||||
|
||||
async value(): Promise<Blob> {
|
||||
return await this.raw.blob();
|
||||
};
|
||||
}
|
||||
|
||||
export class TextApiResponse {
|
||||
constructor(public raw: Response) {}
|
||||
|
||||
async value(): Promise<string> {
|
||||
return await this.raw.text();
|
||||
};
|
||||
}
|
||||
55
db/test-schema-v1.2/generated-zod/schemas.ts
Normal file
55
db/test-schema-v1.2/generated-zod/schemas.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* AUTO-GENERATED BY CppBeSsot.
|
||||
* Direct edits are pointless: this file is regenerated.
|
||||
* Update the OpenAPI schema and/or CppBeSsot templates, then regenerate generated-* outputs.
|
||||
*/
|
||||
|
||||
import { makeApi, Zodios, type ZodiosOptions } from "@zodios/core";
|
||||
import { z } from "zod";
|
||||
|
||||
const Agent = z
|
||||
.object({
|
||||
id: z.string(),
|
||||
role: z.string(),
|
||||
persistent: z.boolean(),
|
||||
displayName: z.string().optional(),
|
||||
trustScore: z.number().int().gte(0).lte(100).optional(),
|
||||
})
|
||||
.passthrough();
|
||||
const GovernmentAddress = z
|
||||
.object({
|
||||
id: z.string(),
|
||||
addressLabel: z.string().optional(),
|
||||
regionLookupKey: z.string().optional(),
|
||||
})
|
||||
.passthrough();
|
||||
const TripAttemptResult = z
|
||||
.object({
|
||||
id: z.string(),
|
||||
result: z.string(),
|
||||
retryReason: z.string().optional(),
|
||||
governmentSuspensionReason: z.string().optional(),
|
||||
governmentTerminationReason: z.string().optional(),
|
||||
complianceSuspensionReason: z.string().optional(),
|
||||
complianceTerminationReason: z.string().optional(),
|
||||
policySuspensionReason: z.string().optional(),
|
||||
policyTerminationReason: z.string().optional(),
|
||||
cancelationReason: z.string().optional(),
|
||||
failureReason: z.string().optional(),
|
||||
details: z.string().optional(),
|
||||
})
|
||||
.passthrough();
|
||||
|
||||
export const schemas = {
|
||||
Agent,
|
||||
GovernmentAddress,
|
||||
TripAttemptResult,
|
||||
};
|
||||
|
||||
const endpoints = makeApi([]);
|
||||
|
||||
export const api = new Zodios(endpoints);
|
||||
|
||||
export function createApiClient(baseUrl: string, options?: ZodiosOptions) {
|
||||
return new Zodios(baseUrl, endpoints, options);
|
||||
}
|
||||
@@ -49,10 +49,19 @@ inline std::vector<std::filesystem::path> cppbessot_sql_files()
|
||||
std::vector<std::filesystem::path> files;
|
||||
for(const auto& entry : std::filesystem::directory_iterator(sql_dir))
|
||||
{
|
||||
if(entry.is_regular_file() && entry.path().extension() == ".sql")
|
||||
if(!entry.is_regular_file() || entry.path().extension() != ".sql")
|
||||
{
|
||||
files.push_back(entry.path());
|
||||
continue;
|
||||
}
|
||||
|
||||
const std::string stem = entry.path().stem().string();
|
||||
if(stem.ends_with("-pre") || stem.ends_with("-post"))
|
||||
{
|
||||
// These roundtrip tests bootstrap from full schema snapshots, not ODB migration fragments.
|
||||
continue;
|
||||
}
|
||||
|
||||
files.push_back(entry.path());
|
||||
}
|
||||
|
||||
std::sort(files.begin(), files.end());
|
||||
|
||||
Reference in New Issue
Block a user