Skip to content

Commit

Permalink
support casting to year (#314)
Browse files Browse the repository at this point in the history
Co-authored-by: James Cor <[email protected]>
  • Loading branch information
jycor and James Cor authored Feb 28, 2024
1 parent d55088c commit 13c0f62
Show file tree
Hide file tree
Showing 3 changed files with 6,130 additions and 6,098 deletions.
89 changes: 61 additions & 28 deletions go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5608,64 +5608,97 @@ func TestConvert(t *testing.T) {
validSQL := []parseTest{
{
input: "select cast('abc' as date) from t",
}, {
input: "select cast('abc' as date) from t",
},
{
input: "select cast('abc' as year) from t",
},
{
input: "select cast('abc' as date) from t",
useSelectExpressionLiteral: true,
}, {
},
{
input: "select convert('abc', binary(4)) from t",
}, {
},
{
input: "select convert('abc', binary) from t",
}, {
},
{
input: "select convert('abc', char character set binary) from t",
}, {
},
{
input: "select convert('abc', char(4) ascii) from t",
}, {
},
{
input: "select convert('abc', char unicode) from t",
}, {
},
{
input: "select convert('abc', char(4)) from t",
}, {
},
{
input: "select convert('abc', char) from t",
}, {
},
{
input: "select convert('abc', nchar(4)) from t",
}, {
},
{
input: "select convert('abc', nchar) from t",
}, {
},
{
input: "select convert('abc', signed) from t",
}, {
},
{
input: "select convert('abc', signed integer) from t",
output: "select convert('abc', signed) from t",
}, {
},
{
input: "select convert('abc', signed) from t",
output: "select convert('abc', signed) from t",
}, {
},
{
input: "select convert('abc', unsigned) from t",
}, {
},
{
input: "select convert('abc', unsigned integer) from t",
output: "select convert('abc', unsigned) from t",
}, {
},
{
input: "select convert('abc', unsigned) from t",
output: "select convert('abc', unsigned) from t",
}, {
},
{
input: "select convert('abc', decimal(3, 4)) from t",
}, {
},
{
input: "select convert('abc', decimal(4)) from t",
}, {
},
{
input: "select convert('abc', decimal) from t",
}, {
},
{
input: "select convert('abc', date) from t",
}, {
},
{
input: "select convert('abc', time(4)) from t",
}, {
},
{
input: "select convert('abc', time) from t",
}, {
},
{
input: "select convert('abc', datetime(9)) from t",
}, {
},
{
input: "select convert('abc', datetime) from t",
}, {
},
{
input: "select convert('abc', json) from t",
}, {
},
{
input: "select convert('abc' using ascii) from t",
}}
},
{
input: "select convert('abc', year) from t",
},
}

for _, tcase := range validSQL {
runParseTestCase(t, tcase)
Expand Down
Loading

0 comments on commit 13c0f62

Please sign in to comment.