(major, minor int)
| 282 | } |
| 283 | |
| 284 | func mysqlVersionAtLeast(major, minor int) bool { |
| 285 | if !isMysql() { |
| 286 | return false |
| 287 | } |
| 288 | |
| 289 | var version string |
| 290 | if err := DB.Raw("SELECT VERSION()").Row().Scan(&version); err != nil { |
| 291 | return false |
| 292 | } |
| 293 | |
| 294 | base := strings.SplitN(strings.TrimSpace(version), "-", 2)[0] |
| 295 | parts := strings.Split(base, ".") |
| 296 | if len(parts) < 2 { |
| 297 | return false |
| 298 | } |
| 299 | |
| 300 | currentMajor, err := strconv.Atoi(parts[0]) |
| 301 | if err != nil { |
| 302 | return false |
| 303 | } |
| 304 | |
| 305 | currentMinor, err := strconv.Atoi(parts[1]) |
| 306 | if err != nil { |
| 307 | return false |
| 308 | } |
| 309 | |
| 310 | if currentMajor != major { |
| 311 | return currentMajor > major |
| 312 | } |
| 313 | |
| 314 | return currentMinor >= minor |
| 315 | } |
| 316 | |
| 317 | func isSqlite() bool { |
| 318 | return os.Getenv("GORM_DIALECT") == "sqlite" |
no test coverage detected