MCPcopy
hub / github.com/XiaoMi/Gaea / TestType

Function TestType

parser/parser_test.go:2051–2088  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2049}
2050
2051func TestType(t *testing.T) {
2052 table := []testCase{
2053 // for time fsp
2054 {"CREATE TABLE t( c1 TIME(2), c2 DATETIME(2), c3 TIMESTAMP(2) );", true, "CREATE TABLE `t` (`c1` TIME(2),`c2` DATETIME(2),`c3` TIMESTAMP(2))"},
2055
2056 // for hexadecimal
2057 {"select x'0a', X'11', 0x11", true, "SELECT x'0a',x'11',x'11'"},
2058 {"select x'13181C76734725455A'", true, "SELECT x'13181c76734725455a'"},
2059 {"select x'0xaa'", false, ""},
2060 {"select 0X11", false, ""},
2061 {"select 0x4920616D2061206C6F6E672068657820737472696E67", true, "SELECT x'4920616d2061206c6f6e672068657820737472696e67'"},
2062
2063 // for bit
2064 {"select 0b01, 0b0, b'11', B'11'", true, "SELECT b'1',b'0',b'11',b'11'"},
2065 // 0B01 and 0b21 are identifiers, the following two statement could parse.
2066 // {"select 0B01", false, ""},
2067 // {"select 0b21", false, ""},
2068
2069 // for enum and set type
2070 {"create table t (c1 enum('a', 'b'), c2 set('a', 'b'))", true, "CREATE TABLE `t` (`c1` ENUM('a','b'),`c2` SET('a','b'))"},
2071 {"create table t (c1 enum)", false, ""},
2072 {"create table t (c1 set)", false, ""},
2073
2074 // for blob and text field length
2075 {"create table t (c1 blob(1024), c2 text(1024))", true, "CREATE TABLE `t` (`c1` BLOB(1024),`c2` TEXT(1024))"},
2076
2077 // for year
2078 {"create table t (y year(4), y1 year)", true, "CREATE TABLE `t` (`y` YEAR(4),`y1` YEAR)"},
2079 {"create table t (y year(4) unsigned zerofill zerofill, y1 year signed unsigned zerofill)", true, "CREATE TABLE `t` (`y` YEAR(4),`y1` YEAR)"},
2080
2081 // for national
2082 {"create table t (c1 national char(2), c2 national varchar(2))", true, "CREATE TABLE `t` (`c1` CHAR(2),`c2` VARCHAR(2))"},
2083
2084 // for json type
2085 {`create table t (a JSON);`, true, "CREATE TABLE `t` (`a` JSON)"},
2086 }
2087 RunTest(t, table, false)
2088}
2089
2090func TestPrivilege(t *testing.T) {
2091 table := []testCase{

Callers

nothing calls this directly

Calls 1

RunTestFunction · 0.85

Tested by

no test coverage detected