Bug #101294 Invalid query generated for new entity without any values results in exception
| Submitted: | 23 Oct 2020 16:54 | Modified: | 24 Oct 2020 14:39 |
|---|---|---|---|
| Reporter: | Foo Bar | Email Updates: | |
| Status: | Verified | Impact on me: | |
| Category: | Connector / NET | Severity: | S3 (Non-critical) |
| Version: | 8.0.22, 8.0.23 | OS: | Linux (Gentoo) |
| Assigned to: | CPU Architecture: | Other (x64) |
[23 Oct 2020 16:54]
Foo Bar
[24 Oct 2020 14:39]
MySQL Verification Team
Hello! Thank you for the report and feedback. regards, Umesh
[25 Mar 2021 13:18]
MySQL Verification Team
Bug #103049 marked as duplicate of this one.
[19 May 2023 20:28]
Søren Nielsen
Can be worked around by using a DbCommandInterceptor:
--------------------------------------------------------
using Microsoft.EntityFrameworkCore.Diagnostics;
using System.Data.Common;
public class MySqlDefaultValuesInterceptor : DbCommandInterceptor
{
public override InterceptionResult<DbDataReader> ReaderExecuting(DbCommand command, CommandEventData eventData, InterceptionResult<DbDataReader> result)
{
if (command.CommandText.Contains("DEFAULT VALUES()"))
{
command.CommandText = command.CommandText.Replace("DEFAULT VALUES()", "VALUES()");
}
return result;
}
}
--------------------------------------------------------
And then in your DbContext:
--------------------------------------------------------
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.AddInterceptors(new MySqlDefaultValuesInterceptor());
base.OnConfiguring(optionsBuilder);
}
--------------------------------------------------------
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.054 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.