metadata

package
v2.10.3 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: Apache-2.0, BSD-3-Clause, MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column struct {
	Name         string
	IsPrimaryKey bool
	IsNullable   bool
	IsGenerated  bool
	DataType     DataType
	Comment      string
}

Column struct

func (Column) GoLangComment

func (c Column) GoLangComment() string

GoLangComment returns column comment without ascii control characters

type DataType

type DataType struct {
	Name       string
	Kind       DataTypeKind
	IsUnsigned bool
}

DataType contains information about column data type

type DataTypeKind

type DataTypeKind string

DataTypeKind is database type kind(base, enum, user-defined, array)

const (
	BaseType        DataTypeKind = "base"
	EnumType        DataTypeKind = "enum"
	UserDefinedType DataTypeKind = "user-defined"
	ArrayType       DataTypeKind = "array"
	RangeType       DataTypeKind = "range"
)

DataTypeKind possible values

type DialectQuerySet

type DialectQuerySet interface {
	GetTablesMetaData(db *sql.DB, schemaName string, tableType TableType) ([]Table, error)
	GetEnumsMetaData(db *sql.DB, schemaName string) ([]Enum, error)
}

DialectQuerySet is set of methods necessary to retrieve dialect metadata information

type Enum

type Enum struct {
	Name   string `sql:"primary_key"`
	Values []string
}

Enum metadata struct

type Schema

type Schema struct {
	Name           string
	TablesMetaData []Table
	ViewsMetaData  []Table
	EnumsMetaData  []Enum
}

Schema struct

func GetSchema

func GetSchema(db *sql.DB, querySet DialectQuerySet, schemaName string) (Schema, error)

GetSchema retrieves Schema information from database

func (Schema) IsEmpty

func (s Schema) IsEmpty() bool

IsEmpty returns true if schema info does not contain any table, views or enums metadata

type Table

type Table struct {
	Name    string
	Columns []Column
}

Table metadata struct

func (Table) MutableColumns

func (t Table) MutableColumns() []Column

MutableColumns returns list of mutable columns for table

type TableType

type TableType string

TableType is type of database table(view or base)

const (
	BaseTable TableType = "BASE TABLE"
	ViewTable TableType = "VIEW"
)

SQL table types

Jump to

Keyboard shortcuts

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