drivers

package
v2.7.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2018 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TinyintAsBool bool

TinyintAsBool is a global that is set from main.go if a user specifies this flag when generating. This flag only applies to MySQL so we're using a global instead, to avoid breaking the interface. If TinyintAsBool is true then tinyint(1) will be mapped in your generated structs to bool opposed to int8.

Functions

func MSSQLBuildQueryString

func MSSQLBuildQueryString(user, pass, dbname, host string, port int, sslmode string) string

MSSQLBuildQueryString builds a query string for MSSQL.

func MySQLBuildQueryString

func MySQLBuildQueryString(user, pass, dbname, host string, port int, sslmode string) string

MySQLBuildQueryString builds a query string for MySQL.

func PostgresBuildQueryString

func PostgresBuildQueryString(user, pass, dbname, host string, port int, sslmode string) string

PostgresBuildQueryString builds a query string.

Types

type MSSQLDriver

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

MSSQLDriver holds the database connection string and a handle to the database connection.

func NewMSSQLDriver

func NewMSSQLDriver(user, pass, dbname, host string, port int, sslmode string) *MSSQLDriver

NewMSSQLDriver takes the database connection details as parameters and returns a pointer to a MSSQLDriver object. Note that it is required to call MSSQLDriver.Open() and MSSQLDriver.Close() to open and close the database connection once an object has been obtained.

func (*MSSQLDriver) Close

func (m *MSSQLDriver) Close()

Close closes the database connection

func (*MSSQLDriver) Columns

func (m *MSSQLDriver) Columns(schema, tableName string) ([]bdb.Column, error)

Columns takes a table name and attempts to retrieve the table information from the database information_schema.columns. It retrieves the column names and column types and returns those as a []Column after TranslateColumnType() converts the SQL types to Go types, for example: "varchar" to "string"

func (*MSSQLDriver) ForeignKeyInfo

func (m *MSSQLDriver) ForeignKeyInfo(schema, tableName string) ([]bdb.ForeignKey, error)

ForeignKeyInfo retrieves the foreign keys for a given table name.

func (*MSSQLDriver) IndexPlaceholders

func (m *MSSQLDriver) IndexPlaceholders() bool

IndexPlaceholders returns true to indicate MS SQL supports indexed placeholders

func (*MSSQLDriver) LeftQuote

func (m *MSSQLDriver) LeftQuote() byte

LeftQuote is the quoting character for the left side of the identifier

func (*MSSQLDriver) Open

func (m *MSSQLDriver) Open() error

Open opens the database connection using the connection string

func (*MSSQLDriver) PrimaryKeyInfo

func (m *MSSQLDriver) PrimaryKeyInfo(schema, tableName string) (*bdb.PrimaryKey, error)

PrimaryKeyInfo looks up the primary key for a table.

func (*MSSQLDriver) RightQuote

func (m *MSSQLDriver) RightQuote() byte

RightQuote is the quoting character for the right side of the identifier

func (*MSSQLDriver) TableNames

func (m *MSSQLDriver) TableNames(schema string, whitelist, blacklist []string) ([]string, error)

TableNames connects to the postgres database and retrieves all table names from the information_schema where the table schema is schema. It uses a whitelist and blacklist.

func (*MSSQLDriver) TranslateColumnType

func (m *MSSQLDriver) TranslateColumnType(c bdb.Column) bdb.Column

TranslateColumnType converts postgres database types to Go types, for example "varchar" to "string" and "bigint" to "int64". It returns this parsed data as a Column object.

func (*MSSQLDriver) UseLastInsertID

func (m *MSSQLDriver) UseLastInsertID() bool

UseLastInsertID returns false for mssql

func (*MSSQLDriver) UseTopClause

func (m *MSSQLDriver) UseTopClause() bool

UseTopClause returns true to indicate MS SQL supports SQL TOP clause

type MockDriver

type MockDriver struct{}

