Comments (11)
Ooops! Thanks for the hint! The documentation is outdated (I'll update asap).
Please try
s.where.add(true).
See also tests/Select.cpp
from sqlpp11.
Updated the documentation.
from sqlpp11.
I just found the test/Select.cpp and the solution you just pointed out. :)
I also had problems with dynamic_offset and dynamic_limit but solved them using the new syntax:
s.offset.set(start)
s.limit.set(count)
However I still have problems with the order_by statement. My query looks like this:
auto s = dynamic_select(m_db, all_of(sql_entry))
.from(entry)
.order_by(entry.time.desc())
.dynamic_where().dynamic_offset().dynamic_limit();
Any idea on what I've done wrong?
from sqlpp11.
Hum it compiles with the dynamic_order_by, I suppose it is not possible to use static order_by on a dynamic_select?
from sqlpp11.
Thanks for the report. That's a bug, it also affects several other clauses.
Fixed in develop.
from sqlpp11.
Oh great thanks. BTW it would be great to have a simple doc on dynamic insert. I managed to use them but had some trouble to find that I needed to use insert_list.add
.
from sqlpp11.
Good point :-)
In that context: It would be great if you could send a short description of how and why you use the dynamic versions of the queries.
from sqlpp11.
Well it's pretty simple. I have a class Entry with some boost::optional data in it. I insert the Entry instances in a table but I want to insert the optional data only if they are present. It looks like that:
class Entry
{
//...
int64_t time;
boost::optional<std::string> data;
}
void insert(const Entry& entry)
{
auto i = dynamic_insert_into(m_db, sql_entry).dynamic_set(
sql_entry.time = entry.time
);
if (entry.data())
{
i.insert_list.add(sql_entry.data = entry.data().get());
}
m_db(i);
}
from sqlpp11.
I also wanted to limit the number of entries in the table. Therefore I wanted to execute a request looking like that:
delete from entry
where id in (
select id from entry
order by entry.time asc
limit (
select case when count(*) - 800 > 0 then count(*) - 800 else 0 end from entry
)
);
However I did not find any IN operator. Is is possible to do something like that with sqlpp11?
(maybe I should have opened a new issue for that...)
from sqlpp11.
Yes, please open an new issue about missing documentation. In short, you can do
tab.x.in(1,2,3)
tab.x.in(select(whatever))
tab.x.in(sqlpp::value_list(a_vector_of_values))
from sqlpp11.
Fixed dynamic statement issues in release 0.35
from sqlpp11.
Related Issues (20)
- how to get a column by string? HOT 2
- how can I use a in where condition,I always get an error? HOT 4
- mingw64, vcpkg, CMake, Project installation cannot find mariadb ? HOT 5
- sqlite connector: execute() silently ignores statements after the first one HOT 7
- how to use binary equal in where HOT 2
- Is there any opentracing support in sqlpp,like jaeger?Will it be supported in the future? HOT 1
- how to fix update exception? HOT 23
- How to retrieve the row count of a query result? HOT 6
- mysql does not seem to support the TIME type HOT 4
- Multiple table query error HOT 3
- Mysql prepared_statement.h missing _bind_time_of_day_parameter function HOT 3
- How do I get record with count of references from one to many? HOT 4
- Handling of `::sqlpp::tag::enforce_null_result_treatment` does not seem to be implemented, NULL documentation is erroneous HOT 11
- scripts/sqlite2cpp.py requires insert of nullable column HOT 6
- [Feedback Requested] Results returning optional, string_view, and span HOT 22
- [requesting assistance] Can the same parameter be used in multiple places in the same prepared statement? HOT 13
- [Need assistance] Common Table Expressions with update HOT 2
- Can't find how to use count(1) HOT 3
- head file include question HOT 3
- how to predict const struct sqlpp::result_row_t is or not NULL? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqlpp11.