Documentation ¶
Index ¶
Constants ¶
const ( // unknown type, no information about parameter requirements ParamUnknown parameterType = iota // requires no parameters in MySQL declaration ParamNone // requires no parameters or length (int > 0) in MySQL declaration ParamMayLength // requires length (int > 0) in MySQL declaration ParamMustLength // requires valid values as parameters in MySQL declaration ParamValues )
Variables ¶
This section is empty.
Functions ¶
func IsBinary ¶
IsBinary reports whether the row value was retrieved using the binary protocol.
MySQL results retrieved with prepared statements or Query with additional arguments use the binary protocol. The results are typed, the driver will use the closest matching Go type. A plain Query call with only the query itself will not use the binary protocol but the text protocol. The results are all strings in that case.
Types ¶
type Column ¶
type Column interface { // Name returns the column name, matching that of a call to Columns() in database/sql Name() string // MysqlType returns the raw sql type name without parameters and modifiers MysqlType() string // IsNumber returns true if the column contains numbers (one of integer, decimal or floating point) IsNumber() bool // IsInteger returns true if the column contains integers IsInteger() bool // IsFloatingPoint returns true if the column contains floating point numbers IsFloatingPoint() bool // IsDecimal returns true if the column contains decimal numbers IsDecimal() bool // IsText returns true if the column contains textual data IsText() bool // IsBlob returns true if the column contains binary blobs IsBlob() bool // IsTime returns true if the column contains temporal data IsTime() bool // IsPrimaryKey returns true if the column is marked as part of a primary key (*). IsPrimaryKey() bool // IsUniqueKey returns true if the column is marked as part of a unique key (*). IsUniqueKey() bool // IsMultipleKey returns true if the column is marked as part of a regular key (*). IsMultipleKey() bool // IsNotNull returns true if the column is marked as NOT NULL (*). IsNotNull() bool // IsUnsigned returns true if the column is marked as UNSIGNED (*). IsUnsigned() bool // IsZerofill returns true if the column is marked as ZEROFILL (*). IsZerofill() bool // IsBinary returns true if the column is marked as BINARY (*). IsBinary() bool // IsAutoIncrement returns true if the column is marked as AUTO_INCREMENT (*). IsAutoIncrement() bool // derived from mysqlField.decimals Decimals() int // size of a varchar, or display width for a fixed size type Length() uint32 // MysqlParameters returns the category of parameters the SQL type expects in MysqlDeclaration. MysqlParameters() parameterType // MysqlDeclaration returns a type declaration usable in a CREATE TABLE statement. MysqlDeclaration(params ...interface{}) (string, error) // ReflectGoType returns the smallest Go type able to represent all possible regular values. // The returned types assume a non-NULL value and may cause problems // on conversion (e.g. MySQL DATE "0000-00-00", which is not mappable to Go). ReflectGoType() (reflect.Type, error) // ReflectSqlType returns a Go type able to contain the SQL type, including null values. // The returned types may cause problems on conversion // (e.g. MySQL DATE "0000-00-00", which is not mappable to Go). // The returned type assumes IsNotNull() to be false when forceNullable is set // and attempts to return a nullable type (e.g. sql.NullString instead of string). ReflectSqlType(forceNullable bool) (reflect.Type, error) }
Column represents the column of a MySQL result. The methods below postfixed with (*) return information for MySQL internal flags. Please note that I can't say if these are trustworthy (esp. IsNotNull), they come directly from MySQL. At least for SCHEMA information, MySQL can report false metadata, I don't know if this is different for results.