Update Pipeline: Use C# null semantics for WHERE clauses (concurrency tokens)
See original GitHub issueI’m having some OptimisticConcurrency tests fail because the following SQL gets sent to the database:
UPDATE "Drivers" SET "Podiums" = $1 WHERE "Id" = $2 AND "Version" = $3 RETURNING "Version"
with $3 being equal to null.
This may work in other databases, but PostgreSQL always returns false for = NULL
even when using a parameter. Now I can see that in a select query EF generates different SQL (IS NULL vs. equality operator) based on whether the parameter is null or not (I wonder how this interacts with caching, do you key on the nullness of parameters?). However, this logic seems to be totally absent from UpdateSqlGenerator, where the equality operator is always used.
Any tips on how to proceed? I could override AppendWhereCondition
and use PostgreSQL’s IS NOT DISTINCT FROM
as a workaround (it’s like the equality operator except it returns true for nulls). I could also test the ColumnModification’s Value
and generate IS NULL
or equality based on that (although is the update SQL cached somewhere?).
However, this seems like something that needs to be handled outside the provider in Relational… Ideally, shouldn’t the code generating where clauses (and perhaps other SQL components) be shared between query generation and modification generation?
Issue Analytics
- State:
- Created 8 years ago
- Comments:14 (14 by maintainers)
Top GitHub Comments
Thanks for doing this for the RTM guys!
Thanks for letting us know about your concerns @roji!