sqlutil

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package sqlutil provides some helpers for SQL databases.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bool

type Bool bool

Bool converts various column types to a boolean.

Supported types:

bool
int* and float*     0 or 1
[]byte and string   "1", "true", "0", "false"
nil                 defaults to false

func (Bool) MarshalText

func (b Bool) MarshalText() ([]byte, error)

MarshalText converts the data to a JSON-compatible human readable representation.

func (*Bool) Scan

func (b *Bool) Scan(src interface{}) error

Scan converts the different types of representation of a boolean in the database into a bool type.

func (*Bool) UnmarshalText

func (b *Bool) UnmarshalText(text []byte) error

UnmarshalText parses text in to the Go data structure.

func (Bool) Value

func (b Bool) Value() (driver.Value, error)

Value converts a bool type into a number to persist it in the database.

type FloatList

type FloatList []float64

FloatList expands comma-separated values from a column to []float64, and stores []float64 as a comma-separated string.

This is safe for NULL values, in which case it will scan in to FloatList(nil).

func (FloatList) MarshalText

func (l FloatList) MarshalText() ([]byte, error)

MarshalText converts the data to a human readable representation.

func (*FloatList) Scan

func (l *FloatList) Scan(v interface{}) error

Scan converts the data returned from the DB into the struct.

func (FloatList) String added in v1.3.1

func (l FloatList) String() string

func (*FloatList) UnmarshalText

func (l *FloatList) UnmarshalText(v []byte) error

UnmarshalText parses text in to the Go data structure.

func (FloatList) Value

func (l FloatList) Value() (driver.Value, error)

Value implements the SQL Value function to determine what to store in the DB.

type HTML

type HTML template.HTML

HTML is a string which indicates that the string has been HTML-escaped.

func (*HTML) Scan

func (h *HTML) Scan(v interface{}) error

Scan converts the data returned from the DB into the struct.

func (HTML) Value

func (h HTML) Value() (driver.Value, error)

Value implements the SQL Value function to determine what to store in the DB.

type IntList

type IntList []int64

IntList expands comma-separated values from a column to []int64, and stores []int64 as a comma-separated string.

This is safe for NULL values, in which case it will scan in to IntList(nil).

func (IntList) MarshalText

func (l IntList) MarshalText() ([]byte, error)

MarshalText converts the data to a human readable representation.

func (*IntList) Scan

func (l *IntList) Scan(v interface{}) error

Scan converts the data returned from the DB into the struct.

func (IntList) String added in v1.3.1

func (l IntList) String() string

func (*IntList) UnmarshalText

func (l *IntList) UnmarshalText(v []byte) error

UnmarshalText parses text in to the Go data structure.

func (IntList) Value

func (l IntList) Value() (driver.Value, error)

Value implements the SQL Value function to determine what to store in the DB.

type StringList

type StringList []string

StringList expands comma-separated values from a column to []string, and stores []string as a comma-separated string.

Note that this only works for simple strings (e.g. enums), we DO NOT escape commas in strings and you will run in to problems.

This is safe for NULL values, in which case it will scan in to StringList(nil).

func (StringList) MarshalText

func (l StringList) MarshalText() ([]byte, error)

MarshalText converts the data to a human readable representation.

func (*StringList) Scan

func (l *StringList) Scan(v interface{}) error

Scan converts the data returned from the DB into the struct.

func (StringList) String added in v1.3.1

func (l StringList) String() string

func (*StringList) UnmarshalText

func (l *StringList) UnmarshalText(v []byte) error

UnmarshalText parses text in to the Go data structure.

func (StringList) Value

func (l StringList) Value() (driver.Value, error)

Value implements the SQL Value function to determine what to store in the DB.

Jump to

Keyboard shortcuts

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