New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"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

Open
safinaskar opened this Issue Nov 26, 2016 · 0 comments

Comments

Projects
None yet
1 participant
@safinaskar

safinaskar commented Nov 26, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment