mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-16 21:04:15 +08:00
492 lines
14 KiB
C++
492 lines
14 KiB
C++
#pragma once
|
|
|
|
// generated by ./scripts/ddl2cpp -auto-id -with-table-creation-helper tests/postgresql/usage/Tables.sql tests/postgresql/usage/Tables test
|
|
|
|
#include <sqlpp11/core/basic/table.h>
|
|
#include <sqlpp11/data_types.h>
|
|
#include <sqlpp11/core/name/char_sequence.h>
|
|
|
|
namespace test
|
|
{
|
|
template<typename Db>
|
|
void createTabFoo(Db& db)
|
|
{
|
|
db.execute(R"+++(DROP TABLE IF EXISTS tab_foo)+++");
|
|
db.execute(R"+++(CREATE TABLE tab_foo
|
|
(
|
|
id bigserial PRIMARY KEY,
|
|
text_nn_d varchar(255) NOT NULL DEFAULT '',
|
|
int_n bigint,
|
|
double_n double precision,
|
|
bool_n bool,
|
|
blob_n bytea
|
|
))+++");
|
|
}
|
|
|
|
namespace TabFoo_
|
|
{
|
|
struct Id
|
|
{
|
|
struct _alias_t
|
|
{
|
|
static constexpr const char _literal[] = "id";
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
|
template<typename T>
|
|
struct _member_t
|
|
{
|
|
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 TextNnD
|
|
{
|
|
struct _alias_t
|
|
{
|
|
static constexpr const char _literal[] = "text_nn_d";
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
|
template<typename T>
|
|
struct _member_t
|
|
{
|
|
T textNnD;
|
|
T& operator()() { return textNnD; }
|
|
const T& operator()() const { return textNnD; }
|
|
};
|
|
};
|
|
using _traits = sqlpp::make_traits<sqlpp::text>;
|
|
};
|
|
struct IntN
|
|
{
|
|
struct _alias_t
|
|
{
|
|
static constexpr const char _literal[] = "int_n";
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
|
template<typename T>
|
|
struct _member_t
|
|
{
|
|
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
|
|
{
|
|
T doubleN;
|
|
T& operator()() { return doubleN; }
|
|
const T& operator()() const { return doubleN; }
|
|
};
|
|
};
|
|
using _traits = sqlpp::make_traits<sqlpp::floating_point, sqlpp::tag::can_be_null>;
|
|
};
|
|
struct BoolN
|
|
{
|
|
struct _alias_t
|
|
{
|
|
static constexpr const char _literal[] = "bool_n";
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
|
template<typename T>
|
|
struct _member_t
|
|
{
|
|
T boolN;
|
|
T& operator()() { return boolN; }
|
|
const T& operator()() const { return boolN; }
|
|
};
|
|
};
|
|
using _traits = sqlpp::make_traits<sqlpp::boolean, sqlpp::tag::can_be_null>;
|
|
};
|
|
struct BlobN
|
|
{
|
|
struct _alias_t
|
|
{
|
|
static constexpr const char _literal[] = "blob_n";
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
|
template<typename T>
|
|
struct _member_t
|
|
{
|
|
T blobN;
|
|
T& operator()() { return blobN; }
|
|
const T& operator()() const { return blobN; }
|
|
};
|
|
};
|
|
using _traits = sqlpp::make_traits<sqlpp::blob, sqlpp::tag::can_be_null>;
|
|
};
|
|
} // namespace TabFoo_
|
|
|
|
struct TabFoo: sqlpp::table_t<TabFoo,
|
|
TabFoo_::Id,
|
|
TabFoo_::TextNnD,
|
|
TabFoo_::IntN,
|
|
TabFoo_::DoubleN,
|
|
TabFoo_::BoolN,
|
|
TabFoo_::BlobN>
|
|
{
|
|
struct _alias_t
|
|
{
|
|
static constexpr const char _literal[] = "tab_foo";
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
|
template<typename T>
|
|
struct _member_t
|
|
{
|
|
T tabFoo;
|
|
T& operator()() { return tabFoo; }
|
|
const T& operator()() const { return tabFoo; }
|
|
};
|
|
};
|
|
};
|
|
template<typename Db>
|
|
void createTabBar(Db& db)
|
|
{
|
|
db.execute(R"+++(DROP TABLE IF EXISTS tab_bar)+++");
|
|
db.execute(R"+++(CREATE TABLE tab_bar
|
|
(
|
|
id bigserial PRIMARY KEY,
|
|
text_n varchar(255) NULL,
|
|
bool_nn bool NOT NULL DEFAULT false,
|
|
int_n int
|
|
))+++");
|
|
}
|
|
|
|
namespace TabBar_
|
|
{
|
|
struct Id
|
|
{
|
|
struct _alias_t
|
|
{
|
|
static constexpr const char _literal[] = "id";
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
|
template<typename T>
|
|
struct _member_t
|
|
{
|
|
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 TextN
|
|
{
|
|
struct _alias_t
|
|
{
|
|
static constexpr const char _literal[] = "text_n";
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
|
template<typename T>
|
|
struct _member_t
|
|
{
|
|
T textN;
|
|
T& operator()() { return textN; }
|
|
const T& operator()() const { return textN; }
|
|
};
|
|
};
|
|
using _traits = sqlpp::make_traits<sqlpp::text, sqlpp::tag::can_be_null>;
|
|
};
|
|
struct BoolNn
|
|
{
|
|
struct _alias_t
|
|
{
|
|
static constexpr const char _literal[] = "bool_nn";
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
|
template<typename T>
|
|
struct _member_t
|
|
{
|
|
T boolNn;
|
|
T& operator()() { return boolNn; }
|
|
const T& operator()() const { return boolNn; }
|
|
};
|
|
};
|
|
using _traits = sqlpp::make_traits<sqlpp::boolean>;
|
|
};
|
|
struct IntN
|
|
{
|
|
struct _alias_t
|
|
{
|
|
static constexpr const char _literal[] = "int_n";
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
|
template<typename T>
|
|
struct _member_t
|
|
{
|
|
T intN;
|
|
T& operator()() { return intN; }
|
|
const T& operator()() const { return intN; }
|
|
};
|
|
};
|
|
using _traits = sqlpp::make_traits<sqlpp::integer, sqlpp::tag::can_be_null>;
|
|
};
|
|
} // namespace TabBar_
|
|
|
|
struct TabBar: sqlpp::table_t<TabBar,
|
|
TabBar_::Id,
|
|
TabBar_::TextN,
|
|
TabBar_::BoolNn,
|
|
TabBar_::IntN>
|
|
{
|
|
struct _alias_t
|
|
{
|
|
static constexpr const char _literal[] = "tab_bar";
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
|
template<typename T>
|
|
struct _member_t
|
|
{
|
|
T tabBar;
|
|
T& operator()() { return tabBar; }
|
|
const T& operator()() const { return tabBar; }
|
|
};
|
|
};
|
|
};
|
|
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
|
|
(
|
|
day_point_n date,
|
|
time_point_n timestamp,
|
|
time_of_day_n time,
|
|
time_point_n_tz timestamp with time zone,
|
|
time_of_day_n_tz time with time zone
|
|
))+++");
|
|
}
|
|
|
|
namespace TabDateTime_
|
|
{
|
|
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
|
|
{
|
|
T dayPointN;
|
|
T& operator()() { return dayPointN; }
|
|
const T& operator()() const { return dayPointN; }
|
|
};
|
|
};
|
|
using _traits = sqlpp::make_traits<sqlpp::day_point, sqlpp::tag::can_be_null>;
|
|
};
|
|
struct TimePointN
|
|
{
|
|
struct _alias_t
|
|
{
|
|
static constexpr const char _literal[] = "time_point_n";
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
|
template<typename T>
|
|
struct _member_t
|
|
{
|
|
T timePointN;
|
|
T& operator()() { return timePointN; }
|
|
const T& operator()() const { return timePointN; }
|
|
};
|
|
};
|
|
using _traits = sqlpp::make_traits<sqlpp::time_point, sqlpp::tag::can_be_null>;
|
|
};
|
|
struct TimeOfDayN
|
|
{
|
|
struct _alias_t
|
|
{
|
|
static constexpr const char _literal[] = "time_of_day_n";
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
|
template<typename T>
|
|
struct _member_t
|
|
{
|
|
T timeOfDayN;
|
|
T& operator()() { return timeOfDayN; }
|
|
const T& operator()() const { return timeOfDayN; }
|
|
};
|
|
};
|
|
using _traits = sqlpp::make_traits<sqlpp::time_of_day, sqlpp::tag::can_be_null>;
|
|
};
|
|
struct TimePointNTz
|
|
{
|
|
struct _alias_t
|
|
{
|
|
static constexpr const char _literal[] = "time_point_n_tz";
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
|
template<typename T>
|
|
struct _member_t
|
|
{
|
|
T timePointNTz;
|
|
T& operator()() { return timePointNTz; }
|
|
const T& operator()() const { return timePointNTz; }
|
|
};
|
|
};
|
|
using _traits = sqlpp::make_traits<sqlpp::time_point, sqlpp::tag::can_be_null>;
|
|
};
|
|
struct TimeOfDayNTz
|
|
{
|
|
struct _alias_t
|
|
{
|
|
static constexpr const char _literal[] = "time_of_day_n_tz";
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
|
template<typename T>
|
|
struct _member_t
|
|
{
|
|
T timeOfDayNTz;
|
|
T& operator()() { return timeOfDayNTz; }
|
|
const T& operator()() const { return timeOfDayNTz; }
|
|
};
|
|
};
|
|
using _traits = sqlpp::make_traits<sqlpp::time_of_day, sqlpp::tag::can_be_null>;
|
|
};
|
|
} // namespace TabDateTime_
|
|
|
|
struct TabDateTime: sqlpp::table_t<TabDateTime,
|
|
TabDateTime_::DayPointN,
|
|
TabDateTime_::TimePointN,
|
|
TabDateTime_::TimeOfDayN,
|
|
TabDateTime_::TimePointNTz,
|
|
TabDateTime_::TimeOfDayNTz>
|
|
{
|
|
struct _alias_t
|
|
{
|
|
static constexpr const char _literal[] = "tab_date_time";
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
|
template<typename T>
|
|
struct _member_t
|
|
{
|
|
T tabDateTime;
|
|
T& operator()() { return tabDateTime; }
|
|
const T& operator()() const { return tabDateTime; }
|
|
};
|
|
};
|
|
};
|
|
template<typename Db>
|
|
void createBlobSample(Db& db)
|
|
{
|
|
db.execute(R"+++(DROP TABLE IF EXISTS blob_sample)+++");
|
|
db.execute(R"+++(CREATE TABLE blob_sample (
|
|
id bigserial PRIMARY KEY,
|
|
data bytea
|
|
))+++");
|
|
}
|
|
|
|
namespace BlobSample_
|
|
{
|
|
struct Id
|
|
{
|
|
struct _alias_t
|
|
{
|
|
static constexpr const char _literal[] = "id";
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
|
template<typename T>
|
|
struct _member_t
|
|
{
|
|
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 Data
|
|
{
|
|
struct _alias_t
|
|
{
|
|
static constexpr const char _literal[] = "data";
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
|
template<typename T>
|
|
struct _member_t
|
|
{
|
|
T data;
|
|
T& operator()() { return data; }
|
|
const T& operator()() const { return data; }
|
|
};
|
|
};
|
|
using _traits = sqlpp::make_traits<sqlpp::blob, sqlpp::tag::can_be_null>;
|
|
};
|
|
} // namespace BlobSample_
|
|
|
|
struct BlobSample: sqlpp::table_t<BlobSample,
|
|
BlobSample_::Id,
|
|
BlobSample_::Data>
|
|
{
|
|
struct _alias_t
|
|
{
|
|
static constexpr const char _literal[] = "blob_sample";
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
|
template<typename T>
|
|
struct _member_t
|
|
{
|
|
T blobSample;
|
|
T& operator()() { return blobSample; }
|
|
const T& operator()() const { return blobSample; }
|
|
};
|
|
};
|
|
};
|
|
template<typename Db>
|
|
void createTabExcept(Db& db)
|
|
{
|
|
db.execute(R"+++(DROP TABLE IF EXISTS tab_except)+++");
|
|
db.execute(R"+++(CREATE TABLE tab_except (
|
|
int_small_n_u smallint UNIQUE,
|
|
text_short_n text CHECK( length(text_short_n) < 5 )
|
|
))+++");
|
|
}
|
|
|
|
namespace TabExcept_
|
|
{
|
|
struct IntSmallNU
|
|
{
|
|
struct _alias_t
|
|
{
|
|
static constexpr const char _literal[] = "int_small_n_u";
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
|
template<typename T>
|
|
struct _member_t
|
|
{
|
|
T intSmallNU;
|
|
T& operator()() { return intSmallNU; }
|
|
const T& operator()() const { return intSmallNU; }
|
|
};
|
|
};
|
|
using _traits = sqlpp::make_traits<sqlpp::integer, sqlpp::tag::can_be_null>;
|
|
};
|
|
struct TextShortN
|
|
{
|
|
struct _alias_t
|
|
{
|
|
static constexpr const char _literal[] = "text_short_n";
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
|
template<typename T>
|
|
struct _member_t
|
|
{
|
|
T textShortN;
|
|
T& operator()() { return textShortN; }
|
|
const T& operator()() const { return textShortN; }
|
|
};
|
|
};
|
|
using _traits = sqlpp::make_traits<sqlpp::text, sqlpp::tag::can_be_null>;
|
|
};
|
|
} // namespace TabExcept_
|
|
|
|
struct TabExcept: sqlpp::table_t<TabExcept,
|
|
TabExcept_::IntSmallNU,
|
|
TabExcept_::TextShortN>
|
|
{
|
|
struct _alias_t
|
|
{
|
|
static constexpr const char _literal[] = "tab_except";
|
|
using _name_t = sqlpp::make_char_sequence<sizeof(_literal), _literal>;
|
|
template<typename T>
|
|
struct _member_t
|
|
{
|
|
T tabExcept;
|
|
T& operator()() { return tabExcept; }
|
|
const T& operator()() const { return tabExcept; }
|
|
};
|
|
};
|
|
};
|
|
} // namespace test
|