meta

package
v0.0.0-...-3223366 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertPluginTypeToSQLType

func ConvertPluginTypeToSQLType(t pub.PropertyType) string

func ConvertSQLTypeToPluginType

func ConvertSQLTypeToPluginType(t string, maxLength int) pub.PropertyType

Types

type Column

type Column struct {
	SchemaID string `json:"s"`
	ID       string `json:"id"`
	IsKey    bool   `json:"-"`

	// If this is true, the additional properties below this line are valid
	IsDiscovered bool `json:"-"`
	//
	PropertyType pub.PropertyType `json:"-"`
	SQLType      string           `json:"-"`
	MaxLength    int64            `json:"-"`
	IsNullable   bool             `json:"-"`
	// contains filtered or unexported fields
}

func (Column) CastForSelect

func (c Column) CastForSelect(expression string) string

Cast returns expression (which must be a SQL expression representing a value from this column) wrapped in a cast which will make the value an appropriate type for a SELECT statement. If the type of this column is already appropriate, expression will be returned.

func (Column) OpaqueName

func (c Column) OpaqueName() string

OpaqueName is an encoded safe name which can be used to alias to this column in a script.

func (Column) RenderSQLValue

func (c Column) RenderSQLValue(v interface{}) string

RenderSQLValue emits a string which will be a valid representation of value v in a SQL query.

func (Column) String

func (c Column) String() string

type Columns

type Columns []*Column

func (Columns) Len

func (c Columns) Len() int

func (Columns) Less

func (c Columns) Less(i, j int) bool

func (Columns) MakeSQLColumnNameList

func (c Columns) MakeSQLColumnNameList() string

MakeSQLValuesFromMap produces a string like `ID, Value, Other` from a map by extracting the column names in the order the columns are in.

func (Columns) MakeSQLValuesFromMap

func (c Columns) MakeSQLValuesFromMap(m map[string]interface{}) string

MakeSQLValuesFromMap produces a string like `'a', 7, null` from a map by extracting the values in the order the columns are in.

func (Columns) OmitIDs

func (c Columns) OmitIDs(omit ...string) Columns

func (Columns) OmitKeys

func (c Columns) OmitKeys() Columns

func (Columns) Swap

func (c Columns) Swap(i, j int)

type RowKey

type RowKey RowValue

func (RowKey) String

func (r RowKey) String() string

type RowKeys

type RowKeys []RowKey

func UnmarshalRowKeys

func UnmarshalRowKeys(b []byte) (RowKeys, error)

func (RowKeys) HasNils

func (r RowKeys) HasNils() bool

HasNils returns true if any values are nil.

func (RowKeys) Marshal

func (r RowKeys) Marshal() []byte

func (RowKeys) String

func (r RowKeys) String() string

func (RowKeys) ToMapKey

func (r RowKeys) ToMapKey() string

ToMapKey returns a string which contains all the keys.

type RowMap

type RowMap map[string]interface{}

RowMap is a map of column name to column value. It is created from a SQL result.

func (RowMap) ExtractPrefixedRowKeys

func (r RowMap) ExtractPrefixedRowKeys(s *Schema, prefix string) (RowKeys, error)

ExtractPrefixedRowKeys returns a RowKeys with the values for entry in the RowMap which has a key which matches a column in the schema when the prefix is removed. Returns an error if data does not have an entry for each key column in the schema.

func (RowMap) ExtractPrefixedRowValues

func (r RowMap) ExtractPrefixedRowValues(s *Schema, prefix string) (RowValues, error)

ExtractPrefixedRowValues returns a RowValues with the values for entry in the RowMap which has a key which matches a column in the schema when the prefix is removed. Returns an error if data does not have an entry for each column in the schema.

func (RowMap) ExtractRowKeys

func (r RowMap) ExtractRowKeys(s *Schema) (RowKeys, error)

ExtractPrefixedRowKeys returns a RowKeys with the values for entry in the RowMap which has a key which matches a column in the schema. Returns an error if data does not have an entry for each key column in the schema.

func (RowMap) ExtractRowValues

func (r RowMap) ExtractRowValues(s *Schema) (RowValues, error)

ExtractRowValues returns a RowValues with the values for entry in the RowMap which has a key which matches a column in the schema. Returns an error if data does not have an entry for each column in the schema.

func (RowMap) JSON

func (r RowMap) JSON() string

JSON returns the JSON representation of the RowMap.

type RowValue

type RowValue struct {
	ColumnID string
	Value    interface{}
}

func (RowValue) String

func (r RowValue) String() string

type RowValues

type RowValues []RowValue

func (RowValues) Hash

func (r RowValues) Hash() []byte

func (RowValues) String

func (r RowValues) String() string

type Schema

type Schema struct {
	ID               string
	IsTable          bool
	IsChangeTracking bool

	// The query for this schema, if it's not a table or view.
	Query string
	// contains filtered or unexported fields
}

func (*Schema) AddColumn

func (s *Schema) AddColumn(c *Column) *Column

func (*Schema) Columns

func (s *Schema) Columns() Columns

func (*Schema) ColumnsKeysFirst

func (s *Schema) ColumnsKeysFirst() Columns

ColumnsKeysFirst returns the columns with keys sorted to the beginning.

func (*Schema) GetColumn

func (s *Schema) GetColumn(id string) *Column

func (*Schema) GetColumnByOpaqueName

func (s *Schema) GetColumnByOpaqueName(id string) (*Column, bool)

func (*Schema) KeyColumns

func (s *Schema) KeyColumns() []*Column

KeyColumns returns the key columns, in alphabetical order.

func (*Schema) Keys

func (s *Schema) Keys() []string

Keys returns the names of the key columns, in alphabetical order.

func (*Schema) LookupColumn

func (s *Schema) LookupColumn(id string) (*Column, bool)

func (*Schema) NonKeyColumns

func (s *Schema) NonKeyColumns() Columns

func (*Schema) WithColumns

func (s *Schema) WithColumns(cols Columns) *Schema

type SchemaID

type SchemaID string

func (SchemaID) SQLSchema

func (s SchemaID) SQLSchema() string

SQLSchema returns the SQL schema from the schema ID (or "dbo" if there is no schema)

func (SchemaID) SQLSchemaEsc

func (s SchemaID) SQLSchemaEsc() string

SQLSchemaEsc returns the SQL schema from the schema ID (or "dbo" if there is no schema), surrounded by escaping `[]`.

func (SchemaID) SQLTable

func (s SchemaID) SQLTable() string

SQLSchema returns the SQL table name (without escaping brackets) from the schema ID, without surrounding '[]'

func (SchemaID) SQLTableEsc

func (s SchemaID) SQLTableEsc() string

SQLTableEsc returns the SQL table from the schema ID (or "dbo" if there is no schema), surrounded by escaping `[]`.

type SchemaRowKey

type SchemaRowKey struct {
	SchemaID string
	RowKey
}

Maps a string key to a value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL