dolthub / dolt

Dolt – Git for Data

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pomelo Entity Framework connector is not able to commit changes

awarycha opened this issue · comments

Problem exist on Dolt in Docker both dolthub/dolt-sql-server:1.38.3 and dolthub/dolt-sql-server:1.39.0 only with Pomelo connector
Pomelo.EntityFrameworkCore.MySql" Version="8.0.2", everything works if I use MySql.EntityFrameworkCore" Version="8.0.2" connector.
I tested also commit on Pomelo and Dolt dolthub/dolt-sql-server:1.34.0 and it is working fine. So I think it is regress, please confirm.

Steps to reproduce:
At the beginning of application after recreation of database scheme, I'm adding initial commit

 string sqlAddTablesQuery = $"call dolt_add('mytable1','mytable2');";
 dbContext.Database.ExecuteSqlRaw(sqlAddTablesQuery);
 dbContext.Database.ExecuteSqlRaw($"CALL DOLT_COMMIT('-a', '-m', 'Initial state','--author', 'System <system@mydomain.com>');");

Then I get the following error:

fail: Microsoft.EntityFrameworkCore.Database.Command[20102]
      Failed executing DbCommand (4ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
      CALL DOLT_COMMIT('-a', '-m', 'Initial state.','--author', 'System <system@mydomain.com>');

Exception has occurred: CLR/MySqlConnector.MySqlException
An unhandled exception of type 'MySqlConnector.MySqlException' occurred in Microsoft.EntityFrameworkCore.Relational.dll: 'error: the table(s) __DATABASE__mydb do not exist'
   at MySqlConnector.Core.ServerSession.<ReceiveReplyAsync>d__107.MoveNext()
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1.ConfiguredValueTaskAwaiter.GetResult()
   at MySqlConnector.Core.ResultSet.<ReadResultSetHeaderAsync>d__2.MoveNext()
   at MySqlConnector.MySqlDataReader.ActivateResultSet(CancellationToken cancellationToken)
   at MySqlConnector.MySqlDataReader.<InitAsync>d__111.MoveNext()
   at MySqlConnector.Core.CommandExecutor.<ExecuteReaderAsync>d__0.MoveNext()
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at MySqlConnector.MySqlCommand.<ExecuteNonQueryAsync>d__78.MoveNext()
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at MySqlConnector.MySqlCommand.ExecuteNonQuery()
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteNonQuery(RelationalCommandParameterObject parameterObject)
   at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.ExecuteSqlRaw(DatabaseFacade databaseFacade, String sql, IEnumerable`1 parameters)
   at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.ExecuteSqlRaw(DatabaseFacade databaseFacade, String sql, Object[] parameters)

Hi @awarycha, thanks for opening a new issue for this one. This looks related to a recent change @jycor made to show database level changes (e.g. a collation change) as changed tables.

Here's an even simpler repro from a dolt sql shell in a new database named may24:

show create database may24;
+----------+--------------------------------------------------------------------------------------------+
| Database | Create Database                                                                            |
+----------+--------------------------------------------------------------------------------------------+
| may24    | CREATE DATABASE `may24` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_bin */ |
+----------+--------------------------------------------------------------------------------------------+

alter database may24 collate utf8mb4_0900_ai_ci;
Query OK, 1 row affected (0.00 sec)

select * from dolt_status;
+-------------------+--------+----------+
| table_name        | staged | status   |
+-------------------+--------+----------+
| __DATABASE__may24 | false  | modified |
+-------------------+--------+----------+

call dolt_commit('-a', '-m', 'changing collation', '--author', 'system <system@domain.com>');
error: the table(s) __DATABASE__may24 do not exist

I'll follow up with @jycor and see if he can pick this one up today. It should be a quick fix.

Hey @awarycha,

Just merged a fix for this to dolt main. I had missed this particular case when adding this change.
We can cut a release for you later today or early next week.

Hi @awarycha, we have released Dolt version 1.39.1 with the fix for this issue.

Sorry for the snag on this regression, and thank you for taking the time to report it to us so we could fix it. 🙏

I hope testing your ASP.NET Core app with this new version goes smoothly! Let us know if you hit any more issues and we'll be happy to help.

Thanks for the quick fix. I am not able to test it now but I will do it on monday morning and then give you a feedback.

Verified on Dolt version 1.39.1. Works as expected. Thanks.

Hi @awarycha , we'd love to learn more about your Dolt use case. Swing by our Discord or email me if you want to share.