sqx

package
v1.0.19 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2024 License: MIT Imports: 9 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	QuoteMarksDefault = QuoteMarks{'"', '"'}
	QuoteMarksMSSQL   = QuoteMarks{'[', ']'}
	QuoteMarksMYSQL   = QuoteMarks{'`', '`'}
)

Functions

func EndsLike

func EndsLike(s string, escape ...rune) string

StartsLike build a string for like suffix '%' + s The default escape char is backslach '\\'.

func EscapeLike

func EscapeLike(s string, escape ...rune) string

EscapeLike escape sql like string. The default escape char is backslach '\\'.

func EscapeString

func EscapeString(s string) string

At present, this method only turns single-quotes into doubled single-quotes ( <code>"McHale's Navy"</code> => <code>"McHale”s Navy"</code>). It does not handle the cases of percent (%) or underscore (_) for use in LIKE clauses. </p> see http://www.jguru.com/faq/view.jsp?EID=8881

func In added in v1.0.15

func In(col string, arg any) (sql string, args []any)

func NotIn added in v1.0.15

func NotIn(col string, arg any) (sql string, args []any)

func Question added in v1.0.15

func Question(n int) string

func Questions added in v1.0.15

func Questions(n int) []string

func QuoteDriver added in v1.0.15

func QuoteDriver(driverName string, quoter Quoter)

QuoteDriver sets the Quoter for driverName to quoter.

func StartsLike

func StartsLike(s string, escape ...rune) string

StartsLike build a string for like prefix s + '%' The default escape char is backslach '\\'.

func StringLike

func StringLike(s string, escape ...rune) string

StringLike build a string for like '%' + s + '%' The default escape char is backslach '\\'.

Types

type Builder added in v1.0.15

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

func (*Builder) Build added in v1.0.15

func (b *Builder) Build() (string, []any)

func (*Builder) Columns added in v1.0.15

func (b *Builder) Columns(cols ...string) *Builder

func (*Builder) Delete added in v1.0.15

func (b *Builder) Delete(tb string) *Builder

func (*Builder) Distinct added in v1.0.15

func (b *Builder) Distinct(cols ...string) *Builder

func (*Builder) From added in v1.0.15

func (b *Builder) From(tb string) *Builder

func (*Builder) In added in v1.0.15

func (b *Builder) In(col string, arg any) *Builder

func (*Builder) Insert added in v1.0.15

func (b *Builder) Insert(tb string) *Builder

func (*Builder) Into added in v1.0.18

func (b *Builder) Into(col string, args ...any) *Builder

func (*Builder) Limit added in v1.0.15

func (b *Builder) Limit(limit int) *Builder

func (*Builder) NotIn added in v1.0.15

func (b *Builder) NotIn(col string, arg any) *Builder

func (*Builder) Offset added in v1.0.15

func (b *Builder) Offset(offset int) *Builder

func (*Builder) Order added in v1.0.15

func (b *Builder) Order(order string) *Builder

func (*Builder) Params added in v1.0.15

func (b *Builder) Params() []any

func (*Builder) SQL added in v1.0.15

func (b *Builder) SQL() string

func (*Builder) Select added in v1.0.15

func (b *Builder) Select(cols ...string) *Builder

func (*Builder) Set added in v1.0.15

func (b *Builder) Set(col string, args ...any) *Builder

func (*Builder) Update added in v1.0.15

func (b *Builder) Update(tb string) *Builder

func (*Builder) Values added in v1.0.15

func (b *Builder) Values(vals ...string) *Builder

func (*Builder) Where added in v1.0.15

func (b *Builder) Where(q string, args ...any) *Builder

type QuoteMarks added in v1.0.15

type QuoteMarks []rune

type Quoter added in v1.0.15

type Quoter int
const (
	QuoteDefault Quoter = iota
	QuoteMYSQL
	QuoteMSSQL
)

func GetQuoter added in v1.0.15

func GetQuoter(driverName string) Quoter

GetQuoteer returns the quoter for a given database given a drivername.

func (Quoter) Marks added in v1.0.15

func (quoter Quoter) Marks() QuoteMarks

func (Quoter) Quote added in v1.0.15

func (quoter Quoter) Quote(s string) string

Quote quote string 's' with quote marks [2]rune, return (m[0] + s + m[1])

func (Quoter) Quotes added in v1.0.15

func (quoter Quoter) Quotes(ss ...string) []string

Quotes quote string 's' in 'ss' with quote marks [2]rune, return (m[0] + s + m[1])

type SqlReader added in v1.0.17

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

func NewSqlReader added in v1.0.17

func NewSqlReader(r io.Reader) *SqlReader

func (*SqlReader) Error added in v1.0.17

func (sr *SqlReader) Error() error

func (*SqlReader) ReadSql added in v1.0.17

func (sr *SqlReader) ReadSql() (string, error)

Directories

Path Synopsis
Package sqx provides general purpose extensions to database/sql.
Package sqx provides general purpose extensions to database/sql.

Jump to

Keyboard shortcuts

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