Beispiel #1
0
func ParseSqlStatements(sqlQuery string) ([]SqlStatement, error) {
	l := lex.NewSqlLexer(sqlQuery)
	m := Sqlbridge{l: l, SqlTokenPager: NewSqlTokenPager(l), buildVm: false}
	stmts := make([]SqlStatement, 0)
	for {
		stmt, err := m.parse()
		if err != nil {
			return nil, err
		}
		stmts = append(stmts, stmt)
		sqlRemaining, hasMore := l.Remainder()
		if !hasMore {
			break
		}
		l = lex.NewSqlLexer(sqlRemaining)
		m = Sqlbridge{l: l, SqlTokenPager: NewSqlTokenPager(l), buildVm: false}
	}
	return stmts, nil
}
Beispiel #2
0
func ParseSqlVm(sqlQuery string) (SqlStatement, error) {
	l := lex.NewSqlLexer(sqlQuery)
	m := Sqlbridge{l: l, SqlTokenPager: NewSqlTokenPager(l), buildVm: true}
	return m.parse()
}
Beispiel #3
0
func parseSqlResolver(sqlQuery string, fr expr.FuncResolver) (SqlStatement, error) {
	l := lex.NewSqlLexer(sqlQuery)
	m := Sqlbridge{l: l, SqlTokenPager: NewSqlTokenPager(l), funcs: fr, buildVm: false}
	return m.parse()
}