Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix: check constraints were being marked invalid for tables with upper case letters #376

Merged
merged 1 commit into from Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions enginetest/enginetests.go
Expand Up @@ -1889,14 +1889,14 @@ func TestCreateCheckConstraints(t *testing.T, harness Harness) {
// Check statements in CREATE TABLE statements
// TODO: <> gets parsed / serialized as NOT(=), needs to be fixed for full round trip compatibility
RunQuery(t, e, harness, `
CREATE TABLE t2
CREATE TABLE T2
(
CHECK (c1 = c2),
c1 INT CHECK (c1 > 10),
c2 INT CONSTRAINT c2_positive CHECK (c2 > 0),
c3 INT CHECK (c3 < 100),
CONSTRAINT c1_nonzero CHECK (c1 = 0),
CHECK (c1 > c3)
CHECK (C1 > C3)
);`)

table, ok, err = db.GetTableInsensitive(NewContext(harness), "t2")
Expand Down
6 changes: 5 additions & 1 deletion enginetest/memory_engine_test.go
Expand Up @@ -97,7 +97,11 @@ func TestSingleQuery(t *testing.T) {

var test enginetest.QueryTest
test = enginetest.QueryTest{
Query: "SELECT mytable.s FROM mytable WHERE mytable.i = (SELECT othertable.i2 FROM othertable WHERE othertable.s2 = 'second')",
Query: "CREATE TABLE `test_data_fUGNcRWp` (\n" +
" x FLOAT(53),\n" +
" b BOOL,\n" +
" CHECK (b IN (0, 1))\n" +
")",
Expected: []sql.Row{
{"second row"},
},
Expand Down
5 changes: 1 addition & 4 deletions sql/analyzer/check_constraints.go
Expand Up @@ -63,10 +63,7 @@ func validateCreateTableChecks(ctx *sql.Context, a *Analyzer, n *plan.CreateTabl

switch e := e.(type) {
case column:
col := tableCol{
table: e.Table(),
col: e.Name(),
}
col := newTableCol(e.Table(), e.Name())
if _, ok := columns[col]; !ok {
err = sql.ErrTableColumnNotFound.New(e.Table(), e.Name())
return false
Expand Down