Fixed propagation of NULL indicators in the soci::values::set() function#1337
Fixed propagation of NULL indicators in the soci::values::set() function#1337Innokentiy-Alaytsev wants to merge 2 commits into
Conversation
|
New tests are failing because there is an issue with query I'll look into it. |
a8706d9 to
ec5029e
Compare
|
Unfortunately, some fixes required changes to SOCI API. Nothing was removed, one member function was added. Technically, this PR fixes 2 problems instead of the one in the title. I can split the PR into 2 separate PRs if it is the way. |
|
Sorry for the delay with getting to this one. After looking at it, I agree with the main idea, i.e. we do need to preserve user-provided null indicators, but I'm not sure what exactly Even if the changes are probably correct, I'd like to understand them before applying and, ideally, have this explained in the comments in the sources. Could you please try to explain this in more details? TIA! |
ec5029e to
8a5f1e3
Compare
|
The name
I hope it makes sense. The context where I discovered the issue with positional binding might be outside of the expected use-case for # From unit tests
const INSERT_QUERY := \
"""
INSERT INTO test_02_query_insert
VALUES (:id, :string_val, :bool_val, :real_val);
"""
const ARRAY_NOT_NULL := [ 1, "From Array, with NULL", true, null ]
result = (
sql.new_query (INSERT_QUERY)
.use (ARRAY_NOT_NULL)
.execute ()
)I reckon, it should work just fine for simple one-off queries, time will tell. Even if it's a questionable approach, the problem stands: positional binding of values through |
|
Thanks for the explanation! To be honest, I'd consider just forbidding uses values and positional binding together because it doesn't seem to make much sense and we can be sure that nobody is using it, knowing that it doesn't work... But if you consider it useful enough to keep it, let's merge this PR. I still dislike the name of the new function, but I have trouble coming up with something better. Maybe we could invert the function semantics and call it something like |
Forbidding positional binding for It's up to you to decide, I'll accept any decision.
The name is bad, I agree. Maybe |
If you think it's worth having this for your bindings, I'm ready to accept it. If you don't care (enough) about it, I'd rather make things simpler by just forbidding this.
Yes, |
It's not worth it. I have my binding, yeah, but solely because it's possible to have them. Besides, I'm not sure similar approach is great for C++: it's hard to imagine that someone will implement binding for something like |
|
Thanks! You wrote before
Would you mind doing this, i.e. deleting everything except this so that at least this much reduced version could be merged? |
|
Of course, though a bit later. |
|
Sure, this is not urgent at all. TIA! |
45289a4 to
b5603b9
Compare
|
Thanks! Will merge when the Appveyor CI build finishes. |
|
Done. I kept the fix for indicator processing positional values binding for completeness. This code will be removed sometime soon, but until then it will be correct) |
The tests are expected to fail, because the value of an indicator, passed to the soci::values::set() function is replaced with the value returned from the type_conversion::to_base() function. Since it is possible that a valid value was passed alongside the i_null indicator, e.g., for setting an integer field to NULL, the type_conversion::to_base() function might return i_ok, as the default implementation of the function does. The problematic behaviour is not detected by the existing tests. Signed-off-by: Innokentiy Alaytsev <alaitsev@gmail.com>
Originally, the indicator passed by the user was copied into a stored-for-later variable. This value could have been overwritten during conversion of the bound parameter to its base type. Signed-off-by: Innokentiy Alaytsev <alaitsev@gmail.com>
3e09d90 to
bb0a2b7
Compare
…tsev/soci Fix propagation of NULL indicators in the soci::values::set() function. See #1337.
|
Oops, I've missed the force push and have merged the previous version of the PR. But AFAICS there are no changes between the original version and the latest one, so I'm closing this because everything was merged by the commit referenced above. |
|
2 last force pushes are about me pushing the "add changes from |
Originally, the indicator passed by the user was copied into a stored-for-later variable. This value could have been overwritten during conversion of the bound parameter to its base type. The fixed code preserves the value of an indicator.