db_common

package
v0.1.0-alpha.202401101409 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddRootCertToConfig

func AddRootCertToConfig(config *pgconn.Config, certLocation string) error

func CollectOneToStructByName

func CollectOneToStructByName[T any](rows *sql.Rows) (*T, error)

func CollectToStructByName

func CollectToStructByName[T any](rows *sql.Rows) ([]T, error)

func GetCommentsQueryForPlugin

func GetCommentsQueryForPlugin(connectionName string, p map[string]*proto.TableSchema) string

func GetDeleteConnectionQuery

func GetDeleteConnectionQuery(name string) string

func GetUpdateConnectionQuery

func GetUpdateConnectionQuery(connectionName, pluginSchemaName string) string

func IsSchemaNameValid

func IsSchemaNameValid(name string) (bool, string)

IsSchemaNameValid verifies that the given string is a valid pgsql schema name

func MaxDbConnections

func MaxDbConnections() int

func PgEscapeName

func PgEscapeName(name string) string

PgEscapeName escapes strings which will be usaed for Podsdtgres object identifiers (table names, column names, schema names)

func PgEscapeSearchPath

func PgEscapeSearchPath(searchPath []string) []string

PgEscapeSearchPath applies postgres escaping to search path and remove whitespace

func PgEscapeString

func PgEscapeString(str string) string

PgEscapeString escapes strings which are to be inserted use a custom escape tag to avoid chance of clash with the escaped text https://medium.com/@lnishada/postgres-dollar-quoting-6d23e4f186ec

Types

type ColumnSchema

type ColumnSchema struct {
	ID          string
	Name        string
	NotNull     bool
	Type        string
	Default     string
	Description string
}

ColumnSchema contains the details of a single column in a table

type ExecContext

type ExecContext interface {
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
}

type InitResult

type InitResult struct {
	error_helpers.ErrorAndWarnings
	Messages []string

	// allow overriding of the display functions
	DisplayMessage func(ctx context.Context, m string)
	DisplayWarning func(ctx context.Context, w string)
}

func (*InitResult) AddMessage

func (r *InitResult) AddMessage(messages ...string)

func (*InitResult) AddWarnings

func (r *InitResult) AddWarnings(warnings ...string)

func (*InitResult) DisplayMessages

func (r *InitResult) DisplayMessages()

func (*InitResult) HasMessages

func (r *InitResult) HasMessages() bool

func (*InitResult) Merge

func (r *InitResult) Merge(other InitResult)

type QueryWithArgs

type QueryWithArgs struct {
	Query string
	Args  []any
}

type SQLFunction

type SQLFunction struct {
	Name     string
	Params   map[string]string
	Returns  string
	Body     string
	Language string
}

SQLFunction is a struct for an sqlFunc

type SchemaMetadata

type SchemaMetadata struct {
	// map {schemaname, {map {tablename -> tableschema}}
	Schemas map[string]map[string]TableSchema
	// the name of the temporary schema
	TemporarySchemaName string
}

SchemaMetadata is a struct to represent the schema of the database

func NewSchemaMetadata

func NewSchemaMetadata() *SchemaMetadata

func (*SchemaMetadata) GetSchemas

func (m *SchemaMetadata) GetSchemas() []string

GetSchemas returns all foreign schema names

func (*SchemaMetadata) GetTablesInSchema

func (m *SchemaMetadata) GetTablesInSchema(schemaName string) map[string]struct{}

GetTablesInSchema returns a lookup of all foreign tables in a given foreign schema

type TableSchema

type TableSchema struct {
	// map columnName -> columnSchema
	Columns     map[string]ColumnSchema
	Name        string
	FullName    string
	Schema      string
	Description string
}

TableSchema contains the details of a single table in the schema

Jump to

Keyboard shortcuts

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