(checkA *CheckDefinition, checkB *CheckDefinition)
| 5012 | } |
| 5013 | |
| 5014 | func (g *Generator) areSameCheckDefinition(checkA *CheckDefinition, checkB *CheckDefinition) bool { |
| 5015 | if checkA == nil && checkB == nil { |
| 5016 | return true |
| 5017 | } |
| 5018 | if checkA == nil || checkB == nil { |
| 5019 | return false |
| 5020 | } |
| 5021 | |
| 5022 | normalizedA := normalizeCheckExpr(checkA.definition, g.mode) |
| 5023 | normalizedB := normalizeCheckExpr(checkB.definition, g.mode) |
| 5024 | |
| 5025 | // Unwrap outermost parentheses if present (MySQL adds extra parens) |
| 5026 | normalizedA = unwrapOutermostParenExpr(normalizedA) |
| 5027 | normalizedB = unwrapOutermostParenExpr(normalizedB) |
| 5028 | |
| 5029 | return parser.String(normalizedA) == parser.String(normalizedB) && |
| 5030 | checkA.notForReplication == checkB.notForReplication && |
| 5031 | checkA.noInherit == checkB.noInherit |
| 5032 | } |
| 5033 | |
| 5034 | // unwrapOutermostParenExpr removes the outermost ParenExpr if the expression is wrapped in one. |
| 5035 | // This is needed because some databases (like MySQL) add extra parentheses around CHECK expressions. |
no test coverage detected