-
Notifications
You must be signed in to change notification settings - Fork 103
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
Add validation to Insert statement parsing to match the column names with supplied values #3070
base: main
Are you sure you want to change the base?
Conversation
Result of fdb-record-layer-pr on Linux CentOS 7
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also fix up the title of the PR and add a more comprehensive description?
...java/com/apple/foundationdb/relational/recordlayer/ddl/DdlRecordLayerSchemaTemplateTest.java
Outdated
Show resolved
Hide resolved
...al-core/src/test/java/com/apple/foundationdb/relational/recordlayer/RelationalArrayTest.java
Outdated
Show resolved
Hide resolved
// This phenomenon is also true with basic types, i.e., non-nullability is not enforced and is tracked by | ||
// TODO (Add support + tests for column nullable/not null) | ||
insertQuery("INSERT INTO T (pk) VALUES (4)"); | ||
Assert.assertThrows(SQLException.class, () -> insertQuery("INSERT INTO T (pk) VALUES (4)")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use RelationalAssertions.assertThrowsSqlException
that allows you to check for the error message and SQLState?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you check the SQLState as well?
RelationalAssertions.assertThrowsSqlException
has a method withErrorCode
or something like this that you can use.
...al-core/src/test/java/com/apple/foundationdb/relational/recordlayer/RelationalArrayTest.java
Outdated
Show resolved
Hide resolved
...al-core/src/test/java/com/apple/foundationdb/relational/recordlayer/RelationalArrayTest.java
Outdated
Show resolved
Hide resolved
...al-core/src/test/java/com/apple/foundationdb/relational/recordlayer/RelationalArrayTest.java
Outdated
Show resolved
Hide resolved
...al-core/src/test/java/com/apple/foundationdb/relational/recordlayer/RelationalArrayTest.java
Outdated
Show resolved
Hide resolved
...al-core/src/test/java/com/apple/foundationdb/relational/recordlayer/RelationalArrayTest.java
Outdated
Show resolved
Hide resolved
Result of fdb-record-layer-pr on Linux CentOS 7
|
cddee53
to
e5cd8c2
Compare
Result of fdb-record-layer-pr on Linux CentOS 7
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two small comments, then I think this one can come in.
Good work!
- | ||
# Case when the number of values is more than the number of columns specified. | ||
- query: insert into A(A1, A2, A3) values (5, 6, 7, 8, 9); | ||
- supported_version: !current_version | ||
- error: "42601" | ||
- | ||
# Case when a nullable column's value is not provided |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to cover that, could you add a test where the not provided column is the first one and another case where it's the last one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
fixes #3069. This PR also provide a short-term solution to #3068
In essence, it does the following things:
INSERT
statement but its value is not provided.INSERT
statement is not equal to the number of values provided for a rowINSERT
statement or its value is not providedARRAY
) asNOT NULL
in the DDL since this feature is not fully supported throughout.DEFAULT
}