changed the interface of on_primary_key to have a third parameter of type primary_key_attribute
This commit is contained in:
@@ -71,7 +71,6 @@ add_library(matador-orm STATIC
|
||||
query/attribute_string_writer.cpp
|
||||
query/basic_condition.cpp
|
||||
query/condition.cpp
|
||||
query/fk_value_extractor.cpp
|
||||
query/intermediates/executable_query.cpp
|
||||
query/intermediates/fetchable_query.cpp
|
||||
query/intermediates/query_create_intermediate.cpp
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
#include "matador/orm/session_insert_builder.hpp"
|
||||
|
||||
namespace matador::orm {
|
||||
void session_insert_builder::on_primary_key(const char* id, std::string& value, size_t) {
|
||||
push(id, value);
|
||||
}
|
||||
|
||||
void session_insert_builder::on_revision(const char* id, unsigned long long& x) {
|
||||
push(id, x);
|
||||
}
|
||||
|
||||
@@ -3,14 +3,6 @@
|
||||
#include <iostream>
|
||||
|
||||
namespace matador::orm {
|
||||
void session_query_builder::on_primary_key(const char *id, std::string &, size_t) {
|
||||
push(id);
|
||||
if (!is_root_entity()) {
|
||||
const auto b = pk_.is_varchar();
|
||||
std::cout << "is matching primary key: " << std::boolalpha << b << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
void session_query_builder::on_revision(const char *id, unsigned long long &/*rev*/) {
|
||||
push(id);
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
#include "matador/query/fk_value_extractor.hpp"
|
||||
|
||||
namespace matador::query::detail {
|
||||
|
||||
void fk_value_extractor::on_primary_key(const char *, std::string &pk, size_t)
|
||||
{
|
||||
value_ = pk;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,11 +7,6 @@ namespace matador::sql {
|
||||
detail::pk_reader::pk_reader(query_result_reader &reader)
|
||||
: reader_(reader) {}
|
||||
|
||||
void detail::pk_reader::on_primary_key(const char *id, std::string &value, size_t size)
|
||||
{
|
||||
utils::data_type_traits<std::string>::read_value(reader_, id, column_index_++, value, size);
|
||||
}
|
||||
|
||||
query_result_impl::query_result_impl(std::unique_ptr<query_result_reader> &&reader, std::vector<object::attribute_definition> &&prototype, const size_t column_index)
|
||||
: column_index_(column_index)
|
||||
, prototype_(std::move(prototype))
|
||||
@@ -26,11 +21,6 @@ query_result_impl::query_result_impl(std::unique_ptr<query_result_reader> &&read
|
||||
, pk_reader_(*reader_)
|
||||
{}
|
||||
|
||||
void query_result_impl::on_primary_key(const char *id, std::string &value, size_t size)
|
||||
{
|
||||
utils::data_type_traits<std::string>::read_value(*reader_, id, column_index_++, value, size);
|
||||
}
|
||||
|
||||
void query_result_impl::on_revision(const char *id, uint64_t &rev)
|
||||
{
|
||||
utils::data_type_traits<uint64_t>::read_value(*reader_, id, column_index_++, rev);
|
||||
|
||||
@@ -4,13 +4,7 @@
|
||||
|
||||
namespace matador::query {
|
||||
|
||||
void key_value_generator::on_primary_key(const char *id, std::string &x, size_t)
|
||||
{
|
||||
result_.emplace_back(id, x);
|
||||
}
|
||||
|
||||
void key_value_generator::on_revision(const char *id, unsigned long long int &x)
|
||||
{
|
||||
void key_value_generator::on_revision(const char *id, unsigned long long int &x) {
|
||||
result_.emplace_back(id, x);
|
||||
}
|
||||
|
||||
|
||||
@@ -275,8 +275,8 @@ void query_compiler::visit(internal::query_create_table_part &create_table_part)
|
||||
}
|
||||
for (const auto &[column, reference_column]: context.foreign_contexts) {
|
||||
// ALTER TABLE Orders ADD CONSTRAINT FK_PersonOrder FOREIGN KEY (PersonID) REFERENCES Persons(PersonID);
|
||||
std::string fk_cmd = "ALTER TABLE " + query_.table.name + " ADD";
|
||||
fk_cmd += " CONSTRAINT FK_" + create_table_part.table().name;
|
||||
std::string fk_cmd = "ALTER TABLE " + dialect_->prepare_identifier_string(query_.table.name) + " ADD";
|
||||
fk_cmd += " CONSTRAINT FK_" + query_.table.name;
|
||||
fk_cmd += "_" + column;
|
||||
fk_cmd += " FOREIGN KEY (" + dialect_->prepare_identifier_string(column) + ")";
|
||||
fk_cmd += " REFERENCES " + reference_column->table_name() + "(" + reference_column->name() + ")";
|
||||
|
||||
@@ -6,11 +6,6 @@ value_extractor::value_extractor(std::vector<utils::database_type> &values)
|
||||
: values_(values)
|
||||
{}
|
||||
|
||||
void value_extractor::on_primary_key(const char *, std::string &pk, size_t s)
|
||||
{
|
||||
utils::data_type_traits<std::string>::bind_value(*this, 0, pk, s);
|
||||
}
|
||||
|
||||
void value_extractor::on_revision(const char *, uint64_t &rev)
|
||||
{
|
||||
utils::data_type_traits<uint64_t>::bind_value(*this, 0, rev);
|
||||
|
||||
@@ -18,14 +18,6 @@ column_generator::column_generator(std::vector<column> &column_infos,
|
||||
seen_tables.insert(table_name);
|
||||
}
|
||||
|
||||
void column_generator::on_primary_key(const char *id, std::string &, size_t)
|
||||
{
|
||||
if (has_many_to_many_) {
|
||||
return;
|
||||
}
|
||||
push(id);
|
||||
}
|
||||
|
||||
void column_generator::on_revision(const char *id, unsigned long long int &)
|
||||
{
|
||||
if (has_many_to_many_) {
|
||||
|
||||
@@ -4,25 +4,11 @@
|
||||
|
||||
namespace matador::sql {
|
||||
|
||||
namespace detail {
|
||||
|
||||
void fk_result_binder::on_primary_key(const char * /*id*/, std::string &value, const size_t size)
|
||||
{
|
||||
utils::data_type_traits<std::string>::read_value(*binder_, id_, index_++, value, size);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void object_result_binder::reset()
|
||||
{
|
||||
index_ = 0;
|
||||
}
|
||||
|
||||
void object_result_binder::on_primary_key(const char *id, std::string &value, const size_t size)
|
||||
{
|
||||
utils::data_type_traits<std::string>::read_value(*binder_, id, index_++, value, size);
|
||||
}
|
||||
|
||||
void object_result_binder::on_revision(const char *id, uint64_t &value)
|
||||
{
|
||||
utils::data_type_traits<uint64_t>::read_value(*binder_, id, index_++, value);
|
||||
|
||||
@@ -3,15 +3,6 @@
|
||||
#include "matador/utils/value.hpp"
|
||||
|
||||
namespace matador::sql::internal {
|
||||
void query_result_pk_resolver::on_primary_key(const char* id, std::string& /*value*/, const size_t size) {
|
||||
if (!type_stack_.empty()) {
|
||||
return;
|
||||
}
|
||||
std::string value;
|
||||
utils::data_type_traits<std::string>::read_value(reader_, id, column_index_++, value, size);
|
||||
pk_ = value;
|
||||
}
|
||||
|
||||
void query_result_pk_resolver::on_attribute(const char *id, const utils::value &x, const utils::field_attributes &attr) {
|
||||
if (is_constraint_set(attr.options(), utils::constraints::PRIMARY_KEY)) {
|
||||
if (x.is_integer()) {
|
||||
|
||||
@@ -3,25 +3,11 @@
|
||||
|
||||
namespace matador::sql {
|
||||
|
||||
namespace detail {
|
||||
|
||||
void fk_binder::on_primary_key(const char * /*id*/, std::string &value, size_t /*size*/)
|
||||
{
|
||||
utils::data_type_traits<std::string>::bind_value(*binder_, index_++, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void object_parameter_binder::reset(const size_t start_index)
|
||||
{
|
||||
index_ = start_index;
|
||||
}
|
||||
|
||||
void object_parameter_binder::on_primary_key(const char * /*id*/, std::string &val, const size_t size)
|
||||
{
|
||||
utils::data_type_traits<std::string>::bind_value(*binder_, index_++, val, size);
|
||||
}
|
||||
|
||||
void object_parameter_binder::on_revision(const char * /*id*/, uint64_t &rev)
|
||||
{
|
||||
utils::data_type_traits<uint64_t>::bind_value(*binder_, index_++, rev);
|
||||
|
||||
Reference in New Issue
Block a user