Documentation ¶
Index ¶
- Constants
- Variables
- func SQLPlaceholderSet(count int) string
- func SQLQuote(src interface{}) (dst string, err error)
- func SqlDriverToDriverName(driver driver.Driver) string
- func SqlSprintf(format string, args ...string) string
- type MetaTable
- func (t *MetaTable) AddColumnDDL(fn schema.FieldName, ft schema.FieldType) (string, error)
- func (t *MetaTable) AsCreateTableDDL() (string, error)
- func (t *MetaTable) ClearTableDDL() string
- func (t *MetaTable) DeleteDML(values []interface{}) (string, error)
- func (t *MetaTable) DropTableDDL() string
- func (t *MetaTable) FieldNames() []schema.FieldName
- func (t MetaTable) ForDriver(newDriver string) (MetaTable, error)
- func (t *MetaTable) UpsertDML(values []interface{}) (string, error)
- func (t *MetaTable) Validate() error
Constants ¶
View Source
const MaxSQLIdentifier = 64
View Source
const MinSQLIdentifier = 2
Variables ¶
View Source
var ErrIdentifierInvalid = errors.New("Identifier can only contain letters, numbers, and underscore")
View Source
var ErrIdentifierStart = errors.New("Identifier must start with a letter")
View Source
var ErrIdentifierTooLong = fmt.Errorf("Identifier must be at most %d characters", MaxSQLIdentifier)
View Source
var ErrIdentifierTooShort = fmt.Errorf("Identifier must be at least %d characters", MinSQLIdentifier)
Functions ¶
func SQLPlaceholderSet ¶
Generates a placeholder string for N values
func SqlDriverToDriverName ¶
The database/sql API doesn't provide a way to get the registry name for a driver from the driver type.
func SqlSprintf ¶
"Replacement" for fmt.Sprintf when splicing together SQL strings in dangerous ways where standard placeholders won't work, such as table and field names
Types ¶
type MetaTable ¶
type MetaTable struct { DriverName string FamilyName schema.FamilyName TableName schema.TableName Fields []schema.NamedFieldType KeyFields schema.PrimaryKey }
func BuildMetaTableFromInput ¶
func (*MetaTable) AddColumnDDL ¶
XXX: should we validate schema with SQLite first? (yes!)
func (*MetaTable) AsCreateTableDDL ¶
func (*MetaTable) ClearTableDDL ¶
func (*MetaTable) DeleteDML ¶
Returns the DML string for a delete for provided fields with placeholders for all of the key fields in proper order.
func (*MetaTable) DropTableDDL ¶
func (*MetaTable) FieldNames ¶
Returns the names of the fields in this table in order
Click to show internal directories.
Click to hide internal directories.