2023-07-25 13:00:05 +08:00
|
|
|
#pragma once
|
2014-07-20 17:14:44 +08:00
|
|
|
|
2024-06-17 00:45:26 +08:00
|
|
|
// generated by ./scripts/ddl2cpp -with-table-creation-helper tests/core/usage/sample.sql tests/core/usage/Sample test
|
2024-06-15 02:04:08 +08:00
|
|
|
|
2014-07-20 17:14:44 +08:00
|
|
|
#include <sqlpp11/table.h>
|
2015-10-30 05:21:46 +08:00
|
|
|
#include <sqlpp11/data_types.h>
|
2014-12-01 02:40:34 +08:00
|
|
|
#include <sqlpp11/char_sequence.h>
|
2014-07-20 17:14:44 +08:00
|
|
|
|
|
|
|
namespace test
|
|
|
|
{
|
2024-06-17 00:45:26 +08:00
|
|
|
template<typename Db>
|
|
|
|
void createTabFoo(Db& db)
|
|
|
|
{
|
|
|
|
db.execute(R"+++(DROP TABLE IF EXISTS tab_foo)+++");
|
|
|
|
db.execute(R"+++(CREATE TABLE tab_foo
|
|
|
|
(
|
|
|
|
id bigint AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
text_nn_d varchar(255) NOT NULL DEFAULT "",
|
|
|
|
int_n bigint,
|
|
|
|
double_n double,
|
|
|
|
u_int_n bigint UNSIGNED,
|
|
|
|
blob_n BLOB
|
|
|
|
))+++");
|
|
|
|
}
|
|
|
|
|
2014-07-20 17:14:44 +08:00
|
|
|
namespace TabFoo_
|
|
|
|
{
|
2024-06-15 02:04:08 +08:00
|
|
|
struct Id
|
2014-07-20 17:14:44 +08:00
|
|
|
{
|
2014-12-01 02:40:34 +08:00
|
|
|
struct _alias_t
|
2014-07-20 17:14:44 +08:00
|
|
|
{
|
2024-06-15 02:04:08 +08:00
|
|
|
static constexpr const char _literal[] = "id";
|
2014-12-01 02:40:34 +08:00
|
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
2024-06-15 02:04:08 +08:00
|
|
|
template<typename T>
|
2014-07-20 17:14:44 +08:00
|
|
|
struct _member_t
|
2015-09-14 03:33:19 +08:00
|
|
|
{
|
2024-06-15 02:04:08 +08:00
|
|
|
T id;
|
|
|
|
T& operator()() { return id; }
|
|
|
|
const T& operator()() const { return id; }
|
|
|
|
};
|
2014-07-20 17:14:44 +08:00
|
|
|
};
|
2024-06-15 02:04:08 +08:00
|
|
|
using _traits = sqlpp::make_traits<sqlpp::integer, sqlpp::tag::must_not_insert, sqlpp::tag::must_not_update>;
|
2014-07-20 17:14:44 +08:00
|
|
|
};
|
2024-06-15 02:04:08 +08:00
|
|
|
struct TextNnD
|
2014-07-20 17:14:44 +08:00
|
|
|
{
|
2014-12-01 02:40:34 +08:00
|
|
|
struct _alias_t
|
2014-07-20 17:14:44 +08:00
|
|
|
{
|
2024-06-15 02:04:08 +08:00
|
|
|
static constexpr const char _literal[] = "text_nn_d";
|
2014-12-01 02:40:34 +08:00
|
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
2024-06-15 02:04:08 +08:00
|
|
|
template<typename T>
|
2014-07-20 17:14:44 +08:00
|
|
|
struct _member_t
|
2015-09-14 03:33:19 +08:00
|
|
|
{
|
2024-06-15 02:04:08 +08:00
|
|
|
T textNnD;
|
|
|
|
T& operator()() { return textNnD; }
|
|
|
|
const T& operator()() const { return textNnD; }
|
|
|
|
};
|
2014-07-20 17:14:44 +08:00
|
|
|
};
|
2024-06-15 02:04:08 +08:00
|
|
|
using _traits = sqlpp::make_traits<sqlpp::text>;
|
2014-07-20 17:14:44 +08:00
|
|
|
};
|
2024-06-15 02:04:08 +08:00
|
|
|
struct IntN
|
2014-07-20 17:14:44 +08:00
|
|
|
{
|
2014-12-01 02:40:34 +08:00
|
|
|
struct _alias_t
|
2014-07-20 17:14:44 +08:00
|
|
|
{
|
2024-06-15 02:04:08 +08:00
|
|
|
static constexpr const char _literal[] = "int_n";
|
2014-12-01 02:40:34 +08:00
|
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
2024-06-15 02:04:08 +08:00
|
|
|
template<typename T>
|
2014-07-20 17:14:44 +08:00
|
|
|
struct _member_t
|
|
|
|
{
|
2024-06-15 02:04:08 +08:00
|
|
|
T intN;
|
|
|
|
T& operator()() { return intN; }
|
|
|
|
const T& operator()() const { return intN; }
|
|
|
|
};
|
|
|
|
};
|
|
|
|
using _traits = sqlpp::make_traits<sqlpp::integer, sqlpp::tag::can_be_null>;
|
|
|
|
};
|
|
|
|
struct DoubleN
|
|
|
|
{
|
|
|
|
struct _alias_t
|
|
|
|
{
|
|
|
|
static constexpr const char _literal[] = "double_n";
|
|
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
|
|
|
template<typename T>
|
|
|
|
struct _member_t
|
2015-09-14 03:33:19 +08:00
|
|
|
{
|
2024-06-15 02:04:08 +08:00
|
|
|
T doubleN;
|
|
|
|
T& operator()() { return doubleN; }
|
|
|
|
const T& operator()() const { return doubleN; }
|
|
|
|
};
|
2014-07-20 17:14:44 +08:00
|
|
|
};
|
2014-07-24 00:06:33 +08:00
|
|
|
using _traits = sqlpp::make_traits<sqlpp::floating_point, sqlpp::tag::can_be_null>;
|
2014-07-20 17:14:44 +08:00
|
|
|
};
|
2024-06-15 02:04:08 +08:00
|
|
|
struct UIntN
|
2016-05-20 19:09:48 +08:00
|
|
|
{
|
|
|
|
struct _alias_t
|
|
|
|
{
|
2024-06-15 02:04:08 +08:00
|
|
|
static constexpr const char _literal[] = "u_int_n";
|
2016-05-20 19:09:48 +08:00
|
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
2024-06-15 02:04:08 +08:00
|
|
|
template<typename T>
|
2016-05-20 19:09:48 +08:00
|
|
|
struct _member_t
|
|
|
|
{
|
2024-06-15 02:04:08 +08:00
|
|
|
T uIntN;
|
|
|
|
T& operator()() { return uIntN; }
|
|
|
|
const T& operator()() const { return uIntN; }
|
|
|
|
};
|
2016-05-20 19:09:48 +08:00
|
|
|
};
|
2024-06-15 02:04:08 +08:00
|
|
|
using _traits = sqlpp::make_traits<sqlpp::integer_unsigned, sqlpp::tag::can_be_null>;
|
2016-06-06 03:35:49 +08:00
|
|
|
};
|
2024-06-15 02:04:08 +08:00
|
|
|
struct BlobN
|
2017-08-07 01:54:54 +08:00
|
|
|
{
|
|
|
|
struct _alias_t
|
|
|
|
{
|
2024-06-15 02:04:08 +08:00
|
|
|
static constexpr const char _literal[] = "blob_n";
|
2017-08-07 01:54:54 +08:00
|
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
2024-06-15 02:04:08 +08:00
|
|
|
template<typename T>
|
2017-08-07 01:54:54 +08:00
|
|
|
struct _member_t
|
|
|
|
{
|
2024-06-15 02:04:08 +08:00
|
|
|
T blobN;
|
|
|
|
T& operator()() { return blobN; }
|
|
|
|
const T& operator()() const { return blobN; }
|
|
|
|
};
|
2017-08-07 01:54:54 +08:00
|
|
|
};
|
|
|
|
using _traits = sqlpp::make_traits<sqlpp::blob, sqlpp::tag::can_be_null>;
|
|
|
|
};
|
2024-06-15 02:04:08 +08:00
|
|
|
} // namespace TabFoo_
|
2014-07-20 17:14:44 +08:00
|
|
|
|
2024-06-15 02:04:08 +08:00
|
|
|
struct TabFoo: sqlpp::table_t<TabFoo,
|
|
|
|
TabFoo_::Id,
|
|
|
|
TabFoo_::TextNnD,
|
|
|
|
TabFoo_::IntN,
|
|
|
|
TabFoo_::DoubleN,
|
|
|
|
TabFoo_::UIntN,
|
|
|
|
TabFoo_::BlobN>
|
2014-07-20 17:14:44 +08:00
|
|
|
{
|
2014-12-01 02:40:34 +08:00
|
|
|
struct _alias_t
|
2014-07-20 17:14:44 +08:00
|
|
|
{
|
2024-06-15 02:04:08 +08:00
|
|
|
static constexpr const char _literal[] = "tab_foo";
|
2014-12-01 02:40:34 +08:00
|
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
2024-06-15 02:04:08 +08:00
|
|
|
template<typename T>
|
2014-07-20 17:14:44 +08:00
|
|
|
struct _member_t
|
|
|
|
{
|
|
|
|
T tabFoo;
|
2024-06-15 02:04:08 +08:00
|
|
|
T& operator()() { return tabFoo; }
|
|
|
|
const T& operator()() const { return tabFoo; }
|
2014-07-20 17:14:44 +08:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-06-17 00:45:26 +08:00
|
|
|
template<typename Db>
|
|
|
|
void createTabBar(Db& db)
|
|
|
|
{
|
|
|
|
db.execute(R"+++(DROP TABLE IF EXISTS tab_bar)+++");
|
|
|
|
db.execute(R"+++(CREATE TABLE tab_bar
|
|
|
|
(
|
|
|
|
id bigint AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
text_n varchar(255) NULL DEFAULT "",
|
|
|
|
bool_nn bool NOT NULL,
|
|
|
|
int_n int
|
|
|
|
))+++");
|
|
|
|
}
|
|
|
|
|
2014-07-20 17:14:44 +08:00
|
|
|
namespace TabBar_
|
|
|
|
{
|
2024-06-15 02:04:08 +08:00
|
|
|
struct Id
|
2014-07-20 17:14:44 +08:00
|
|
|
{
|
2014-12-01 02:40:34 +08:00
|
|
|
struct _alias_t
|
2014-07-20 17:14:44 +08:00
|
|
|
{
|
2024-06-15 02:04:08 +08:00
|
|
|
static constexpr const char _literal[] = "id";
|
2014-12-01 02:40:34 +08:00
|
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
2024-06-15 02:04:08 +08:00
|
|
|
template<typename T>
|
2014-07-20 17:14:44 +08:00
|
|
|
struct _member_t
|
2015-09-14 03:33:19 +08:00
|
|
|
{
|
2024-06-15 02:04:08 +08:00
|
|
|
T id;
|
|
|
|
T& operator()() { return id; }
|
|
|
|
const T& operator()() const { return id; }
|
|
|
|
};
|
2014-07-20 17:14:44 +08:00
|
|
|
};
|
2024-06-15 02:04:08 +08:00
|
|
|
using _traits = sqlpp::make_traits<sqlpp::integer, sqlpp::tag::must_not_insert, sqlpp::tag::must_not_update>;
|
2014-07-20 17:14:44 +08:00
|
|
|
};
|
2024-06-15 02:04:08 +08:00
|
|
|
struct TextN
|
2014-07-20 17:14:44 +08:00
|
|
|
{
|
2014-12-01 02:40:34 +08:00
|
|
|
struct _alias_t
|
2014-07-20 17:14:44 +08:00
|
|
|
{
|
2024-06-15 02:04:08 +08:00
|
|
|
static constexpr const char _literal[] = "text_n";
|
2014-12-01 02:40:34 +08:00
|
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
2024-06-15 02:04:08 +08:00
|
|
|
template<typename T>
|
2014-07-20 17:14:44 +08:00
|
|
|
struct _member_t
|
2015-09-14 03:33:19 +08:00
|
|
|
{
|
2024-06-15 02:04:08 +08:00
|
|
|
T textN;
|
|
|
|
T& operator()() { return textN; }
|
|
|
|
const T& operator()() const { return textN; }
|
|
|
|
};
|
2014-07-20 17:14:44 +08:00
|
|
|
};
|
2024-06-15 02:04:08 +08:00
|
|
|
using _traits = sqlpp::make_traits<sqlpp::text, sqlpp::tag::can_be_null>;
|
2014-07-20 17:14:44 +08:00
|
|
|
};
|
2024-06-15 02:04:08 +08:00
|
|
|
struct BoolNn
|
2014-07-20 17:14:44 +08:00
|
|
|
{
|
2014-12-01 02:40:34 +08:00
|
|
|
struct _alias_t
|
2014-07-20 17:14:44 +08:00
|
|
|
{
|
2024-06-15 02:04:08 +08:00
|
|
|
static constexpr const char _literal[] = "bool_nn";
|
2014-12-01 02:40:34 +08:00
|
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
2024-06-15 02:04:08 +08:00
|
|
|
template<typename T>
|
2014-07-20 17:14:44 +08:00
|
|
|
struct _member_t
|
2015-09-14 03:33:19 +08:00
|
|
|
{
|
2024-06-15 02:04:08 +08:00
|
|
|
T boolNn;
|
|
|
|
T& operator()() { return boolNn; }
|
|
|
|
const T& operator()() const { return boolNn; }
|
|
|
|
};
|
2014-07-20 17:14:44 +08:00
|
|
|
};
|
2014-07-24 00:06:33 +08:00
|
|
|
using _traits = sqlpp::make_traits<sqlpp::boolean, sqlpp::tag::require_insert>;
|
2014-07-20 17:14:44 +08:00
|
|
|
};
|
2024-06-15 02:04:08 +08:00
|
|
|
struct IntN
|
2014-07-20 17:14:44 +08:00
|
|
|
{
|
2014-12-01 02:40:34 +08:00
|
|
|
struct _alias_t
|
2014-07-20 17:14:44 +08:00
|
|
|
{
|
2024-06-15 02:04:08 +08:00
|
|
|
static constexpr const char _literal[] = "int_n";
|
2014-12-01 02:40:34 +08:00
|
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
2024-06-15 02:04:08 +08:00
|
|
|
template<typename T>
|
2014-07-20 17:14:44 +08:00
|
|
|
struct _member_t
|
|
|
|
{
|
2024-06-15 02:04:08 +08:00
|
|
|
T intN;
|
|
|
|
T& operator()() { return intN; }
|
|
|
|
const T& operator()() const { return intN; }
|
|
|
|
};
|
2014-07-20 17:14:44 +08:00
|
|
|
};
|
2014-07-24 00:06:33 +08:00
|
|
|
using _traits = sqlpp::make_traits<sqlpp::integer, sqlpp::tag::can_be_null>;
|
2014-07-20 17:14:44 +08:00
|
|
|
};
|
2024-06-15 02:04:08 +08:00
|
|
|
} // namespace TabBar_
|
2014-07-20 17:14:44 +08:00
|
|
|
|
2024-06-15 02:04:08 +08:00
|
|
|
struct TabBar: sqlpp::table_t<TabBar,
|
|
|
|
TabBar_::Id,
|
|
|
|
TabBar_::TextN,
|
|
|
|
TabBar_::BoolNn,
|
|
|
|
TabBar_::IntN>
|
2014-07-20 17:14:44 +08:00
|
|
|
{
|
2014-12-01 02:40:34 +08:00
|
|
|
struct _alias_t
|
2014-07-20 17:14:44 +08:00
|
|
|
{
|
2024-06-15 02:04:08 +08:00
|
|
|
static constexpr const char _literal[] = "tab_bar";
|
2014-12-01 02:40:34 +08:00
|
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
2024-06-15 02:04:08 +08:00
|
|
|
template<typename T>
|
2014-07-20 17:14:44 +08:00
|
|
|
struct _member_t
|
|
|
|
{
|
|
|
|
T tabBar;
|
2024-06-15 02:04:08 +08:00
|
|
|
T& operator()() { return tabBar; }
|
|
|
|
const T& operator()() const { return tabBar; }
|
2014-07-20 17:14:44 +08:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-06-17 00:45:26 +08:00
|
|
|
template<typename Db>
|
|
|
|
void createTabDateTime(Db& db)
|
|
|
|
{
|
|
|
|
db.execute(R"+++(DROP TABLE IF EXISTS tab_date_time)+++");
|
|
|
|
db.execute(R"+++(CREATE TABLE tab_date_time
|
|
|
|
(
|
|
|
|
id bigint AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
day_point_n date,
|
|
|
|
time_point_n datetime,
|
|
|
|
time_of_day_n time
|
|
|
|
))+++");
|
|
|
|
}
|
|
|
|
|
2015-10-29 03:52:43 +08:00
|
|
|
namespace TabDateTime_
|
|
|
|
{
|
2024-06-15 02:04:08 +08:00
|
|
|
struct Id
|
2015-10-29 03:52:43 +08:00
|
|
|
{
|
|
|
|
struct _alias_t
|
|
|
|
{
|
2024-06-15 02:04:08 +08:00
|
|
|
static constexpr const char _literal[] = "id";
|
2015-10-29 03:52:43 +08:00
|
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
2024-06-15 02:04:08 +08:00
|
|
|
template<typename T>
|
2015-10-29 03:52:43 +08:00
|
|
|
struct _member_t
|
|
|
|
{
|
2024-06-15 02:04:08 +08:00
|
|
|
T id;
|
|
|
|
T& operator()() { return id; }
|
|
|
|
const T& operator()() const { return id; }
|
|
|
|
};
|
|
|
|
};
|
|
|
|
using _traits = sqlpp::make_traits<sqlpp::integer, sqlpp::tag::must_not_insert, sqlpp::tag::must_not_update>;
|
|
|
|
};
|
|
|
|
struct DayPointN
|
|
|
|
{
|
|
|
|
struct _alias_t
|
|
|
|
{
|
|
|
|
static constexpr const char _literal[] = "day_point_n";
|
|
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
|
|
|
template<typename T>
|
|
|
|
struct _member_t
|
2015-10-29 03:52:43 +08:00
|
|
|
{
|
2024-06-15 02:04:08 +08:00
|
|
|
T dayPointN;
|
|
|
|
T& operator()() { return dayPointN; }
|
|
|
|
const T& operator()() const { return dayPointN; }
|
|
|
|
};
|
2015-10-29 03:52:43 +08:00
|
|
|
};
|
2015-10-29 23:41:45 +08:00
|
|
|
using _traits = sqlpp::make_traits<sqlpp::day_point, sqlpp::tag::can_be_null>;
|
2015-10-29 03:52:43 +08:00
|
|
|
};
|
2024-06-15 02:04:08 +08:00
|
|
|
struct TimePointN
|
2015-10-29 03:52:43 +08:00
|
|
|
{
|
|
|
|
struct _alias_t
|
|
|
|
{
|
2024-06-15 02:04:08 +08:00
|
|
|
static constexpr const char _literal[] = "time_point_n";
|
2015-10-29 03:52:43 +08:00
|
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
2024-06-15 02:04:08 +08:00
|
|
|
template<typename T>
|
2015-10-29 03:52:43 +08:00
|
|
|
struct _member_t
|
|
|
|
{
|
2024-06-15 02:04:08 +08:00
|
|
|
T timePointN;
|
|
|
|
T& operator()() { return timePointN; }
|
|
|
|
const T& operator()() const { return timePointN; }
|
|
|
|
};
|
2015-10-29 03:52:43 +08:00
|
|
|
};
|
2015-10-29 23:41:45 +08:00
|
|
|
using _traits = sqlpp::make_traits<sqlpp::time_point, sqlpp::tag::can_be_null>;
|
2015-10-29 03:52:43 +08:00
|
|
|
};
|
2024-06-15 02:04:08 +08:00
|
|
|
struct TimeOfDayN
|
2016-05-19 20:53:56 +08:00
|
|
|
{
|
|
|
|
struct _alias_t
|
|
|
|
{
|
2024-06-15 02:04:08 +08:00
|
|
|
static constexpr const char _literal[] = "time_of_day_n";
|
2016-05-19 20:53:56 +08:00
|
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
2024-06-15 02:04:08 +08:00
|
|
|
template<typename T>
|
2016-05-19 20:53:56 +08:00
|
|
|
struct _member_t
|
|
|
|
{
|
2024-06-15 02:04:08 +08:00
|
|
|
T timeOfDayN;
|
|
|
|
T& operator()() { return timeOfDayN; }
|
|
|
|
const T& operator()() const { return timeOfDayN; }
|
|
|
|
};
|
2016-05-19 20:53:56 +08:00
|
|
|
};
|
|
|
|
using _traits = sqlpp::make_traits<sqlpp::time_of_day, sqlpp::tag::can_be_null>;
|
|
|
|
};
|
2024-06-15 02:04:08 +08:00
|
|
|
} // namespace TabDateTime_
|
2015-10-29 03:52:43 +08:00
|
|
|
|
2024-06-15 02:04:08 +08:00
|
|
|
struct TabDateTime: sqlpp::table_t<TabDateTime,
|
|
|
|
TabDateTime_::Id,
|
|
|
|
TabDateTime_::DayPointN,
|
|
|
|
TabDateTime_::TimePointN,
|
|
|
|
TabDateTime_::TimeOfDayN>
|
2015-10-29 03:52:43 +08:00
|
|
|
{
|
|
|
|
struct _alias_t
|
|
|
|
{
|
2024-06-15 02:04:08 +08:00
|
|
|
static constexpr const char _literal[] = "tab_date_time";
|
2015-10-29 03:52:43 +08:00
|
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
2024-06-15 02:04:08 +08:00
|
|
|
template<typename T>
|
2015-10-29 03:52:43 +08:00
|
|
|
struct _member_t
|
|
|
|
{
|
|
|
|
T tabDateTime;
|
2024-06-15 02:04:08 +08:00
|
|
|
T& operator()() { return tabDateTime; }
|
|
|
|
const T& operator()() const { return tabDateTime; }
|
2015-10-29 03:52:43 +08:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-06-15 02:04:08 +08:00
|
|
|
} // namespace test
|