sqlmanager_shared

package
v0.4.31 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PostgresDriver = "postgres"
	MysqlDriver    = "mysql"
)
View Source
const (
	DisableForeignKeyChecks = "SET FOREIGN_KEY_CHECKS = 0;"
)

Variables

This section is empty.

Functions

func BuildTable

func BuildTable(schema, table string) string

func ConvertNullableTextToBool

func ConvertNullableTextToBool(isNullableStr string) bool

func DedupeSlice

func DedupeSlice(input []string) []string

func GetUniqueSchemaColMappings

func GetUniqueSchemaColMappings(
	schemas []*DatabaseSchemaRow,
) map[string]map[string]*ColumnInfo

func Ptr

func Ptr[T any](val T) *T

func SplitTableKey added in v0.4.30

func SplitTableKey(key string) (schema, table string)

Types

type AlterTableStatement

type AlterTableStatement struct {
	Statement      string
	ConstraintType ConstraintType
}

type BatchExecOpts

type BatchExecOpts struct {
	Prefix *string // this string will be added to the start of each statement
}

type ColumnInfo

type ColumnInfo struct {
	OrdinalPosition        int32  // Specifies the sequence or order in which each column is defined within the table. Starts at 1 for the first column.
	ColumnDefault          string // Specifies the default value for a column, if any is set.
	IsNullable             bool   // Specifies if the column is nullable or not.
	DataType               string // Specifies the data type of the column, i.e., bool, varchar, int, etc.
	CharacterMaximumLength *int32 // Specifies the maximum allowable length of the column for character-based data types. For datatypes such as integers, boolean, dates etc. this is NULL.
	NumericPrecision       *int32 // Specifies the precision for numeric data types. It represents the TOTAL count of significant digits in the whole number, that is, the number of digits to BOTH sides of the decimal point. Null for non-numeric data types.
	NumericScale           *int32 // Specifies the scale of the column for numeric data types, specifically non-integers. It represents the number of digits to the RIGHT of the decimal point. Null for non-numeric data types and integers.
}

type ConstraintType

type ConstraintType int
const (
	PrimaryConstraintType ConstraintType = iota
	ForeignConstraintType
	UniqueConstraintType
	CheckConstraintType
)

func ToConstraintType

func ToConstraintType(constraintType string) (ConstraintType, error)

type DataType

type DataType struct {
	Schema     string
	Name       string
	Definition string
}

type DatabaseSchemaRow

type DatabaseSchemaRow struct {
	TableSchema            string
	TableName              string
	ColumnName             string
	DataType               string
	ColumnDefault          string
	IsNullable             string
	CharacterMaximumLength int32
	NumericPrecision       int32
	NumericScale           int32
	OrdinalPosition        int16
	GeneratedType          *string
}

type ForeignConstraint

type ForeignConstraint struct {
	Columns     []string
	NotNullable []bool
	ForeignKey  *ForeignKey
}

type ForeignKey

type ForeignKey struct {
	Table   string
	Columns []string
}

type ForeignKeyConstraintsRow

type ForeignKeyConstraintsRow struct {
	ConstraintName    string
	SchemaName        string
	TableName         string
	ColumnName        string
	IsNullable        bool
	ForeignSchemaName string
	ForeignTableName  string
	ForeignColumnName string
}

type InitSchemaStatements added in v0.4.30

type InitSchemaStatements struct {
	Label      string
	Statements []string
}

type PrimaryKey

type PrimaryKey struct {
	Schema  string
	Table   string
	Columns []string
}

type SchemaTable

type SchemaTable struct {
	Schema string
	Table  string
}

func (SchemaTable) String

func (s SchemaTable) String() string

type SchemaTableDataTypeResponse

type SchemaTableDataTypeResponse struct {
	// Custom Sequences not tied to the SERIAL data type
	Sequences []*DataType

	// SQL Functions
	Functions []*DataType

	// actual Data Types
	Composites []*DataType
	Enums      []*DataType
	Domains    []*DataType
}

These are all items that live at the schema level, but are used by tables

func (*SchemaTableDataTypeResponse) GetStatements

func (s *SchemaTableDataTypeResponse) GetStatements() []string

type TableConstraints

type TableConstraints struct {
	ForeignKeyConstraints map[string][]*ForeignConstraint
	PrimaryKeyConstraints map[string][]string
	UniqueConstraints     map[string][][]string
}

type TableInitStatement

type TableInitStatement struct {
	CreateTableStatement string
	AlterTableStatements []*AlterTableStatement
	IndexStatements      []string
}

type TableTrigger

type TableTrigger struct {
	Schema      string
	Table       string
	TriggerName string
	Definition  string
}

Jump to

Keyboard shortcuts

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