Sql builder generator for postgres database.
This commit is contained in:
parent
3190d6f933
commit
92edc96c9a
10 changed files with 403 additions and 9 deletions
|
|
@ -75,13 +75,10 @@ func (c *baseColumn) setTableName(table string) error {
|
|||
|
||||
func (c *baseColumn) SerializeSqlForColumnList(out *bytes.Buffer) error {
|
||||
if c.table != "" {
|
||||
_ = out.WriteByte('`')
|
||||
_, _ = out.WriteString(c.table)
|
||||
_, _ = out.WriteString("`.")
|
||||
_, _ = out.WriteString(".")
|
||||
}
|
||||
_, _ = out.WriteString("`")
|
||||
_, _ = out.WriteString(c.name)
|
||||
_ = out.WriteByte('`')
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -147,7 +144,7 @@ func DateTimeColumn(name string, nullable NullableColumn) NonAliasColumn {
|
|||
return dc
|
||||
}
|
||||
|
||||
type integerColumn struct {
|
||||
type IntegerColumn struct {
|
||||
baseColumn
|
||||
isExpression
|
||||
}
|
||||
|
|
@ -158,7 +155,7 @@ func IntColumn(name string, nullable NullableColumn) NonAliasColumn {
|
|||
if !validIdentifierName(name) {
|
||||
panic("Invalid column name in int column")
|
||||
}
|
||||
ic := &integerColumn{}
|
||||
ic := &IntegerColumn{}
|
||||
ic.name = name
|
||||
ic.nullable = nullable
|
||||
return ic
|
||||
|
|
|
|||
|
|
@ -131,11 +131,9 @@ func (t *Table) ForceIndex(index string) *Table {
|
|||
// Generates the sql string for the current table expression. Note: the
|
||||
// generated string may not be a valid/executable sql statement.
|
||||
func (t *Table) SerializeSql(database string, out *bytes.Buffer) error {
|
||||
_, _ = out.WriteString("`")
|
||||
_, _ = out.WriteString(database)
|
||||
_, _ = out.WriteString("`.`")
|
||||
_, _ = out.WriteString(".")
|
||||
_, _ = out.WriteString(t.Name())
|
||||
_, _ = out.WriteString("`")
|
||||
|
||||
if t.forcedIndex != "" {
|
||||
if !validIdentifierName(t.forcedIndex) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue