Documentation
¶
Index ¶
- Constants
- type SqlBuilder
- type SqlBuilderOption
- func WithCommentGenerate() SqlBuilderOption
- func WithDialect(dialect sqltemplates.SqlDialect) SqlBuilderOption
- func WithMysql() SqlBuilderOption
- func WithPluralTableName() SqlBuilderOption
- func WithPointerAsValue() SqlBuilderOption
- func WithPostgresql() SqlBuilderOption
- func WithSliceAsJson() SqlBuilderOption
- func WithSqlLowercase() SqlBuilderOption
- func WithSqlTag(sqlTag string) SqlBuilderOption
- func WithSqlUppercase() SqlBuilderOption
- func WithSqlite() SqlBuilderOption
- func WithSqlserver() SqlBuilderOption
- func WithTagNameAsColumn() SqlBuilderOption
Constants ¶
const (
SqlTagDefault = "sql"
)
Tag prefixes
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SqlBuilder ¶
type SqlBuilder struct {
// contains filtered or unexported fields
}
SqlBuilder ...
func (SqlBuilder) GetTableName ¶
func (s SqlBuilder) GetTableName(t interface{}) (string, string)
GetTableName read from TableNameFn or parse table name from model as snake_case return object name and table name
func (*SqlBuilder) MappingTables ¶
func (s *SqlBuilder) MappingTables(m map[string]string)
MappingTables ...
func (SqlBuilder) RemoveTable ¶
func (s SqlBuilder) RemoveTable(tb interface{}) string
RemoveTable ...
type SqlBuilderOption ¶
type SqlBuilderOption interface {
// contains filtered or unexported methods
}
SqlBuilderOption ...
func WithCommentGenerate ¶
func WithCommentGenerate() SqlBuilderOption
WithCommentGenerate default is off
func WithDialect ¶
func WithDialect(dialect sqltemplates.SqlDialect) SqlBuilderOption
WithDialect ...
func WithPluralTableName ¶
func WithPluralTableName() SqlBuilderOption
WithPluralTableName Table name in plural convention - ending with `s`
func WithPointerAsValue ¶
func WithPointerAsValue() SqlBuilderOption
WithPointerAsValue maps pointer fields by their pointed-to value type rather than emitting "POINTER", so *time.Time becomes TEXT (ISO8601), *string TEXT, *int INTEGER and so on, even when the pointer is nil. Pointers to structs other than time.Time (e.g. *gofeed.Person, *gofeed.Image) are stored as JSON TEXT columns.
func WithSliceAsJson ¶
func WithSliceAsJson() SqlBuilderOption
WithSliceAsJson stores slice and map fields as a JSON blob in a TEXT column instead of emitting the opaque "UNSPECIFIED" type. For structs like gofeed this turns Categories []string, Links []string, Custom map[string]string, Authors []*Person etc. into queryable SQLite json1 TEXT columns. A per-field `json` tag directive, when present, still takes precedence.
func WithTagNameAsColumn ¶
func WithTagNameAsColumn() SqlBuilderOption
WithTagNameAsColumn uses the first value of the tag (the text before the first comma, as read by encoding/json and sqlx) as the column name instead of the snake-cased Go field name. This lets structs carrying only `json` tag names (e.g. gofeed) round-trip with sqlx's reflectx.NewMapper("json"). A `column:` directive in the tag still overrides the name when present.