pgdialect

package module
v1.2.16 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2025 License: BSD-2-Clause Imports: 24 Imported by: 600

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Version added in v1.0.22

func Version() string

Version is the current release version.

Types

type ArrayValue

type ArrayValue struct {
	// contains filtered or unexported fields
}

func Array

func Array(vi any) *ArrayValue

Array accepts a slice and returns a wrapper for working with PostgreSQL array data type.

For struct fields you can use array tag:

Emails  []string `bun:",array"`

func (*ArrayValue) AppendQuery

func (a *ArrayValue) AppendQuery(gen schema.QueryGen, b []byte) ([]byte, error)

func (*ArrayValue) Scan

func (a *ArrayValue) Scan(src any) error

func (*ArrayValue) Value

func (a *ArrayValue) Value() any

type Column added in v1.2.6

type Column = sqlschema.BaseColumn

type Dialect

type Dialect struct {
	schema.BaseDialect
	// contains filtered or unexported fields
}

func New

func New(opts ...DialectOption) *Dialect

func (*Dialect) AppendSequence added in v1.1.17

func (d *Dialect) AppendSequence(b []byte, _ *schema.Table, _ *schema.Field) []byte

func (*Dialect) AppendUint32 added in v1.0.14

func (d *Dialect) AppendUint32(b []byte, n uint32) []byte

func (*Dialect) AppendUint64 added in v1.0.14

func (d *Dialect) AppendUint64(b []byte, n uint64) []byte

func (*Dialect) CompareType added in v1.2.6

func (d *Dialect) CompareType(col1, col2 sqlschema.Column) bool

func (*Dialect) DefaultSchema added in v1.2.6

func (d *Dialect) DefaultSchema() string

func (*Dialect) DefaultVarcharLen added in v1.1.10

func (d *Dialect) DefaultVarcharLen() int

func (*Dialect) Features

func (d *Dialect) Features() feature.Feature

func (*Dialect) IdentQuote

func (d *Dialect) IdentQuote() byte

func (*Dialect) Init added in v0.2.14

func (d *Dialect) Init(*sql.DB)

func (*Dialect) Name

func (d *Dialect) Name() dialect.Name

func (*Dialect) NewInspector added in v1.2.6

func (d *Dialect) NewInspector(db *bun.DB, options ...sqlschema.InspectorOption) sqlschema.Inspector

func (*Dialect) NewMigrator added in v1.2.6

func (d *Dialect) NewMigrator(db *bun.DB, schemaName string) sqlschema.Migrator

func (*Dialect) OnTable

func (d *Dialect) OnTable(table *schema.Table)

func (*Dialect) Tables

func (d *Dialect) Tables() *schema.Tables

type DialectOption added in v1.2.7

type DialectOption func(d *Dialect)

func WithAppendUintAsInt added in v1.2.9

func WithAppendUintAsInt(on bool) DialectOption

func WithoutFeature added in v1.2.7

func WithoutFeature(other feature.Feature) DialectOption

type ForeignKey added in v1.2.6

type ForeignKey struct {
	ConstraintName string   `bun:"constraint_name"`
	SourceSchema   string   `bun:"schema_name"`
	SourceTable    string   `bun:"table_name"`
	SourceColumns  []string `bun:"columns,array"`
	TargetSchema   string   `bun:"target_schema"`
	TargetTable    string   `bun:"target_table"`
	TargetColumns  []string `bun:"target_columns,array"`
}

type HStoreValue added in v1.1.6

type HStoreValue struct {
	// contains filtered or unexported fields
}

func HStore added in v1.1.6

func HStore(vi any) *HStoreValue

HStore accepts a map[string]string and returns a wrapper for working with PostgreSQL hstore data type.

For struct fields you can use hstore tag:

Attrs  map[string]string `bun:",hstore"`

func (*HStoreValue) AppendQuery added in v1.1.6

func (h *HStoreValue) AppendQuery(gen schema.QueryGen, b []byte) ([]byte, error)

func (*HStoreValue) Scan added in v1.1.6

func (h *HStoreValue) Scan(src any) error

