Documentation ¶
Overview ¶
Package sql helps to create SQL squirrel filters using the TSL package.
Example ¶
Example for the tsl package.
// Set a TSL input string. input := "name = 'joe' and city != 'rome'" // Parse input string into a TSL tree. tree, _ := tsl.ParseTSL(input) // Set filter filter, _ := Walk(tree) // Convert TSL tree into SQL string using squirrel sql builder. sql, args, _ := sq.Select("name, city, state"). From("users"). Where(filter). ToSql() fmt.Printf("SQL : %s\n", sql) fmt.Printf("Args: %v\n", args)
Output: SQL : SELECT name, city, state FROM users WHERE (name = ? AND city <> ?) Args: [joe rome]
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Walk ¶
Walk travel the TSL tree to create squirrel SQL select operators.
Users can call the Walk method inside a squirrel Where to add the query.
filter, _ := sql.Walk(tree) sql, args, _ := sq.Select("name, city, state"). From("users"). Where(filter). ToSql()
Squirrel: https://github.com/Masterminds/squirrel
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.