Compare commits
2 Commits
c9a84e0568
...
830185c3c5
| Author | SHA1 | Date |
|---|---|---|
|
|
830185c3c5 | |
|
|
34740bf126 |
|
|
@ -12,7 +12,7 @@ list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)
|
||||||
include(CTest)
|
include(CTest)
|
||||||
include(Catch)
|
include(Catch)
|
||||||
|
|
||||||
set(MYSQL_CONNECTION_STRING "mysql://test:test123!@127.0.0.1:3306/testdb")
|
set(MYSQL_CONNECTION_STRING "mysql://test:test123!@127.0.0.1:3306/matador_test")
|
||||||
|
|
||||||
configure_file(Connection.hpp.in ${PROJECT_BINARY_DIR}/backends/mysql/test/connection.hpp @ONLY IMMEDIATE)
|
configure_file(Connection.hpp.in ${PROJECT_BINARY_DIR}/backends/mysql/test/connection.hpp @ONLY IMMEDIATE)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,8 @@ TEST_CASE_METHOD(StatementTestFixture, "Create prepared statement", "[statement]
|
||||||
SECTION("Insert with prepared statement and placeholder") {
|
SECTION("Insert with prepared statement and placeholder") {
|
||||||
auto stmt = db.query(schema).insert()
|
auto stmt = db.query(schema).insert()
|
||||||
.into<airplane>("airplane")
|
.into<airplane>("airplane")
|
||||||
.values<airplane>().prepare();
|
.values<airplane>()
|
||||||
|
.prepare();
|
||||||
|
|
||||||
for (const auto &plane: planes) {
|
for (const auto &plane: planes) {
|
||||||
auto res = stmt.bind(*plane).execute();
|
auto res = stmt.bind(*plane).execute();
|
||||||
|
|
|
||||||
|
|
@ -88,10 +88,19 @@ TEST_CASE_METHOD(TypeTraitsTestFixture, "Special handling of attributes with typ
|
||||||
SECTION("Insert and select with direct execution") {
|
SECTION("Insert and select with direct execution") {
|
||||||
location loc{1, "center", {1, 2, 3}, Color::Black};
|
location loc{1, "center", {1, 2, 3}, Color::Black};
|
||||||
|
|
||||||
auto res = db.query(schema).insert().into<location>("location").values(loc).execute();
|
auto res = db
|
||||||
|
.query(schema)
|
||||||
|
.insert()
|
||||||
|
.into<location>("location")
|
||||||
|
.values(loc)
|
||||||
|
.execute();
|
||||||
REQUIRE(res == 1);
|
REQUIRE(res == 1);
|
||||||
|
|
||||||
auto result = db.query(schema).select<location>().from("location").fetch_all<location>();
|
auto result = db
|
||||||
|
.query(schema)
|
||||||
|
.select<location>()
|
||||||
|
.from("location")
|
||||||
|
.fetch_all<location>();
|
||||||
|
|
||||||
for (const auto &l: result) {
|
for (const auto &l: result) {
|
||||||
REQUIRE(l.name == "center");
|
REQUIRE(l.name == "center");
|
||||||
|
|
@ -101,12 +110,23 @@ TEST_CASE_METHOD(TypeTraitsTestFixture, "Special handling of attributes with typ
|
||||||
SECTION("Insert and select with prepared statement") {
|
SECTION("Insert and select with prepared statement") {
|
||||||
location loc{1, "center", {1, 2, 3}, Color::Black};
|
location loc{1, "center", {1, 2, 3}, Color::Black};
|
||||||
|
|
||||||
auto stmt = db.query(schema).insert().into<location>("location").values<location>().prepare();
|
auto stmt = db
|
||||||
auto res = stmt.bind(loc).execute();
|
.query(schema)
|
||||||
|
.insert()
|
||||||
|
.into<location>("location")
|
||||||
|
.values<location>()
|
||||||
|
.prepare();
|
||||||
|
|
||||||
|
auto res = stmt
|
||||||
|
.bind(loc)
|
||||||
|
.execute();
|
||||||
REQUIRE(res == 1);
|
REQUIRE(res == 1);
|
||||||
|
|
||||||
auto result = db.query(schema).select<location>().from("location").
|
auto result = db
|
||||||
template fetch_all<location>();
|
.query(schema)
|
||||||
|
.select<location>()
|
||||||
|
.from("location")
|
||||||
|
.fetch_all<location>();
|
||||||
|
|
||||||
for (const auto &l: result) {
|
for (const auto &l: result) {
|
||||||
REQUIRE(l.name == "center");
|
REQUIRE(l.name == "center");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue