adapters

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2017 License: MIT Imports: 0 Imported by: 4

Documentation

Overview

Package adapters contains database specific code, mainly in sub-packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter interface {
	// DriverName must return the driver name to be used with sql.Open()
	DriverName() string
	// Quote must return an SQL identifier (table name, column name) quoted,
	// ie : "foo" for SQLite or Postgresql, `foo` for MySQL, [foo] for SQLServer.
	Quote(string) string
}

Adapter interface is the minimal implementation for an adapter.

type LimitBuilder

type LimitBuilder interface {
	BuildLimit(int) *SQLPart
}

LimitBuilder is an interface wrapping the optional BuildLimit method.

BuildLimit get an integer and returns a string containing a LIMIT sql clause or its equivalent for the adapter, and an array of sql arguments.

type LimitOffsetOrderer

type LimitOffsetOrderer interface {
	IsOffsetFirst() bool
}

LimitOffsetOrderer is an interface wrapping the optional IsOffsetFirst method.

The IsOffsetFirst returns true is the OFFSET clause has to precede the LIMIT clause. By default the LIMIT is before the OFFSET.

type OffsetBuilder

type OffsetBuilder interface {
	BuildOffset(int) *SQLPart
}

OffsetBuilder is an interface wrapping the optional BuildOffset method.

BuildOffset get an integer and returns a string containing an OFFSET sql clause or its equivalent for the adapter, and an array of sql arguments.

type PlaceholdersReplacer

type PlaceholdersReplacer interface {
	ReplacePlaceholders(string, string) string
}

PlaceholdersReplacer is an interface wrapping the optional ReplacePlaceholders method.

ReplacePlaceholders changes all given placeholders in given sql query with the placeholder used by the database targeted by the adapter.

type ReturningSuffixer added in v1.0.2

type ReturningSuffixer interface {
	ReturningSuffix([]string) string
}

ReturningSuffixer is an interface wrapping the optional ReturningSuffix method.

ReturningSuffixer get a list of columns and returns a suffix to be added to the sql statement by the caller, allowing it to retrieve the values of those columns.

It is intended to replace the use of LastInsertId() when the driver does not support it, or if there are more 'automatic' fields initialized or updated by the database.

type SQLPart

type SQLPart struct {
	Sql       string
	Arguments []interface{}
}

SQLPart is a struct containing a custom part of SQL query builded by an adapter.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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