2

我正在测试 mysql server 5.7.17 并且我已将 sql-mode 定义为

sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

运行其中的每一个都会给我定义的 sql-mode:

SELECT @@sql_mode;
SELECT @@GLOBAL.sql_mode;
SELECT @@SESSION.sql_mode;

但是在我的 vs2012 桌面应用程序上使用带有 EF6 的 mysql .net 连接器 6.9.8 我总是得到错误

InnerException: MySql.Data.MySqlClient.MySqlException
       HResult=-2147467259
       Message=Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'punto_dia.Id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
       Source=MySql.Data
       ErrorCode=-2147467259
       Number=1055
       StackTrace:
            en MySql.Data.MySqlClient.MySqlStream.ReadPacket()
            en MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
            en MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int64& insertedId)
            en MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
            en MySql.Data.MySqlClient.MySqlDataReader.NextResult()
            en MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
            en MySql.Data.Entity.EFMySqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
            en System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
            en System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<Reader>b__c(DbCommand t, DbCommandInterceptionContext`1 c)
            en System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
            en System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext)
            en System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavior behavior)
            en System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
            en System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)

我知道修复查询以正确使用 GROUP BY 我解决了错误,但是如果想使用与 mysql 服务器 5.6.35 一起使用的查询,为什么我不能?

sql-mode 没有定义only_full_group_by,所以我不明白为什么会出现这个错误。

有任何想法吗 ?谢谢

4

0 回答 0