quote table name on DESCRIBE statement (#7)

Summary:
Pull Request resolved: https://github.com/facebookincubator/ent/pull/7

avoid conflicting with reserved words (e.g. "groups" became reserved word in MySQL 8.x)

Reviewed By: alexsn

Differential Revision: D15957279

fbshipit-source-id: b6944752c7e5f6ec37119b11cc0ab8a0d7d3a7ff
This commit is contained in:
Ariel Mashraki
2019-06-23 01:48:26 -07:00
committed by Facebook Github Bot
parent 5ca9494121
commit 0e605681b2
4 changed files with 27 additions and 3 deletions

View File

@@ -257,6 +257,25 @@ func (t *TableBuilder) Query() (string, []interface{}) {
return t.b.String(), t.b.args
}
// DescribeBuilder is a query builder for `DESCRIBE` statement.
type DescribeBuilder struct {
b Builder
name string // table name.
}
// Describe returns a query builder for the `DESCRIBE` statement.
//
// Describe("users")
//
func Describe(name string) *DescribeBuilder { return &DescribeBuilder{b: Builder{}, name: name} }
// Query returns query representation of a `DESCRIBE` statement.
func (t *DescribeBuilder) Query() (string, []interface{}) {
t.b.WriteString("DESCRIBE ")
t.b.Append(t.name)
return t.b.String(), nil
}
// TableAlter is a query builder for `ALTER TABLE` statement.
type TableAlter struct {
b Builder