MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / columnConstraintSQL

Function columnConstraintSQL

pkg/formatter/render.go:1466–1485  ·  view source on GitHub ↗

columnConstraintSQL renders a column constraint.

(c *ast.ColumnConstraint)

Source from the content-addressed store, hash-verified

1464
1465// columnConstraintSQL renders a column constraint.
1466func columnConstraintSQL(c *ast.ColumnConstraint) string {
1467 switch c.Type {
1468 case "NOT NULL", "UNIQUE", "PRIMARY KEY":
1469 return c.Type
1470 case "DEFAULT":
1471 return "DEFAULT " + exprSQL(c.Default)
1472 case "REFERENCES":
1473 if c.References != nil {
1474 return referenceSQL(c.References)
1475 }
1476 return "REFERENCES"
1477 case "CHECK":
1478 return "CHECK (" + exprSQL(c.Check) + ")"
1479 default:
1480 if c.AutoIncrement {
1481 return "AUTO_INCREMENT"
1482 }
1483 return c.Type
1484 }
1485}
1486
1487// tableConstraintSQL renders a table-level constraint.
1488func tableConstraintSQL(tc *ast.TableConstraint) string {

Callers 1

columnDefSQLFunction · 0.70

Calls 2

exprSQLFunction · 0.70
referenceSQLFunction · 0.70

Tested by

no test coverage detected