From 94c399a8f90b53f886cbf6427e1a8cf08f304384 Mon Sep 17 00:00:00 2001 From: Jacyking <791026912@qq.com> Date: Tue, 19 Dec 2023 17:19:07 +0800 Subject: [PATCH] pg auto key use "bigserial" when the type is int64_t --- include/postgresql.hpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/postgresql.hpp b/include/postgresql.hpp index 2e25513d..832f01d1 100644 --- a/include/postgresql.hpp +++ b/include/postgresql.hpp @@ -333,9 +333,14 @@ class postgresql { } else if constexpr (std::is_same_v) { if (!has_add_field) { - append(sql, field_name.data(), " "); + if (type_name_arr[i] == "bigint") { + append(sql, field_name.data(), " ", "bigserial"); + } + else { + append(sql, field_name.data(), " ", "serial"); + } } - append(sql, " serial primary key"); + append(sql, " primary key"); has_add_field = true; } else if constexpr (std::is_same_v) {