ulib/3party/sqlpp11/docs/New-Features.md
tqcq 9ec8eb952e
All checks were successful
rpcrypto-build / build (Release, hisiv510.toolchain.cmake) (push) Successful in 1m11s
rpcrypto-build / build (Debug, hisiv510.toolchain.cmake) (push) Successful in 1m22s
rpcrypto-build / build (Release, himix200.toolchain.cmake) (push) Successful in 1m27s
rpcrypto-build / build (Debug, himix200.toolchain.cmake) (push) Successful in 1m29s
linux-x64-gcc / linux-gcc (push) Successful in 1m55s
linux-hisiv500-gcc / linux-gcc-hisiv500 (push) Successful in 3m17s
rpcrypto-build / build (Release, hisiv510.toolchain.cmake) (pull_request) Successful in 1m9s
rpcrypto-build / build (Debug, himix200.toolchain.cmake) (pull_request) Successful in 1m14s
rpcrypto-build / build (Debug, hisiv510.toolchain.cmake) (pull_request) Successful in 1m20s
linux-x64-gcc / linux-gcc (pull_request) Successful in 1m24s
linux-mips64-gcc / linux-gcc-mips64el (push) Successful in 4m26s
linux-mips64-gcc / linux-gcc-mips64el (pull_request) Successful in 1m43s
rpcrypto-build / build (Release, himix200.toolchain.cmake) (pull_request) Successful in 1m55s
linux-hisiv500-gcc / linux-gcc-hisiv500 (pull_request) Successful in 4m8s
fix use mirror repository of date
2024-01-06 21:51:10 +08:00

59 lines
1.9 KiB
Markdown

# New Features
There are a bunch of new features, that are not fully documented yet. If you would like to contribute documentation, please let me know.
## Preprocessor generator for columns/tables
You'll need boost 1.50 or greater to use this feature by niXman:
```C++
#include <sqlpp11/ppgen.h>
SQLPP_DECLARE_TABLE(
(tab_person)
,
(id , int , SQLPP_AUTO_INCREMENT)
(name , varchar(255), SQLPP_NOT_NULL )
(feature, int , SQLPP_NOT_NULL )
)
```
See `examples/ppgen.hpp`.
## Union
Unions are now supported. The arguments need to have the same names and types in their columns.
```C++
db(select(t.alpha).from(t).where(true)
.union_distinct(select(f.epsilon.as(t.alpha)).from(f).where(true)));
db(select(t.alpha).from(t).where(true)
.union_all(select(f.epsilon.as(t.alpha)).from(f).where(true)));
```
## With
sqlpp11 supports common table expressions:
```C++
auto x = sqlpp::cte(sqlpp::alias::x).as(select(all_of(t)).from(t));
db(with(x)(select(x.alpha).from(x).where(true)));
```
## Custom Queries
This allows you to combine building blocks of sqlpp11 into custom queries, for instance a SELECT..INTO which is not supported yet.
```C++
// A custom (select ... into) with adjusted return type
// The first argument with a return type is the select,
// but the custom query is really an insert. Thus, we tell it so.
db(custom_query(select(all_of(t)).from(t), into(f))
.with_result_type_of(insert_into(f)));
```
## Schema-qualified tables
sqlpp11 assumes that you're connection addresses one database, normally. But you can tell it about other databases using the `sqlpp::schema_t` and instantiating schema-qualified tables with it:
```C++
auto schema = db.attach("lorem_ipsum");
auto s = schema_qualified_table(schema, TabSample{}).as(sqlpp::alias::x)
// s now represents "lorem_ipsum.tab_sample as x"
// s can be used like any other table in the code
```