keywords package
SQL keyword tables and dialect identifiers.
Import path: github.com/ajitpratap0/GoSQLX/pkg/sql/keywords (pkg.go.dev)
Part of the GoSQLX API reference.
Core Types
Category (Type)
const (
CategoryReserved Category = iota
CategoryDML
CategoryDDL
CategoryDataType
CategoryFunction
CategoryOperator
CategoryJoin
CategoryWindow
CategoryAggregate
)
Functions
IsKeyword(word string) bool
Check if string is a SQL keyword.
keywords.IsKeyword("SELECT") // true
keywords.IsKeyword("LATERAL") // true (v1.6.0)
GetCategory(word string) (Category, bool)
Get keyword category.
cat, ok := keywords.GetCategory("SELECT")
// Returns: CategoryDML, true
IsDMLKeyword(word string) bool
Check if DML keyword.
IsDDLKeyword(word string) bool
Check if DDL keyword.
IsReserved(word string) bool
Check if reserved keyword.
IsFunction(word string) bool
Check if function name.
IsAggregate(word string) bool
Check if aggregate function.
IsWindowFunction(word string) bool
Check if window function.
IsDataType(word string) bool
Check if data type.
GetAllKeywords() []string
Get all keywords.
GetKeywordsByCategory(cat Category) []string
Get keywords by category.
Dialect-Specific Functions
IsPostgreSQLKeyword(word string) bool
IsMySQLKeyword(word string) bool
IsSQLServerKeyword(word string) bool
IsOracleKeyword(word string) bool
IsSQLiteKeyword(word string) bool
GetSuggestions(prefix string, maxResults int) []string
Get keyword suggestions for autocomplete.
Suggestions are served from an LRU cache. See benchmarks for measured performance.
suggestions := keywords.GetSuggestions("SEL", 5)
// Returns: ["SELECT"]