Documentation ¶
Overview ¶
Package goql is a go sql driver for query against go packages the tables and fields are registered dynamically at runtime, and registration can be done using Register* functions currently 3 types are accepted, Number/String/Bool type `Definition` is under development see the cmd/goql for an example.
Example ¶
package main import ( "database/sql" "fmt" "log" ) func main() { con, err := sql.Open("goql", "net/http") if err != nil { log.Fatal(err) } defer con.Close() rows, err := con.Query("SELECT name, receiver FROM funcs WHERE name='Do'") // client.Do if err != nil { log.Fatal(err) } var name, rec string for rows.Next() { if err := rows.Scan(&name, &rec); err != nil { log.Fatal(err) } fmt.Printf("%s.%s", rec, name) } }
Output: Client.Do
Index ¶
- func RegisterField(t string, name string, valuer interface{})
- func RegisterFunction(name string, fn Function)
- func RegisterTable(name string, data Table)
- type Bool
- type BoolValuer
- type Definition
- type DefinitionValuer
- type Function
- type Getter
- type Number
- type NumberValuer
- type String
- type StringValuer
- type Table
- type ValueType
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterField ¶
RegisterField is the field registration for a table, table must registered before and the name must be unique in that table the value is one of the String/Bool/NumberValuer in any other case, it panics
func RegisterFunction ¶
RegisterFunction is entry point for registering a function into system, the name must be unique
func RegisterTable ¶
RegisterTable is the function to handle registration of a table, the name must be unique, and duplicate registration panics
Types ¶
type BoolValuer ¶
type BoolValuer interface {
Value(interface{}) Bool
}
BoolValuer is the Boolean valuer
type Definition ¶
type Definition struct {
Definition astdata.Definition
}
Definition is the type to handle type definition
type DefinitionValuer ¶
type DefinitionValuer interface {
Value(interface{}) Definition
}
DefinitionValuer is used to handle definition column
type Function ¶
Function is the functions in the system, it should check for arguments count and return error on wrong arguments count, but for type, it should try to cast TODO : check for function arguments on prepare
type Getter ¶
type Getter interface {
Get() interface{}
}
Getter is replacement to prevent using the interface{} it is used when the value is required
type NumberValuer ¶
type NumberValuer interface {
Value(interface{}) Number
}
NumberValuer is the number valuer (float64 is supported only )
type StringValuer ¶
type StringValuer interface {
Value(interface{}) String
}
StringValuer is provider for a value for a table
type Table ¶
type Table interface { // the function argument is the object used as database. in our case it is the astdata.Package and the result // must be an array of items. items are depends on the table. for example on funcs table, the result // is a slice of astdata.Functions Provide(interface{}) []interface{} }
Table is a interface for registration of a data
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
Package parse is a simple sql lexer/parser with limited functionality it can handle queries like :
|
Package parse is a simple sql lexer/parser with limited functionality it can handle queries like : |
plugin
|
|
goqlimport
Package goqlimport is a prof of concept, just to show how to add a new column to a table this is slow, just for demonstration
|
Package goqlimport is a prof of concept, just to show how to add a new column to a table this is slow, just for demonstration |