MockDriver is a mock implementation of the bdb driver Interface

func (*MockDriver) Close

func (m *MockDriver) Close()

Close mimics a database close call

func (*MockDriver) Columns

func (m *MockDriver) Columns(schema, tableName string) ([]bdb.Column, error)

Columns returns a list of mock columns

func (*MockDriver) ForeignKeyInfo

func (m *MockDriver) ForeignKeyInfo(schema, tableName string) ([]bdb.ForeignKey, error)

ForeignKeyInfo returns a list of mock foreignkeys

func (*MockDriver) IndexPlaceholders

func (m *MockDriver) IndexPlaceholders() bool

IndexPlaceholders returns true to indicate fake support of indexed placeholders

func (*MockDriver) LeftQuote

func (m *MockDriver) LeftQuote() byte

LeftQuote is the quoting character for the left side of the identifier

func (*MockDriver) Open

func (m *MockDriver) Open() error

Open mimics a database open call and returns nil for no error

func (*MockDriver) PrimaryKeyInfo

func (m *MockDriver) PrimaryKeyInfo(schema, tableName string) (*bdb.PrimaryKey, error)

PrimaryKeyInfo returns mock primary key info for the passed in table name

func (*MockDriver) RightQuote

func (m *MockDriver) RightQuote() byte

RightQuote is the quoting character for the right side of the identifier

func (*MockDriver) TableNames

func (m *MockDriver) TableNames(schema string, whitelist, blacklist []string) ([]string, error)

TableNames returns a list of mock table names

func (*MockDriver) TranslateColumnType

func (m *MockDriver) TranslateColumnType(c bdb.Column) bdb.Column

TranslateColumnType converts a column to its "null." form if it is nullable

func (*MockDriver) UseLastInsertID

func (m *MockDriver) UseLastInsertID() bool

UseLastInsertID returns a database mock LastInsertID compatibility flag

func (*MockDriver) UseTopClause

func (m *MockDriver) UseTopClause() bool

UseTopClause returns a database mock SQL TOP clause compatibility flag

type MySQLDriver

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

MySQLDriver holds the database connection string and a handle to the database connection.

func NewMySQLDriver

func NewMySQLDriver(user, pass, dbname, host string, port int, sslmode string) *MySQLDriver

NewMySQLDriver takes the database connection details as parameters and returns a pointer to a MySQLDriver object. Note that it is required to call MySQLDriver.Open() and MySQLDriver.Close() to open and close the database connection once an object has been obtained.

func (*MySQLDriver) Close

func (m *MySQLDriver) Close()

Close closes the database connection

func (*MySQLDriver) Columns

func (m *MySQLDriver) Columns(schema, tableName string) ([]bdb.Column, error)

Columns takes a table name and attempts to retrieve the table information from the database information_schema.columns. It retrieves the column names and column types and returns those as a []Column after TranslateColumnType() converts the SQL types to Go types, for example: "varchar" to "string"

func (*MySQLDriver) ForeignKeyInfo

func (m *MySQLDriver) ForeignKeyInfo(schema, tableName string) ([]bdb.ForeignKey, error)

ForeignKeyInfo retrieves the foreign keys for a given table name.

func (*MySQLDriver) IndexPlaceholders

func (m *MySQLDriver) IndexPlaceholders() bool

IndexPlaceholders returns false to indicate MySQL doesnt support indexed placeholders

func (*MySQLDriver) LeftQuote

func (m *MySQLDriver) LeftQuote() byte

LeftQuote is the quoting character for the left side of the identifier

func (*MySQLDriver) Open

func (m *MySQLDriver) Open() error

Open opens the database connection using the connection string

func (*MySQLDriver) PrimaryKeyInfo

func (m *MySQLDriver) PrimaryKeyInfo(schema, tableName string) (*bdb.PrimaryKey, error)

PrimaryKeyInfo looks up the primary key for a table.

