MCPcopy
hub / github.com/sqldef/sqldef / areSameCheckDefinition

Method areSameCheckDefinition

schema/generator.go:5014–5032  ·  view source on GitHub ↗
(checkA *CheckDefinition, checkB *CheckDefinition)

Source from the content-addressed store, hash-verified

5012}
5013
5014func (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.

Calls 3

StringFunction · 0.92
normalizeCheckExprFunction · 0.85
unwrapOutermostParenExprFunction · 0.85

Tested by

no test coverage detected