lerni/silverstripe3-mysql57-fluent

此软件包已弃用且不再维护。未建议替代软件包。

为 SilverStripe 提供的补丁,以模拟 MySQL <5.7.x 的 MySQL-Mode ANSI

安装次数: 10,181

依赖关系: 0

建议者: 0

安全: 0

星级: 1

关注者: 3

分支: 0

类型:silverstripe-patch

dev-master 2018-08-23 14:34 UTC

This package is auto-updated.

Last update: 2023-04-11 01:24:04 UTC


README

要求

  • SilverStripe >3.6 <4

安装

使用 composer: composer require lerni/silverstripe3-mysql57-fluent

背景

此修复仅适用于 SS 3.x,对于 SS 4,您应更新 fluent 到 4.1 或使用 sunnysideup 在其模块中使用的配置来修复 4.x 上的相同问题 https://github.com/sunnysideup/silverstripe-mysql-5-7-fix

框架在每次数据库请求上都设置 MySQL-Mode 为 ANSI-Mode https://github.com/silverstripe/silverstripe-framework/blob/3/model/connect/MySQLDatabase.php#L45

根据 MySQL 5.7,ANSI-Mode 还包括 ONLY_FULL_GROUP_BY,而不仅仅是: REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE https://dev.mysqlserver.cn/doc/refman/5.7/en/sql-mode.html#sql-mode-combo

带有 ONLY_FULL_GROUP_BY 的排序会导致通过 fluent 翻译的字段对 DataObject 进行排序时抛出错误: [用户错误] 未捕获的 SS_DatabaseException: 无法运行查询: SELECT DISTINCT ... 这与 DISTINCT 不兼容

此模块通过修改 MySQLDatabase.php 防止上述错误。