Documentation
¶
Index ¶
- func LoadPgKeywords() []string
- type ColumnInfo
- type ColumnMetadata
- type Completer
- func (c *Completer) ExtendColumns(columns []ColumnInfo, isView bool)
- func (c *Completer) ExtendDataTypes(dataTypes []DatatypeName)
- func (c *Completer) ExtendDatabases(databases []string)
- func (c *Completer) ExtendForeignKeys(foreignKeys []ForeignKey)
- func (c *Completer) ExtendFunctions(funcs []*FunctionMetadata)
- func (c *Completer) ExtendSchemas(schemas []string)
- func (c *Completer) ExtendTables(tables []Relation)
- func (c *Completer) GetKeyWords() []string
- type DatabaseExecutor
- type DatatypeName
- type ForeignKey
- type FunctionMetadata
- type MetaData
- type MetaDataRefresher
- type RefreshRequest
- type Relation
- type RelationKind
- type TableMetadata
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadPgKeywords ¶
func LoadPgKeywords() []string
LoadPgKeywords returns PostgreSQL keyword suggestions used by autocompletion.
Types ¶
type ColumnInfo ¶
type ColumnMetadata ¶
type ColumnMetadata struct {
Name string
DataType string
ForeignKey []ForeignKey
Default *string
HasDefault bool
}
type Completer ¶
type Completer struct {
// contains filtered or unexported fields
}
func New ¶
New creates a new Completer with an optional logger. If logger is nil, logging will be disabled.
func (*Completer) ExtendColumns ¶
func (c *Completer) ExtendColumns(columns []ColumnInfo, isView bool)
func (*Completer) ExtendDataTypes ¶
func (c *Completer) ExtendDataTypes(dataTypes []DatatypeName)
func (*Completer) ExtendDatabases ¶
func (*Completer) ExtendForeignKeys ¶
func (c *Completer) ExtendForeignKeys(foreignKeys []ForeignKey)
func (*Completer) ExtendFunctions ¶
func (c *Completer) ExtendFunctions(funcs []*FunctionMetadata)
func (*Completer) ExtendSchemas ¶
func (*Completer) ExtendTables ¶
func (*Completer) GetKeyWords ¶
GetKeyWords returns the PostgreSQL keywords for autocompletion.
type DatabaseExecutor ¶
type DatabaseExecutor interface {
// query schema names
Schemas() ([]string, error)
// Query table names along with their schema
Tables() ([]Relation, error)
// Query view names along with their schema
Views() ([]Relation, error)
// Query table column metadata
TableColumns() ([]ColumnInfo, error)
// Query view column metadata
ViewColumns() ([]ColumnInfo, error)
// Query function metadata
Functions() ([]*FunctionMetadata, error)
// Query data type names
DataTypes() ([]DatatypeName, error)
// Query foreign key relationships
ForeignKeys() ([]ForeignKey, error)
// Query database names
Databases() ([]string, error)
// Query the current search path
SearchPath() ([]string, error)
}
DatabaseExecutor defines the interface for executing database queries to fetch metadata
type DatatypeName ¶
type ForeignKey ¶
type ForeignKey struct {
ParentSchema string
ParentTable string
ParentColumn string
ChildSchema string
ChildTable string
ChildColumn string
}
example school.id -> students.school_id parenttable = school parentcolumn = id childtable = students childcolumn = school_id
type FunctionMetadata ¶
type MetaData ¶
type MetaData struct {
Databases []string
SearchPath []string
Tables map[string]map[string]*TableMetadata // schema -> table -> metadata
Views map[string]map[string]*TableMetadata // schema -> view -> metadata
Functions map[string]map[string][]*FunctionMetadata // schema -> functions(overload) -> metadata
// we are not storing full enum metadata, just the names, suffices for completion
// reference : pgcli/pgcompleter.py line 288 - 297
DataTypes map[string]map[string]bool // schema -> datatype -> exists
// keyword tree: a map mapping keywords to well known following keywords
// ex: create -> map[table, user, database ...]
KeyWordsTree map[string]any
KeyWords []string
BuiltinFunctions []string
AllCompletions map[string]bool
Casing map[string]string
ReservedWords map[string]bool
LastRefreshed time.Time
// contains filtered or unexported fields
}
func NewMetaData ¶
func NewMetaData() *MetaData
type MetaDataRefresher ¶
type MetaDataRefresher struct {
// contains filtered or unexported fields
}
MetaDataRefresher handles asynchronous refreshing of metadata
type RefreshRequest ¶
type RefreshRequest struct {
// Type of metadata to refresh
// options: "schemata", "tables", "views", "functions", "datatypes", "etc"
RefreshTypes []string
// Callback to invoke after refresh is done
Callback func(*MetaData)
}
RefreshRequest represents a request to refresh certain types of metadata
type Relation ¶
type Relation struct {
Schema string
Name string
Kind RelationKind
}
type RelationKind ¶
type RelationKind string
const ( RelationKindTable RelationKind = "table" RelationKindView RelationKind = "view" )
type TableMetadata ¶
type TableMetadata struct {
Name string
Columns map[string]*ColumnMetadata
}
Click to show internal directories.
Click to hide internal directories.