added tests for sequence generator and table sequence pk generator
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "matador/query/expression/expression_operators.hpp"
|
||||
#include "matador/query/query.hpp"
|
||||
#include "matador/query/table_column.hpp"
|
||||
#include "matador/query/table_pk_generator.hpp"
|
||||
|
||||
#include "TableSequenceFixture.hpp"
|
||||
|
||||
@@ -37,4 +38,24 @@ TEST_CASE_METHOD(TableSequenceFixture, "test create and drop table sequence", "[
|
||||
REQUIRE(id_result);
|
||||
REQUIRE(id_result->has_value());
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user