func (*MySQLDriver) RightQuote

func (m *MySQLDriver) RightQuote() byte

RightQuote is the quoting character for the right side of the identifier

func (*MySQLDriver) TableNames

func (m *MySQLDriver) TableNames(schema string, whitelist, blacklist []string) ([]string, error)

TableNames connects to the postgres database and retrieves all table names from the information_schema where the table schema is public.

func (*MySQLDriver) TranslateColumnType

func (m *MySQLDriver) TranslateColumnType(c bdb.Column) bdb.Column

TranslateColumnType converts postgres database types to Go types, for example "varchar" to "string" and "bigint" to "int64". It returns this parsed data as a Column object.

func (*MySQLDriver) UseLastInsertID

func (m *MySQLDriver) UseLastInsertID() bool

UseLastInsertID returns false for postgres

func (*MySQLDriver) UseTopClause

func (m *MySQLDriver) UseTopClause() bool

UseTopClause returns false to indicate MySQL doesnt support SQL TOP clause

type PostgresDriver

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

PostgresDriver holds the database connection string and a handle to the database connection.

func NewPostgresDriver

func NewPostgresDriver(user, pass, dbname, host string, port int, sslmode string) *PostgresDriver

NewPostgresDriver takes the database connection details as parameters and returns a pointer to a PostgresDriver object. Note that it is required to call PostgresDriver.Open() and PostgresDriver.Close() to open and close the database connection once an object has been obtained.

func (*PostgresDriver) Close

func (p *PostgresDriver) Close()

Close closes the database connection

func (*PostgresDriver) Columns

func (p *PostgresDriver) Columns(schema, tableName string) ([]bdb.Column, error)

Columns takes a table name and attempts to retrieve the table information from the database information_schema.columns. It retrieves the column names and column types and returns those as a []Column after TranslateColumnType() converts the SQL types to Go types, for example: "varchar" to "string"

func (*PostgresDriver) ForeignKeyInfo

func (p *PostgresDriver) ForeignKeyInfo(schema, tableName string) ([]bdb.ForeignKey, error)

ForeignKeyInfo retrieves the foreign keys for a given table name.

func (*PostgresDriver) IndexPlaceholders

func (p *PostgresDriver) IndexPlaceholders() bool

IndexPlaceholders returns true to indicate PSQL supports indexed placeholders

func (*PostgresDriver) LeftQuote

func (p *PostgresDriver) LeftQuote() byte

LeftQuote is the quoting character for the left side of the identifier

func (*PostgresDriver) Open

func (p *PostgresDriver) Open() error

Open opens the database connection using the connection string

func (*PostgresDriver) PrimaryKeyInfo

func (p *PostgresDriver) PrimaryKeyInfo(schema, tableName string) (*bdb.PrimaryKey, error)

PrimaryKeyInfo looks up the primary key for a table.

func (*PostgresDriver) RightQuote

func (p *PostgresDriver) RightQuote() byte

RightQuote is the quoting character for the right side of the identifier

func (*PostgresDriver) TableNames

func (p *PostgresDriver) TableNames(schema string, whitelist, blacklist []string) ([]string, error)

TableNames connects to the postgres database and retrieves all table names from the information_schema where the table schema is schema. It uses a whitelist and blacklist.

func (*PostgresDriver) TranslateColumnType

func (p *PostgresDriver) TranslateColumnType(c bdb.Column) bdb.Column

TranslateColumnType converts postgres database types to Go types, for example "varchar" to "string" and "bigint" to "int64". It returns this parsed data as a Column object.

func (*PostgresDriver) UseLastInsertID

func (p *PostgresDriver) UseLastInsertID() bool

UseLastInsertID returns false for postgres

func (*PostgresDriver) UseTopClause

func (m *PostgresDriver) UseTopClause() bool

UseTopClause returns false to indicate PSQL doesnt support SQL TOP clause

Jump to

Keyboard shortcuts

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