0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-15 20:31:16 +08:00

Merge pull request #228 from niXman/develop

real type support added for ppgen
This commit is contained in:
Roland Bock 2018-04-13 08:49:40 +02:00 committed by GitHub
commit d2dc3124fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 5 deletions

View File

@ -34,6 +34,11 @@
#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_float(...) \ #define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_float(...) \
::sqlpp::floating_point ::sqlpp::floating_point
#define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_real \
PROC_real
#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_real(...) \
::sqlpp::floating_point
#define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_double \ #define SQLPP_DECLARE_COLUMN_GET_TRAITS_LAZY_double \
PROC_double PROC_double
#define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_double(...) \ #define SQLPP_DECLARE_COLUMN_GEN_TRAITS_PROC_double(...) \

View File

@ -52,6 +52,7 @@ SQLPP_DECLARE_TABLE(
(id , int , SQLPP_PRIMARY_KEY) (id , int , SQLPP_PRIMARY_KEY)
(name , varchar(255), SQLPP_NOT_NULL ) (name , varchar(255), SQLPP_NOT_NULL )
(feature, int , SQLPP_NOT_NULL ) (feature, int , SQLPP_NOT_NULL )
(level , real , SQLPP_NOT_NULL )
) )
SQLPP_DECLARE_TABLE( SQLPP_DECLARE_TABLE(
@ -76,14 +77,21 @@ int Ppgen(int, char* [])
db(insert_into(f).default_values()); db(insert_into(f).default_values());
auto i = insert_into(p).columns(p.name, p.feature); auto i = insert_into(p).columns(p.name, p.feature, p.level);
i.values.add(p.name = "Roland", p.feature = 1); i.values.add(p.name = "Roland", p.feature = 1, p.level = 3.14);
i.values.add(p.name = "Zaphod", p.feature = sqlpp::default_value); i.values.add(p.name = "Zaphod", p.feature = sqlpp::default_value, p.level = 3.14*2);
db(i); db(i);
auto pi = db.prepare(insert_into(p).set(p.name = parameter(f.name), p.feature = parameter(p.feature))); auto pi = db.prepare(
insert_into(p).set(
p.name = parameter(f.name)
,p.feature = parameter(p.feature)
,p.level = parameter(p.level)
)
);
pi.params.name = "likes java"; pi.params.name = "likes java";
pi.params.feature = true; pi.params.feature = 2;
pi.params.level = 3.14;
db(pi); db(pi);
return 0; return 0;