mirror of https://github.com/grafana/grafana.git
				
				
				
			SQLStore: Fix parseTime check (#94175)
This commit is contained in:
		
							parent
							
								
									ee8bb63d2d
								
							
						
					
					
						commit
						4623a6471b
					
				|  | @ -289,7 +289,7 @@ func (ss *SQLStore) initEngine(engine *xorm.Engine) error { | ||||||
| 	} | 	} | ||||||
| 	if engine == nil { | 	if engine == nil { | ||||||
| 		// Ensure that parseTime is enabled for MySQL
 | 		// Ensure that parseTime is enabled for MySQL
 | ||||||
| 		if ss.features.IsEnabledGlobally(featuremgmt.FlagMysqlParseTime) && ss.dbCfg.Type == migrator.MySQL && !strings.Contains(ss.dbCfg.ConnectionString, "parseTime=") { | 		if ss.features.IsEnabledGlobally(featuremgmt.FlagMysqlParseTime) && strings.Contains(ss.dbCfg.Type, migrator.MySQL) && !strings.Contains(ss.dbCfg.ConnectionString, "parseTime=") { | ||||||
| 			if strings.Contains(ss.dbCfg.ConnectionString, "?") { | 			if strings.Contains(ss.dbCfg.ConnectionString, "?") { | ||||||
| 				ss.dbCfg.ConnectionString += "&parseTime=true" | 				ss.dbCfg.ConnectionString += "&parseTime=true" | ||||||
| 			} else { | 			} else { | ||||||
|  |  | ||||||
|  | @ -93,6 +93,13 @@ func TestInitEngine_ParseTimeInConnectionString(t *testing.T) { | ||||||
| 			featureEnabled:     true, | 			featureEnabled:     true, | ||||||
| 			expectedConnection: "user:password@tcp(localhost:3306)/existingparams?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&charset=utf8&parseTime=true", | 			expectedConnection: "user:password@tcp(localhost:3306)/existingparams?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&charset=utf8&parseTime=true", | ||||||
| 		}, | 		}, | ||||||
|  | 		{ | ||||||
|  | 			name:               "MySQL with feature enabled", | ||||||
|  | 			connectionString:   "mysql://user:password@localhost:3306/existingparams?charset=utf8", | ||||||
|  | 			dbType:             "mysqlWithHooks", | ||||||
|  | 			featureEnabled:     true, | ||||||
|  | 			expectedConnection: "user:password@tcp(localhost:3306)/existingparams?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&charset=utf8&parseTime=true", | ||||||
|  | 		}, | ||||||
| 		{ | 		{ | ||||||
| 			name:               "MySQL with feature disabled", | 			name:               "MySQL with feature disabled", | ||||||
| 			connectionString:   "mysql://user:password@localhost:3306/disabled", | 			connectionString:   "mysql://user:password@localhost:3306/disabled", | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue