MCPcopy Create free account
hub / github.com/araddon/qlbridge / TestSqlCreate

Function TestSqlCreate

rel/parse_sql_test.go:634–660  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

632}
633
634func TestSqlCreate(t *testing.T) {
635 t.Parallel()
636 sql := `
637 CREATE TABLE articles
638 (
639 ID int(11) NOT NULL AUTO_INCREMENT,
640 Email char(150) NOT NULL DEFAULT '' COMMENT "email hello",
641 PRIMARY KEY (ID),
642 CONSTRAINT emails_fk FOREIGN KEY (Email) REFERENCES Emails (Email) COMMENT "hello constraint"
643 ) ENGINE=InnoDB AUTO_INCREMENT=4080 DEFAULT CHARSET=utf8
644 WITH stuff = "hello";`
645 req, err := rel.ParseSql(sql)
646 assert.Equal(t, nil, err)
647 assert.NotEqual(t, nil, req)
648 cs, ok := req.(*rel.SqlCreate)
649 assert.True(t, ok, "wanted SqlCreate got %T", req)
650 assert.Equal(t, lex.TokenCreate, cs.Keyword(), "Has keyword CREATE")
651 assert.Equal(t, "TABLE", cs.Tok.V, "Wanted TABLE: got %q", cs.Tok.V)
652 assert.Equal(t, "articles", cs.Identity, "has articles: %v", cs.Identity)
653 //assert.True(t, len(up.Values) == 2, "%v", up)
654 assert.Equal(t, len(cs.Cols), 4, "Has 4 cols?")
655
656 c2 := cs.Cols[1]
657 assert.Equal(t, "email hello", c2.Comment, "%+v", c2)
658 assert.Equal(t, "char", c2.DataType, "%+v", c2)
659 assert.Equal(t, 150, c2.DataTypeSize, "%+v", c2)
660}
661
662func TestSqlDrop(t *testing.T) {
663 t.Parallel()

Callers

nothing calls this directly

Calls 3

ParseSqlFunction · 0.92
EqualMethod · 0.65
KeywordMethod · 0.65

Tested by

no test coverage detected