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 ¶
Types ¶
type Float8 ¶
type Float8 float64
func (*Float8) ScanFloat64 ¶
ScanFloat64 implements the Float64Scanner interface.
func (Float8) SkipUnderlyingTypePlan ¶
func (Float8) SkipUnderlyingTypePlan()
type Int2 ¶
type Int2 int16
func (Int2) SkipUnderlyingTypePlan ¶
func (Int2) SkipUnderlyingTypePlan()
type Int4 ¶
type Int4 int32
func (Int4) SkipUnderlyingTypePlan ¶
func (Int4) SkipUnderlyingTypePlan()
type Int8 ¶
type Int8 int64
func (Int8) SkipUnderlyingTypePlan ¶
func (Int8) SkipUnderlyingTypePlan()
type Text ¶
type Text string
func (Text) SkipUnderlyingTypePlan ¶
func (Text) SkipUnderlyingTypePlan()
type Timestamp ¶
func (Timestamp) SkipUnderlyingTypePlan ¶
func (Timestamp) SkipUnderlyingTypePlan()
type Timestamptz ¶
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)