-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Query never returns when DB value for column mapped to primitive collection is '' #32896
Comments
@ajcvickers Just wondering, should something be done about the migrations generated when adding a new primitive collection? |
@sindrekroknes Thanks for pointing this out. We should not be generating the empty string by default for primitive collection columns. /cc @roji @maumar |
I have not been able to reproduce this. I see |
@sindrekroknes Got it. It happens when the table already exists and then a primitive collection column is added: protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Stuff",
table: "Joins",
type: "TEXT",
nullable: false,
defaultValue: "");
} |
@ajcvickers Oh. Yeah, should have made that more clear. It's only when adding new columns to an existing entity |
Ah yeah, this was actually raised for EFCore.PG: npgsql/efcore.pg#2965, and was fixed for 8.0.0 (the PG case is different, since the database type is actually JSON, and rejects empty strings). Should have thought about the general case in EF. |
@ajcvickers should we track the migration problem in another issue? |
@roji Yeah, I think so. |
Problem
When using EF to query an entity that has a primitive collection property the query never returns if the database value of the column is ''
The database query appears to execute successfully, but nothing more happens. The method never returns.
This is the last thing logged, even with LogLevel set to Trace:
Encountered this when adding a new column to an existing table. The generated migration sets the default value to ''
Tested with different collection types and primitives, Sqlite/SqlServer, and sync/async. Same result for everything I tested with.
Update: Left the repro running over night, the FirstAsync method has still not returned.
Repro code
Include provider and version information
EF Core version: 8.0.1
Database provider: tested with Microsoft.EntityFrameworkCore.SqlServer and Microsoft.EntityFrameworkCore.Sqlite
Target framework: .NET 8.0)
Operating system: Windows 11
IDE: VS Code
The text was updated successfully, but these errors were encountered: