Merge pull request #489 from nemec784/fix/warnings/receiver_name
golint: receiver name %s should be consistent with ...
This commit is contained in:
commit
90b9a22c7c
|
@ -577,14 +577,14 @@ func (db *oracle) DropTableSql(tableName string) string {
|
||||||
return fmt.Sprintf("DROP TABLE `%s`", tableName)
|
return fmt.Sprintf("DROP TABLE `%s`", tableName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *oracle) CreateTableSql(table *core.Table, tableName, storeEngine, charset string) string {
|
func (db *oracle) CreateTableSql(table *core.Table, tableName, storeEngine, charset string) string {
|
||||||
var sql string
|
var sql string
|
||||||
sql = "CREATE TABLE "
|
sql = "CREATE TABLE "
|
||||||
if tableName == "" {
|
if tableName == "" {
|
||||||
tableName = table.Name
|
tableName = table.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
sql += b.Quote(tableName) + " ("
|
sql += db.Quote(tableName) + " ("
|
||||||
|
|
||||||
pkList := table.PrimaryKeys
|
pkList := table.PrimaryKeys
|
||||||
|
|
||||||
|
@ -593,7 +593,7 @@ func (b *oracle) CreateTableSql(table *core.Table, tableName, storeEngine, chars
|
||||||
/*if col.IsPrimaryKey && len(pkList) == 1 {
|
/*if col.IsPrimaryKey && len(pkList) == 1 {
|
||||||
sql += col.String(b.dialect)
|
sql += col.String(b.dialect)
|
||||||
} else {*/
|
} else {*/
|
||||||
sql += col.StringNoPk(b)
|
sql += col.StringNoPk(db)
|
||||||
//}
|
//}
|
||||||
sql = strings.TrimSpace(sql)
|
sql = strings.TrimSpace(sql)
|
||||||
sql += ", "
|
sql += ", "
|
||||||
|
@ -601,17 +601,17 @@ func (b *oracle) CreateTableSql(table *core.Table, tableName, storeEngine, chars
|
||||||
|
|
||||||
if len(pkList) > 0 {
|
if len(pkList) > 0 {
|
||||||
sql += "PRIMARY KEY ( "
|
sql += "PRIMARY KEY ( "
|
||||||
sql += b.Quote(strings.Join(pkList, b.Quote(",")))
|
sql += db.Quote(strings.Join(pkList, db.Quote(",")))
|
||||||
sql += " ), "
|
sql += " ), "
|
||||||
}
|
}
|
||||||
|
|
||||||
sql = sql[:len(sql)-2] + ")"
|
sql = sql[:len(sql)-2] + ")"
|
||||||
if b.SupportEngine() && storeEngine != "" {
|
if db.SupportEngine() && storeEngine != "" {
|
||||||
sql += " ENGINE=" + storeEngine
|
sql += " ENGINE=" + storeEngine
|
||||||
}
|
}
|
||||||
if b.SupportCharset() {
|
if db.SupportCharset() {
|
||||||
if len(charset) == 0 {
|
if len(charset) == 0 {
|
||||||
charset = b.URI().Charset
|
charset = db.URI().Charset
|
||||||
}
|
}
|
||||||
if len(charset) > 0 {
|
if len(charset) > 0 {
|
||||||
sql += " DEFAULT CHARSET " + charset
|
sql += " DEFAULT CHARSET " + charset
|
||||||
|
|
42
statement.go
42
statement.go
|
@ -809,9 +809,9 @@ func (statement *Statement) ForUpdate() *Statement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Select replace select
|
// Select replace select
|
||||||
func (s *Statement) Select(str string) *Statement {
|
func (statement *Statement) Select(str string) *Statement {
|
||||||
s.selectStr = str
|
statement.selectStr = str
|
||||||
return s
|
return statement
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cols generate "col1, col2" statement
|
// Cols generate "col1, col2" statement
|
||||||
|
@ -1031,11 +1031,11 @@ func (statement *Statement) genCreateTableSQL() string {
|
||||||
statement.StoreEngine, statement.Charset)
|
statement.StoreEngine, statement.Charset)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Statement) genIndexSQL() []string {
|
func (statement *Statement) genIndexSQL() []string {
|
||||||
var sqls []string
|
var sqls []string
|
||||||
tbName := s.TableName()
|
tbName := statement.TableName()
|
||||||
quote := s.Engine.Quote
|
quote := statement.Engine.Quote
|
||||||
for idxName, index := range s.RefTable.Indexes {
|
for idxName, index := range statement.RefTable.Indexes {
|
||||||
if index.Type == core.IndexType {
|
if index.Type == core.IndexType {
|
||||||
sql := fmt.Sprintf("CREATE INDEX %v ON %v (%v);", quote(indexName(tbName, idxName)),
|
sql := fmt.Sprintf("CREATE INDEX %v ON %v (%v);", quote(indexName(tbName, idxName)),
|
||||||
quote(tbName), quote(strings.Join(index.Cols, quote(","))))
|
quote(tbName), quote(strings.Join(index.Cols, quote(","))))
|
||||||
|
@ -1049,41 +1049,41 @@ func uniqueName(tableName, uqeName string) string {
|
||||||
return fmt.Sprintf("UQE_%v_%v", tableName, uqeName)
|
return fmt.Sprintf("UQE_%v_%v", tableName, uqeName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Statement) genUniqueSQL() []string {
|
func (statement *Statement) genUniqueSQL() []string {
|
||||||
var sqls []string
|
var sqls []string
|
||||||
tbName := s.TableName()
|
tbName := statement.TableName()
|
||||||
for _, index := range s.RefTable.Indexes {
|
for _, index := range statement.RefTable.Indexes {
|
||||||
if index.Type == core.UniqueType {
|
if index.Type == core.UniqueType {
|
||||||
sql := s.Engine.dialect.CreateIndexSql(tbName, index)
|
sql := statement.Engine.dialect.CreateIndexSql(tbName, index)
|
||||||
sqls = append(sqls, sql)
|
sqls = append(sqls, sql)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sqls
|
return sqls
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Statement) genDelIndexSQL() []string {
|
func (statement *Statement) genDelIndexSQL() []string {
|
||||||
var sqls []string
|
var sqls []string
|
||||||
tbName := s.TableName()
|
tbName := statement.TableName()
|
||||||
for idxName, index := range s.RefTable.Indexes {
|
for idxName, index := range statement.RefTable.Indexes {
|
||||||
var rIdxName string
|
var rIdxName string
|
||||||
if index.Type == core.UniqueType {
|
if index.Type == core.UniqueType {
|
||||||
rIdxName = uniqueName(tbName, idxName)
|
rIdxName = uniqueName(tbName, idxName)
|
||||||
} else if index.Type == core.IndexType {
|
} else if index.Type == core.IndexType {
|
||||||
rIdxName = indexName(tbName, idxName)
|
rIdxName = indexName(tbName, idxName)
|
||||||
}
|
}
|
||||||
sql := fmt.Sprintf("DROP INDEX %v", s.Engine.Quote(rIdxName))
|
sql := fmt.Sprintf("DROP INDEX %v", statement.Engine.Quote(rIdxName))
|
||||||
if s.Engine.dialect.IndexOnTable() {
|
if statement.Engine.dialect.IndexOnTable() {
|
||||||
sql += fmt.Sprintf(" ON %v", s.Engine.Quote(s.TableName()))
|
sql += fmt.Sprintf(" ON %v", statement.Engine.Quote(statement.TableName()))
|
||||||
}
|
}
|
||||||
sqls = append(sqls, sql)
|
sqls = append(sqls, sql)
|
||||||
}
|
}
|
||||||
return sqls
|
return sqls
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Statement) genAddColumnStr(col *core.Column) (string, []interface{}) {
|
func (statement *Statement) genAddColumnStr(col *core.Column) (string, []interface{}) {
|
||||||
quote := s.Engine.Quote
|
quote := statement.Engine.Quote
|
||||||
sql := fmt.Sprintf("ALTER TABLE %v ADD %v;", quote(s.TableName()),
|
sql := fmt.Sprintf("ALTER TABLE %v ADD %v;", quote(statement.TableName()),
|
||||||
col.String(s.Engine.dialect))
|
col.String(statement.Engine.dialect))
|
||||||
return sql, []interface{}{}
|
return sql, []interface{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue