Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
"select p, sum(a)" causes "a" to be converted from "long long" to "double". so row::get<double> works and row::get<long long> doesn't (std::bad_cast) #515
Debian GNU/Linux Stretch, soci 3.2.3-1+b1, Postgres 9.6.0-1, g++ 6.1.1, libstdc++ 6.2.0-13
i have table (say) "o" created using something like this:
CREATE TABLE o (..., p bigint, a bigint)
I perform something like this:
soci::rowset<soci::row> rs = (sql.prepare << "select p, sum(a) from o where ... group by p order by p asc", soci::use (...)); const auto &i = rs.begin (); i.get<long long> (0); // works (as expected) i.get<long long> (1); // fails for unknown reason with bad_cast (???) i.get<double> (1); // works (why?!)
So, as you can see, it seems SUM causes "a" to be converted from BIGINT (i. e. long long) to double and this is wrong.
Yes, I can convert back, but this (as well as I know) will cause precision loss.
If you think this is not a bug, then, please, suggest some workaround.