struct sqlpp::integral has no member named ‘as’
I updated sqlpp11 version and a statement that was previously working is failing to compile.error:
‘sqlpp::return_type_minus_t<sqlpp::count_t<sqlpp::noop,` sqlpp::column_t<sdn_sql::Entry, sdn_sql::Entry_::Id> >, unsigned int> {aka struct sqlpp::integral}’ has no member named ‘as’
for (const auto& row : m_db(select((count(sql_entry.id) - m_maxEntries).as(row_limit)).from(sql_entry).where(true)))
I checked the wiki but my statement seems similar to the one on the wiki:
db(select(((foo.id + 17) * 4).as(foo.id)).from(tab))
Has something changed in the way we are supposed to write such statements?
That compile error is rather unexpected. The type of the expression count(sql_entry.id) - m_maxEntries should not be sqlpp::integral. It should be sqlpp::binary_expression_t<Something>.
However, I haven't been able to reproduce the problem.
I tested a bunch of expressions, including (count(foo.omega) - 42).as(cheese).
The only error I would expect from your code would be about the .where(true). That needs to be replaced with .unconditionally() in newer versions. But the error message would be rather clear about this.
Using the tables from tests/TabSample.h can you reproduce the bug?
Depending on how old your previous version was: Maybe you need to update the script that generates the table definitions.
I found the problem. The type of m_maxEntries was uint32_t (which indeed might not be a good idea). If I change it to int everything compiles correctly.
Hmm. This compiles on my machine: (foo.omega - uint32_t(17)).as(cheese)
Yes but this does not: select((count(foo.omega) - uint32_t(10)).as(cheese)).from(foo)
Thanks! I'll look into that.
Found it. A bug in the implementation of signed/unsigned operators.
It is fixed in the develop branch now. If you're using MSVC, it probably won't compile for you. I'll take care of that some time soon, I hope.
The new release (0.44) takes care of this.