Compare commits
No commits in common. "3fc08fb7ffbd20d7dfcc224ce21890722a42537e" and "905ee019d7465d89fcd23bea62c95eac542b1c14" have entirely different histories.
3fc08fb7ff
...
905ee019d7
|
|
@ -1,7 +1,6 @@
|
||||||
#include "catch2/catch_test_macros.hpp"
|
#include "catch2/catch_test_macros.hpp"
|
||||||
|
|
||||||
#include "matador/query/query.hpp"
|
#include "matador/query/query.hpp"
|
||||||
#include "matador/query/sequence_pk_generator.hpp"
|
|
||||||
|
|
||||||
#include "SequenceFixture.hpp"
|
#include "SequenceFixture.hpp"
|
||||||
|
|
||||||
|
|
@ -35,27 +34,3 @@ TEST_CASE_METHOD(SequenceFixture, "test create and drop sequence", "[sequence][c
|
||||||
.execute(db);
|
.execute(db);
|
||||||
REQUIRE(result.is_ok());
|
REQUIRE(result.is_ok());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE_METHOD(SequenceFixture, "Test nextval and currval through sequence pk generator", "[sequence][nextval][currval]") {
|
|
||||||
auto result = query::create()
|
|
||||||
.sequence("person_seq")
|
|
||||||
.execute(db);
|
|
||||||
REQUIRE(result.is_ok());
|
|
||||||
|
|
||||||
sequences_to_drop.emplace("person_seq");
|
|
||||||
|
|
||||||
sequence_pk_generator generator("person_seq");
|
|
||||||
|
|
||||||
auto pk_result = generator.next_id(db);
|
|
||||||
REQUIRE(pk_result.is_ok());
|
|
||||||
REQUIRE(*pk_result == 1);
|
|
||||||
|
|
||||||
pk_result = generator.current_id(db);
|
|
||||||
REQUIRE(pk_result.is_ok());
|
|
||||||
REQUIRE(*pk_result == 1);
|
|
||||||
|
|
||||||
result = query::drop()
|
|
||||||
.sequence("person_seq")
|
|
||||||
.execute(db);
|
|
||||||
REQUIRE(result.is_ok());
|
|
||||||
}
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
#include "matador/query/expression/expression_operators.hpp"
|
#include "matador/query/expression/expression_operators.hpp"
|
||||||
#include "matador/query/query.hpp"
|
#include "matador/query/query.hpp"
|
||||||
#include "matador/query/table_column.hpp"
|
#include "matador/query/table_column.hpp"
|
||||||
#include "matador/query/table_pk_generator.hpp"
|
|
||||||
|
|
||||||
#include "TableSequenceFixture.hpp"
|
#include "TableSequenceFixture.hpp"
|
||||||
|
|
||||||
|
|
@ -38,24 +37,4 @@ TEST_CASE_METHOD(TableSequenceFixture, "test create and drop table sequence", "[
|
||||||
REQUIRE(id_result);
|
REQUIRE(id_result);
|
||||||
REQUIRE(id_result->has_value());
|
REQUIRE(id_result->has_value());
|
||||||
REQUIRE(id_result->value() == 2);
|
REQUIRE(id_result->value() == 2);
|
||||||
}
|
|
||||||
|
|
||||||
TEST_CASE_METHOD(TableSequenceFixture, "Test nextval and currval through table sequence pk generator", "[table_sequence][nextval][currval]" ) {
|
|
||||||
const auto next_id_col = "next_id"_col;
|
|
||||||
auto result = query::query::insert()
|
|
||||||
.into(sequence_table_name, { "name", next_id_col})
|
|
||||||
.values({ "test_seq", 1 })
|
|
||||||
.execute(db);
|
|
||||||
REQUIRE(result);
|
|
||||||
REQUIRE(result->affected_rows == 1);
|
|
||||||
|
|
||||||
table_pk_generator generator(sequence_table_name, "test_seq");
|
|
||||||
|
|
||||||
auto pk_result = generator.next_id(db);
|
|
||||||
REQUIRE(pk_result.is_ok());
|
|
||||||
REQUIRE(*pk_result == 1);
|
|
||||||
|
|
||||||
pk_result = generator.current_id(db);
|
|
||||||
REQUIRE(pk_result.is_ok());
|
|
||||||
REQUIRE(*pk_result == 2);
|
|
||||||
}
|
}
|
||||||
12
todo.md
12
todo.md
|
|
@ -17,18 +17,6 @@ Order of next steps:
|
||||||
4. Finish `insert_query_builder`
|
4. Finish `insert_query_builder`
|
||||||
- collect all inserts for entities with relations
|
- collect all inserts for entities with relations
|
||||||
- tests
|
- tests
|
||||||
- cascade_type: `Insert`
|
|
||||||
- has_many <-> belongs_to: set root id into the join column of elements
|
|
||||||
- belongs_to <-> has_many: ?
|
|
||||||
- belongs_to <-> has_one: set root id into the foreign object
|
|
||||||
- has_one <-> belongs_to: set root id into the foreign object
|
|
||||||
- has_many_to_many: insert relation table entry
|
|
||||||
|
|
||||||
if generator type `manual` => extract pk before insert
|
|
||||||
=>
|
|
||||||
if generator type `sequence` or `table` => generate pk before insert
|
|
||||||
if generator type `identity` => extract pk after insert and before insert of relation objects
|
|
||||||
|
|
||||||
5. Finish `session::insert` method
|
5. Finish `session::insert` method
|
||||||
- use `insert_query_builder`
|
- use `insert_query_builder`
|
||||||
- correct handling of pk generator
|
- correct handling of pk generator
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue