question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Update Pipeline: Use C# null semantics for WHERE clauses (concurrency tokens)

See original GitHub issue

I’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:closed
  • Created 8 years ago
  • Comments:14 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
rojicommented, Jun 16, 2016

Thanks for doing this for the RTM guys!

0reactions
divegacommented, Jun 16, 2016

Thanks for letting us know about your concerns @roji!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dealing with null in update where clause without hard- ...
The function that generates the query - it takes table name, dictionary of values for columns {column: value} and dictionary of constraints, ...
Read more >
Entity Framework Core 7 (EF7) is available today - .NET Blog
EF Core tracks changes to entities and then sends updates to the database when SaveChangesAsync is called. Changes are only sent for properties ......
Read more >
Performance Improvements in .NET 7
NET 7 is fast. Really fast. This post deep-dives into hundreds of performance improvements that contributed to that reality.
Read more >
RefinedC: Automating the Foundational Verification of C ...
In this paper, we present RefinedC, a new approach to verifying C code that is both automated and foundational, while at the same...
Read more >
Xcode 14 Release Notes
Fixed: Xcode doesn't provide semantic highlighting and jump-to-definition support for C++20 concept declarations and the requires clauses in templates.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found