SOCI/soci

Sqlite3 get_affected_rows() does not work

wakille opened this issue · 2 comments

Hello,
when using soci with the sqlite3 backend, I ran in following issue: get_affected_rows() always returns 0.

soci::statement st = (sql.prepare << "UPDATE v_generic_values SET generic_value='" << generic_value << "' WHERE var_id='" << var_id << "'");
st.execute(true);
auto debug = st.get_affected_rows()

From my perspective this looks like a bug. I also found the still open bug report #725 from 2019 concerning this issue.

Thanks!

zann1x commented

I really don't understand when this issue should arise (which it seemingly does) because I can neither reproduce it locally nor do the existing tests (https://github.com/SOCI/soci/blob/924d990f8f4b253e9f7897c92dccfd4c814f569e/tests/common-tests.h#L4806L-L4891) seem to catch such behavior. Even executing the exact same code from #725 doesn't fail on my machine.
It would be great if you could try to dig into the issue yourself and share your findings back here!

My problem is, that I edit a view and intercept the command with INSTEAD OF. sqlite3_changes() does not support this (https://www.sqlite.org/c3ref/changes.html). So no issue by soci. But maybe consider taking this hint to your documentation.