Documentation
¶
Overview ¶
* @Author: wangjun haodreams@163.com * @Date: 2024-05-09 13:27:28 * @LastEditors: wangjun haodreams@163.com * @LastEditTime: 2024-05-17 08:59:56 * @FilePath: \golib\memdb\ast_sql.go * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
Index ¶
- func NewParser() *participle.Parser[SelectStmt]
- func Where(t *memtable.Table, cond *Condition) (table *memtable.Table, err error)
- type Array
- type Compare
- type CondRHS
- type Condition
- type Database
- func (m *Database) GetTable(name string) *memtable.Table
- func (m *Database) Query(sql string) (tempTable *memtable.TempTable, err error)
- func (m *Database) RegisterMemTable(table *memtable.Table, name string) (err error)
- func (m *Database) RegisterTable(table any, key string, names ...string) (err error)
- func (m *Database) Tables() []*memtable.Table
- type Field
- type Fields
- type FillBy
- type GroupBy
- type Is
- type Like
- type Math
- type NumCompare
- type NumMath
- type OrderBy
- type SelectStmt
- type StatisFunc
- type StrCompare
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewParser ¶
func NewParser() *participle.Parser[SelectStmt]
Types ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
表的where支持逻辑和数学一维函数, 例如 where a < b * 100,,数学常量放在表达式最后面 表的字段暂不支持数学函数 例如 select a * 100
func NewDatabase ¶
func NewDatabase() *Database
func (*Database) RegisterMemTable ¶
func (*Database) RegisterTable ¶
type GroupBy ¶
type GroupBy struct {
Name []string `parser:"@Ident ( ',' @Ident )*"`
}
@Ident a-z A-Z 0-9 _ * 任意字符
type Math ¶
type Math struct { Name string `parser:"@Ident"` Operator string `parser:"@( '+' | '-' | '*' | '/' | '%' )"` Number float64 `parser:"@Number"` }
数学函数
type NumCompare ¶
type SelectStmt ¶
type SelectStmt struct { Select string `parser:"@('SELECT') "` Fields []*Field `parser:"@@ ( ',' @@ )*"` From string `parser:"'FROM' @Ident"` Where []*Condition `parser:"( 'WHERE' @@ ( 'AND' @@ )*)?"` GroupBy *GroupBy `parser:"('GROUP' 'BY' (@@)*)?"` FillBy *FillBy `parser:"('FILL' 'BY' (@@)*)?"` OrderBy *OrderBy `parser:"('ORDER' 'BY' (@@)*)?"` }
SelectStmt based on http://www.h2database.com/html/grammar.html
type StrCompare ¶
Click to show internal directories.
Click to hide internal directories.