diff --git a/pkg/services/sqlstore/database_config_test.go b/pkg/services/sqlstore/database_config_test.go index e180051d6cf..9dd7200f379 100644 --- a/pkg/services/sqlstore/database_config_test.go +++ b/pkg/services/sqlstore/database_config_test.go @@ -31,7 +31,7 @@ var databaseConfigTestCases = []databaseConfigTest{ name: "MySQL IPv4", dbType: "mysql", dbHost: "1.2.3.4:5678", - expConnStr: ":@tcp(1.2.3.4:5678)/test_db?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&parseTime=true", + expConnStr: ":@tcp(1.2.3.4:5678)/test_db?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&parseTime=true&sql_mode='ANSI_QUOTES'", }, { name: "Postgres IPv4", @@ -65,13 +65,13 @@ var databaseConfigTestCases = []databaseConfigTest{ name: "MySQL IPv4 (Default Port)", dbType: "mysql", dbHost: "1.2.3.4", - expConnStr: ":@tcp(1.2.3.4)/test_db?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&parseTime=true", + expConnStr: ":@tcp(1.2.3.4)/test_db?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&parseTime=true&sql_mode='ANSI_QUOTES'", }, { name: "MySQL IPv6", dbType: "mysql", dbHost: "[fe80::24e8:31b2:91df:b177]:1234", - expConnStr: ":@tcp([fe80::24e8:31b2:91df:b177]:1234)/test_db?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&parseTime=true", + expConnStr: ":@tcp([fe80::24e8:31b2:91df:b177]:1234)/test_db?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&parseTime=true&sql_mode='ANSI_QUOTES'", }, { name: "Postgres IPv6", @@ -83,7 +83,7 @@ var databaseConfigTestCases = []databaseConfigTest{ name: "MySQL IPv6 (Default Port)", dbType: "mysql", dbHost: "[::1]", - expConnStr: ":@tcp([::1])/test_db?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&parseTime=true", + expConnStr: ":@tcp([::1])/test_db?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&parseTime=true&sql_mode='ANSI_QUOTES'", }, { name: "Postgres IPv6 (Default Port)", @@ -96,13 +96,6 @@ var databaseConfigTestCases = []databaseConfigTest{ dbURL: "://invalid.com/", err: &url.Error{Op: "parse", URL: "://invalid.com/", Err: errors.New("missing protocol scheme")}, }, - { - name: "MySQL with ANSI_QUOTES mode", - dbType: "mysql", - dbHost: "[::1]", - features: featuremgmt.WithFeatures(), - expConnStr: ":@tcp([::1])/test_db?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&parseTime=true&sql_mode='ANSI_QUOTES'", - }, } func TestIntegrationSQLConnectionString(t *testing.T) { diff --git a/pkg/services/sqlstore/sqlstore_test.go b/pkg/services/sqlstore/sqlstore_test.go index 1d17a4066e0..05fe230ee12 100644 --- a/pkg/services/sqlstore/sqlstore_test.go +++ b/pkg/services/sqlstore/sqlstore_test.go @@ -85,19 +85,19 @@ func TestInitEngine_ParseTimeInConnectionString(t *testing.T) { name: "MySQL with parseTime already present", connectionString: "mysql://user:password@localhost:3306/alreadypresent?parseTime=false", dbType: "mysql", - expectedConnection: "user:password@tcp(localhost:3306)/alreadypresent?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&parseTime=true&parseTime=false", + expectedConnection: "user:password@tcp(localhost:3306)/alreadypresent?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&parseTime=true&sql_mode='ANSI_QUOTES'&parseTime=false", }, { name: "MySQL with feature enabled", connectionString: "mysql://user:password@localhost:3306/existingparams?charset=utf8", dbType: "mysql", - expectedConnection: "user:password@tcp(localhost:3306)/existingparams?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&parseTime=true&charset=utf8", + expectedConnection: "user:password@tcp(localhost:3306)/existingparams?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&parseTime=true&sql_mode='ANSI_QUOTES'&charset=utf8", }, { name: "MySQL with feature enabled", connectionString: "mysql://user:password@localhost:3306/existingparams?charset=utf8", dbType: "mysqlWithHooks", - expectedConnection: "user:password@tcp(localhost:3306)/existingparams?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&parseTime=true&charset=utf8", + expectedConnection: "user:password@tcp(localhost:3306)/existingparams?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&parseTime=true&sql_mode='ANSI_QUOTES'&charset=utf8", }, { name: "Postgres",