Skip to content

Commit

Permalink
add get insert id after insert
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacyking committed Dec 14, 2023
1 parent 4ec114d commit 5452a13
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions include/mysql.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,18 @@ class mysql {

template <typename T, typename... Args>
uint64_t get_insert_id_after_insert(const T &t, Args &&...args) {
std::optional<uint64_t> insert_id = {0};
uint64_t insert_id = {0};
insert_or_update_impl(t, generate_insert_sql<T>(true), OptType::insert,
std::move(insert_id));
return insert_id.value();
return insert_id;
}

template <typename T, typename... Args>
uint64_t get_insert_id_after_insert(const std::vector<T> &v, Args &&...args) {
std::optional<uint64_t> insert_id = {0};
uint64_t insert_id = {0};
insert_or_update_impl(v, generate_insert_sql<T>(true), OptType::insert,
std::move(insert_id));
return insert_id.value();
return insert_id;
}

template <typename T, typename... Args>
Expand Down
8 changes: 4 additions & 4 deletions include/postgresql.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,18 @@ class postgresql {

template <typename T, typename... Args>
uint64_t get_insert_id_after_insert(const T &t, Args &&...args) {
std::optional<uint64_t> insert_id = {0};
uint64_t insert_id = {0};
insert_or_update_impl(t, generate_insert_sql<T>(true), OptType::insert,
std::move(insert_id));
return insert_id.value();
return insert_id;
}

template <typename T, typename... Args>
uint64_t get_insert_id_after_insert(const std::vector<T> &v, Args &&...args) {
std::optional<uint64_t> insert_id = {0};
uint64_t insert_id = {0};
insert_or_update_impl(v, generate_insert_sql<T>(true), OptType::insert,
std::move(insert_id));
return insert_id.value();
return insert_id;
}

template <typename T, typename... Args>
Expand Down
8 changes: 4 additions & 4 deletions include/sqlite.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,18 @@ class sqlite {

template <typename T, typename... Args>
uint64_t get_insert_id_after_insert(const T &t, Args &&...args) {
std::optional<uint64_t> insert_id = {0};
uint64_t insert_id = {0};
insert_or_update_impl(t, generate_insert_sql<T>(true), OptType::insert,
std::move(insert_id));
return insert_id.value();
return insert_id;
}

template <typename T, typename... Args>
uint64_t get_insert_id_after_insert(const std::vector<T> &v, Args &&...args) {
std::optional<uint64_t> insert_id = {0};
uint64_t insert_id = {0};
insert_or_update_impl(v, generate_insert_sql<T>(true), OptType::insert,
std::move(insert_id));
return insert_id.value();
return insert_id;
}

template <typename T, typename... Args>
Expand Down

0 comments on commit 5452a13

Please sign in to comment.