Documentation ¶
Index ¶
Constants ¶
View Source
const ( FieldTypeBoolean = "sq.BooleanField" FieldTypeJSON = "sq.JSONField" FieldTypeNumber = "sq.NumberField" FieldTypeString = "sq.StringField" FieldTypeTime = "sq.TimeField" FieldTypeEnum = "sq.EnumField" FieldTypeBinary = "sq.BinaryField" FieldConstructorBoolean = "sq.NewBooleanField" FieldConstructorJSON = "sq.NewJSONField" FieldConstructorNumber = "sq.NewNumberField" FieldConstructorString = "sq.NewStringField" FieldConstructorTime = "sq.NewTimeField" FieldConstructorEnum = "sq.NewEnumField" FieldConstructorBinary = "sq.NewBinaryField" )
Field Types
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { // (required) DB URL DB *sql.DB // Package name of the file to be generated Package string // Slice of database schemas that you want to generate tables for Schemas []string // Slice of case-insensitive table names or functions to exclude from generation Exclude []string // Used to log any skipped/unsupported column types Logger sqgen.Logger }
type Table ¶
type TableField ¶
type TableField struct { Name string RawType string RawTypeEx string Type string Constructor string }
TableField represents a field in a database table
In the MySQL information_schema.columns table, the data_type column (mapped into TableField.RawType) has the general type of the column (i.e. char, integer, etc.), but it does not have information on the exact size of the column The information_schema.column_type column (mapped into TableField.RawTypeEx) contains the full data type for the column, including size
We need to have this extra field to distinguish between boolean columns and number columns, since MySQL stores boolean values as tinyint(1), and we can only get the (1) part from information_schema.column_type
func (TableField) Populate ¶
func (field TableField) Populate() TableField
type TablesTemplateData ¶
Click to show internal directories.
Click to hide internal directories.