Unable to use server sql_mode (or to specify mine)
Posted by: Lionel Najman
Date: December 16, 2015 11:47AM

Hi,

I'm using .Net connector latest version (6.9.8 ) with entity Framework.

I've enabled strict mode in my mysql server (for example to avoid the 2038 timestamp "bug" serverside)

I've tested this strict mode sucessfully with MySQL Workbench.

My problem is that behaviour is totally ignored using .Net MySQL Connector. Enabling general log points me out that the connector is sending a session sql_mode

2015-12-16T17:21:44.438980Z 7 Query SET SESSION sql_mode='ANSI';
2015-12-16T17:21:44.438980Z 7 Query INSERT INTO

But the connector documentation doesn't tell how to enforce sql_mode with entity Framework...

Moreover My.SqlData.Entity.InsertStatement source code confirms me that there is an awfull bug!!!

public override void WriteSql(StringBuilder sql)
{
if (this.ReturningSelect != null && this.ReturningSelect.Columns.Count > 0)
{
sql.Append("SET SESSION sql_mode='ANSI';");
}
sql.Append("INSERT INTO ");
this.Target.WriteSql(sql);
if (this.Sets.Count > 0)
{
sql.Append("(");
base.WriteList(this.Sets, sql);
sql.Append(")");
}
sql.Append(" VALUES ");
sql.Append("(");
base.WriteList(this.Values, sql);
sql.Append(")");
if (this.ReturningSelect != null)
{
sql.Append(";\r\n");
this.ReturningSelect.WriteSql(sql);
}
}

sql_mode is set to ANSI, being careless of global sql_mode!!! ANSI mode should be added to global options, it must not replace global mode

(and in a perfect world we should be able to specify our session sql_mode, whild should be merged with ANSI mode!!!)

So Am I really stuck? Or is there a way to trully enable strict mode with entity Framework and the MySQL .Net Connector?

Thanks for your help...

Options: ReplyQuote


Subject
Written By
Posted
Unable to use server sql_mode (or to specify mine)
December 16, 2015 11:47AM


Sorry, you can't reply to this topic. It has been closed.

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.