Add SCHEMALESS / SCHEMAFULL support to queries
This commit is contained in:
parent
91b3b83554
commit
a16f7b2aba
4 changed files with 31 additions and 0 deletions
|
@ -155,6 +155,7 @@ type DefineTableStatement struct {
|
|||
NS string `cork:"-" codec:"-"`
|
||||
DB string `cork:"-" codec:"-"`
|
||||
What []string `cork:"-" codec:"-"`
|
||||
Full bool `cork:"full" codec:"full"`
|
||||
}
|
||||
|
||||
// RemoveTableStatement represents an SQL REMOVE TABLE statement.
|
||||
|
|
|
@ -1323,6 +1323,28 @@ func Test_Parse_Queries_Define(t *testing.T) {
|
|||
sql: `DEFINE TABLE person something`,
|
||||
err: "Found `something` but expected `EOF, ;`",
|
||||
},
|
||||
{
|
||||
sql: `DEFINE TABLE person SCHEMALESS`,
|
||||
res: &Query{Statements: []Statement{&DefineTableStatement{
|
||||
What: []string{"person"},
|
||||
Full: false,
|
||||
}}},
|
||||
},
|
||||
{
|
||||
sql: `DEFINE TABLE person SCHEMAFULL`,
|
||||
res: &Query{Statements: []Statement{&DefineTableStatement{
|
||||
What: []string{"person"},
|
||||
Full: true,
|
||||
}}},
|
||||
},
|
||||
{
|
||||
sql: `DEFINE TABLE person SCHEMALESS something`,
|
||||
err: "Found `something` but expected `EOF, ;`",
|
||||
},
|
||||
{
|
||||
sql: `DEFINE TABLE person SCHEMAFULL something`,
|
||||
err: "Found `something` but expected `EOF, ;`",
|
||||
},
|
||||
// ----------------------------------------------------------------------
|
||||
{
|
||||
sql: `DEFINE RULES`,
|
||||
|
|
|
@ -26,6 +26,10 @@ func (p *parser) parseDefineTableStatement() (stmt *DefineTableStatement, err er
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if tok, _, exi := p.mightBe(SCHEMAFULL, SCHEMALESS); exi && tok == SCHEMAFULL {
|
||||
stmt.Full = true
|
||||
}
|
||||
|
||||
if _, _, err = p.shouldBe(EOF, SEMICOLON); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -166,6 +166,8 @@ const (
|
|||
RETURN
|
||||
ROLLBACK
|
||||
RULES
|
||||
SCHEMAFULL
|
||||
SCHEMALESS
|
||||
SELECT
|
||||
SET
|
||||
SOMECONTAINEDIN
|
||||
|
@ -324,6 +326,8 @@ var tokens = [...]string{
|
|||
RETURN: "RETURN",
|
||||
ROLLBACK: "ROLLBACK",
|
||||
RULES: "RULES",
|
||||
SCHEMAFULL: "SCHEMAFULL",
|
||||
SCHEMALESS: "SCHEMALESS",
|
||||
SELECT: "SELECT",
|
||||
SET: "SET",
|
||||
SOMECONTAINEDIN: "SOMECONTAINEDIN",
|
||||
|
|
Loading…
Reference in a new issue