diff --git a/go/libraries/doltcore/sqle/expranalysis/expranalysis.go b/go/libraries/doltcore/sqle/expranalysis/expranalysis.go index df9f42255a3..196f5b3c354 100644 --- a/go/libraries/doltcore/sqle/expranalysis/expranalysis.go +++ b/go/libraries/doltcore/sqle/expranalysis/expranalysis.go @@ -63,7 +63,10 @@ func ResolveCheckExpression(ctx *sql.Context, tableName string, sch schema.Schem } for _, check := range ct.Checks() { - if stripTableNamesFromExpression(check.Expr).String() == checkExpr { + // Check definitions created before v1.55.3 may not have backquotes around identifiers + quotedExpr := stripTableNamesFromExpression(check.Expr, true).String() + unquotedExpr := stripTableNamesFromExpression(check.Expr, false).String() + if quotedExpr == checkExpr || unquotedExpr == checkExpr { return check.Expr, nil } } @@ -71,10 +74,10 @@ func ResolveCheckExpression(ctx *sql.Context, tableName string, sch schema.Schem return nil, fmt.Errorf("unable to find check expression") } -func stripTableNamesFromExpression(expr sql.Expression) sql.Expression { +func stripTableNamesFromExpression(expr sql.Expression, quoted bool) sql.Expression { e, _, _ := transform.Expr(expr, func(e sql.Expression) (sql.Expression, transform.TreeIdentity, error) { if col, ok := e.(*expression.GetField); ok { - return col.WithTable("").WithQuotedNames(sql.GlobalSchemaFormatter, true), transform.NewTree, nil + return col.WithTable("").WithQuotedNames(sql.GlobalSchemaFormatter, quoted), transform.NewTree, nil } return e, transform.SameTree, nil }) diff --git a/integration-tests/compatibility/test_files/backward_compatible_versions.txt b/integration-tests/compatibility/test_files/backward_compatible_versions.txt index 560ad74c455..36c6c9f45b8 100644 --- a/integration-tests/compatibility/test_files/backward_compatible_versions.txt +++ b/integration-tests/compatibility/test_files/backward_compatible_versions.txt @@ -1,3 +1,4 @@ +v1.55.3 v1.7.0 v1.6.0 v1.5.0 diff --git a/integration-tests/compatibility/test_files/bats/compatibility.bats b/integration-tests/compatibility/test_files/bats/compatibility.bats index 0d8aacc5f42..b63709b9c64 100755 --- a/integration-tests/compatibility/test_files/bats/compatibility.bats +++ b/integration-tests/compatibility/test_files/bats/compatibility.bats @@ -206,3 +206,8 @@ EOF dolt sql -q 'drop table abc2' } + +@test "dolt merge with check constraints" { + run dolt merge check_merge + [ "$status" -eq 0 ] +} diff --git a/integration-tests/compatibility/test_files/setup_repo.sh b/integration-tests/compatibility/test_files/setup_repo.sh index 6e4772708a1..227f3aad282 100755 --- a/integration-tests/compatibility/test_files/setup_repo.sh +++ b/integration-tests/compatibility/test_files/setup_repo.sh @@ -36,6 +36,11 @@ CREATE TABLE big ( pk int PRIMARY KEY, str longtext ); + +CREATE TABLE def ( + i INT check (i > 0) +); +INSERT INTO def VALUES (1), (2), (3); SQL dolt sql < "../../test_files/big_table.sql" # inserts 1K rows to `big` dolt add . @@ -54,6 +59,8 @@ SQL dolt add . dolt commit -m "made changes to $DEFAULT_BRANCH" +dolt branch check_merge + dolt checkout other dolt sql <