zeronull

package
v5.5.3 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package zeronull contains types that automatically convert between database NULLs and Go zero values.

Sometimes the distinction between a zero value and a NULL value is not useful at the application level. For example, in PostgreSQL an empty string may be stored as NULL. There is usually no application level distinction between an empty string and a NULL string. Package zeronull implements types that seamlessly convert between PostgreSQL NULL and the zero value.

It is recommended to convert types at usage time rather than instantiate these types directly. In the example below, middlename would be stored as a NULL.

firstname := "John"
middlename := ""
lastname := "Smith"
_, err := conn.Exec(
	ctx,
	"insert into people(firstname, middlename, lastname) values($1, $2, $3)",
	zeronull.Text(firstname),
	zeronull.Text(middlename),
	zeronull.Text(lastname),
)

Do not edit. Generated from pgtype/zeronull/int.go.erb

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(m *pgtype.Map)

Register registers the zeronull types so they can be used in query exec modes that do not know the server OIDs.

Types

type Float8

type Float8 float64

func (Float8) Float64Value

func (f Float8) Float64Value() (pgtype.Float8, error)

func (*Float8) Scan

func (f *Float8) Scan(src any) error

Scan implements the database/sql Scanner interface.

func (*Float8) ScanFloat64

func (f *Float8) ScanFloat64(n pgtype.Float8) error

ScanFloat64 implements the Float64Scanner interface.

func (Float8) SkipUnderlyingTypePlan

func (Float8) SkipUnderlyingTypePlan()

func (Float8) Value

func (f Float8) Value() (driver.Value, error)

Value implements the database/sql/driver Valuer interface.

type Int2

type Int2 int16

func (*Int2) Scan

func (dst *Int2) Scan(src any) error

Scan implements the database/sql Scanner interface.

func (*Int2) ScanInt64

func (dst *Int2) ScanInt64(n int64, valid bool) error

ScanInt64 implements the Int64Scanner interface.

func (Int2) SkipUnderlyingTypePlan

func (Int2) SkipUnderlyingTypePlan()

func (Int2) Value

func (src Int2) Value() (driver.Value, error)

Value implements the database/sql/driver Valuer interface.

type Int4

type Int4 int32

func (*Int4) Scan

func (dst *Int4) Scan(src any) error

Scan implements the database/sql Scanner interface.

func (*Int4) ScanInt64

func (dst *Int4) ScanInt64(n int64, valid bool) error

ScanInt64 implements the Int64Scanner interface.

func (Int4) SkipUnderlyingTypePlan

func (Int4) SkipUnderlyingTypePlan()

func (Int4) Value

func (src Int4) Value() (driver.Value, error)

Value implements the database/sql/driver Valuer interface.

type Int8

type Int8 int64

func (*Int8) Scan

func (dst *Int8) Scan(src any) error

Scan implements the database/sql Scanner interface.

func (*Int8) ScanInt64

func (dst *Int8) ScanInt64(n int64, valid bool) error

ScanInt64 implements the Int64Scanner interface.

func (Int8) SkipUnderlyingTypePlan

func (Int8) SkipUnderlyingTypePlan()

func (Int8) Value

func (src Int8) Value() (driver.Value, error)

Value implements the database/sql/driver Valuer interface.

type Text

type Text string

func (*Text) Scan

func (dst *Text) Scan(src any) error

Scan implements the database/sql Scanner interface.

func (*Text) ScanText

func (dst *Text) ScanText(v pgtype.Text) error

ScanText implements the TextScanner interface.

func (Text) SkipUnderlyingTypePlan

func (Text) SkipUnderlyingTypePlan()

func (Text) Value

func (src Text) Value() (driver.Value, error)

Value implements the database/sql/driver Valuer interface.

type Timestamp

type Timestamp time.Time

func (*Timestamp) Scan

func (ts *Timestamp) Scan(src any) error

Scan implements the database/sql Scanner interface.

func (*Timestamp) ScanTimestamp

func (ts *Timestamp) ScanTimestamp(v pgtype.Timestamp) error

func (Timestamp) SkipUnderlyingTypePlan

func (Timestamp) SkipUnderlyingTypePlan()

func (Timestamp) TimestampValue

func (ts Timestamp) TimestampValue() (pgtype.Timestamp, error)

func (Timestamp) Value

func (ts Timestamp) Value() (driver.Value, error)

Value implements the database/sql/driver Valuer interface.

type Timestamptz

type Timestamptz time.Time

func (*Timestamptz) Scan

func (ts *Timestamptz) Scan(src any) error

Scan implements the database/sql Scanner interface.

func (*Timestamptz) ScanTimestamptz

func (ts *Timestamptz) ScanTimestamptz(v pgtype.Timestamptz) error

func (Timestamptz) SkipUnderlyingTypePlan

func (Timestamptz) SkipUnderlyingTypePlan()

func (Timestamptz) TimestamptzValue

func (ts Timestamptz) TimestamptzValue() (pgtype.Timestamptz, error)

func (Timestamptz) Value

func (ts Timestamptz) Value() (driver.Value, error)

Value implements the database/sql/driver Valuer interface.

type UUID

type UUID [16]byte

func (*UUID) Scan

func (u *UUID) Scan(src any) error

Scan implements the database/sql Scanner interface.

func (*UUID) ScanUUID

func (u *UUID) ScanUUID(v pgtype.UUID) error

ScanUUID implements the UUIDScanner interface.

func (UUID) SkipUnderlyingTypePlan

func (UUID) SkipUnderlyingTypePlan()

func (UUID) UUIDValue

func (u UUID) UUIDValue() (pgtype.UUID, error)

func (UUID) Value

func (u UUID) Value() (driver.Value, error)

Value implements the database/sql/driver Valuer interface.

Jump to

Keyboard shortcuts

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