Documentation ¶
Index ¶
Constants ¶
View Source
const ( UNSUPPORTED = "N/A" SELECT = "SELECT" FROM = "FROM" WHERE = "WHERE" LIMIT = "LIMIT" INSERT = "INSERT" INTO = "INTO" VALUES = "VALUES" ASTERISK = "*" )
SQL type tokens
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InsertTree ¶
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func (*Parser) GetSQLType ¶
func (p *Parser) GetSQLType(sql string) StatementType
func (*Parser) ParseInsert ¶
func (p *Parser) ParseInsert(insert string) (ast *InsertTree, err error)
ParseInsert can parse a simple INSERT statement, eg.
INSERT INTO table_name VALUES (value1, value2, …) or INSERT INTO table_name(column1, column2, …) VALUES (value1, value2, …)
func (*Parser) ParseSelect ¶
func (p *Parser) ParseSelect(sel string) (ast *SelectTree, err error)
ParseSelect is a simple select statement parser. It's just a demo of SELECT statement parser skeleton. Currently, the most complex SQL supported here is something like:
SELECT * FROM foo WHERE id < 3 LIMIT 1;
Even SQL-92 standard is far more complex. For a production ready SQL parser, see: https://github.com/auxten/postgresql-parser
type SelectTree ¶
type StatementType ¶
type StatementType string
Click to show internal directories.
Click to hide internal directories.