sqlpp11 icon indicating copy to clipboard operation
sqlpp11 copied to clipboard

struct sqlpp::integral has no member named ‘as’

Open slepasteur opened this issue 10 years ago • 7 comments

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?

slepasteur avatar Nov 10 '16 10:11 slepasteur

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.

rbock avatar Nov 10 '16 11:11 rbock

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.

slepasteur avatar Nov 11 '16 14:11 slepasteur

Hmm. This compiles on my machine: (foo.omega - uint32_t(17)).as(cheese)

rbock avatar Nov 11 '16 15:11 rbock

Yes but this does not: select((count(foo.omega) - uint32_t(10)).as(cheese)).from(foo)

slepasteur avatar Nov 11 '16 15:11 slepasteur

Thanks! I'll look into that.

rbock avatar Nov 11 '16 16:11 rbock

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.

rbock avatar Nov 12 '16 09:11 rbock

The new release (0.44) takes care of this.

rbock avatar Dec 26 '16 10:12 rbock