File size: 1,777 Bytes
530729e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
package dialect
import "fmt"
type commonDialect struct {
delimiter string
delimiter2 string
}
func (c commonDialect) Insert(comp *SQLComponent) string {
comp.prepareInsert(c.delimiter, c.delimiter2)
return comp.Statement
}
func (c commonDialect) Delete(comp *SQLComponent) string {
comp.Statement = "delete from " + c.WrapTableName(comp) + comp.getWheres(c.delimiter, c.delimiter2)
return comp.Statement
}
func (c commonDialect) Update(comp *SQLComponent) string {
comp.prepareUpdate(c.delimiter, c.delimiter2)
return comp.Statement
}
func (c commonDialect) Count(comp *SQLComponent) string {
comp.prepareUpdate(c.delimiter, c.delimiter2)
return comp.Statement
}
func (c commonDialect) Select(comp *SQLComponent) string {
comp.Statement = "select " + comp.getFields(c.delimiter, c.delimiter2) + " from " + c.WrapTableName(comp) + comp.getJoins(c.delimiter, c.delimiter2) +
comp.getWheres(c.delimiter, c.delimiter2) + comp.getGroupBy() + comp.getOrderBy() + comp.getLimit() + comp.getOffset()
return comp.Statement
}
func (c commonDialect) ShowColumns(table string) string {
return fmt.Sprintf("select * from information_schema.columns where table_name = '%s'", table)
}
func (c commonDialect) GetName() string {
return "common"
}
func (c commonDialect) WrapTableName(comp *SQLComponent) string {
return c.delimiter + comp.TableName + c.delimiter2
}
func (c commonDialect) ShowTables() string {
return "show tables"
}
func (c commonDialect) ShowColumnsWithComment(schema, table string) string {
return ""
}
func (c commonDialect) GetDelimiter() string {
return c.delimiter
}
func (c commonDialect) GetDelimiter2() string {
return c.delimiter2
}
func (c commonDialect) GetDelimiters() []string {
return []string{c.delimiter, c.delimiter2}
}
|