func (*HStoreValue) Value added in v1.1.6

func (h *HStoreValue) Value() any

type InformationSchemaColumn added in v1.2.6

type InformationSchemaColumn struct {
	Schema           string   `bun:"table_schema"`
	Table            string   `bun:"table_name"`
	Name             string   `bun:"column_name"`
	DataType         string   `bun:"data_type"`
	VarcharLen       int      `bun:"varchar_len"`
	IsArray          bool     `bun:"is_array"`
	ArrayDims        int      `bun:"array_dims"`
	Default          string   `bun:"default"`
	IsDefaultLiteral bool     `bun:"default_is_literal_expr"`
	IsIdentity       bool     `bun:"is_identity"`
	IndentityType    string   `bun:"identity_type"`
	IsSerial         bool     `bun:"is_serial"`
	IsNullable       bool     `bun:"is_nullable"`
	UniqueGroups     []string `bun:"unique_groups,array"`
}

type InformationSchemaTable added in v1.2.6

type InformationSchemaTable struct {
	Schema     string     `bun:"table_schema,pk"`
	Name       string     `bun:"table_name,pk"`
	PrimaryKey PrimaryKey `bun:"embed:primary_key_"`

	Columns []*InformationSchemaColumn `bun:"rel:has-many,join:table_schema=table_schema,join:table_name=table_name"`
}

type Inspector added in v1.2.6

type Inspector struct {
	sqlschema.InspectorConfig
	// contains filtered or unexported fields
}

func (*Inspector) Inspect added in v1.2.6

func (in *Inspector) Inspect(ctx context.Context) (sqlschema.Database, error)

type MultiRange added in v1.2.2

type MultiRange[T any] []Range[T]

func (MultiRange[T]) AppendQuery added in v1.2.16

func (m MultiRange[T]) AppendQuery(_ schema.QueryGen, buf []byte) ([]byte, error)

func (*MultiRange[T]) IsZero added in v1.2.16

func (m *MultiRange[T]) IsZero() bool

func (*MultiRange[T]) Len added in v1.2.16

func (m *MultiRange[T]) Len() int

type PrimaryKey added in v1.2.6

type PrimaryKey struct {
	ConstraintName string   `bun:"name"`
	Columns        []string `bun:"columns,array"`
}

type Range added in v1.2.2

type Range[T any] struct {
	Lower, Upper           T
	LowerBound, UpperBound RangeBound
}

func NewEmptyRange added in v1.2.16

func NewEmptyRange[T any]() Range[T]

func NewRange added in v1.2.2

func NewRange[T any](lower, upper T) Range[T]

func (Range[T]) AppendQuery added in v1.2.2

func (r Range[T]) AppendQuery(_ schema.QueryGen, buf []byte) ([]byte, error)

func (Range[T]) IsEmpty added in v1.2.16

func (r Range[T]) IsEmpty() bool

func (*Range[T]) IsZero added in v1.2.16

func (r *Range[T]) IsZero() bool

func (*Range[T]) Scan added in v1.2.2

func (r *Range[T]) Scan(raw any) (err error)

type RangeBound added in v1.2.2

type RangeBound byte
const (
	// RangeBoundUnset indicates that no bound is set.
	// This usually means the range is uninitialized or unspecified.
	RangeBoundUnset RangeBound = 0x0
	// RangeBoundEmpty is a special marker for an empty range.
	// This is NOT a valid PostgreSQL bound character, but is used internally
	// to represent a range that contains no values.
	RangeBoundEmpty RangeBound = 'E'

	RangeBoundInclusiveLeft  RangeBound = '['
	RangeBoundInclusiveRight RangeBound = ']'
	RangeBoundExclusiveLeft  RangeBound = '('
	RangeBoundExclusiveRight RangeBound = ')'
)

type RangeOption added in v1.2.16

type RangeOption[T any] func(*Range[T])

type Schema added in v1.2.6

type Schema = sqlschema.BaseDatabase

type Table added in v1.2.6

type Table = sqlschema.BaseTable

Jump to

Keyboard shortcuts

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