From 2255193c571a50f8d144130145c3deee6c9f3a16 Mon Sep 17 00:00:00 2001 From: CyJaySong Date: Mon, 30 Oct 2023 09:23:20 +0800 Subject: [PATCH] Fix code --- dialects/dameng.go | 4 ++-- dialects/mssql.go | 6 +++--- dialects/mysql.go | 4 ++-- dialects/oracle.go | 4 ++-- dialects/postgres.go | 6 +++--- engine.go | 2 +- internal/statements/order_by.go | 2 +- names/mapper.go | 2 +- tags/tag.go | 2 +- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/dialects/dameng.go b/dialects/dameng.go index 23d1836a..38f571fb 100644 --- a/dialects/dameng.go +++ b/dialects/dameng.go @@ -618,8 +618,8 @@ func (db *dameng) SQLType(c *schemas.Column) string { res = t } - hasLen1 := (c.Length > 0) - hasLen2 := (c.Length2 > 0) + hasLen1 := c.Length > 0 + hasLen2 := c.Length2 > 0 if hasLen2 { res += "(" + strconv.FormatInt(c.Length, 10) + "," + strconv.FormatInt(c.Length2, 10) + ")" diff --git a/dialects/mssql.go b/dialects/mssql.go index e4edc466..26d76c45 100644 --- a/dialects/mssql.go +++ b/dialects/mssql.go @@ -334,7 +334,7 @@ func (db *mssql) SQLType(c *schemas.Column) string { case schemas.TimeStampz: res = "DATETIMEOFFSET" c.Length = 7 - case schemas.MediumInt, schemas.TinyInt, schemas.SmallInt, schemas.UnsignedMediumInt, schemas.UnsignedTinyInt, schemas.UnsignedSmallInt: + case schemas.MediumInt, schemas.SmallInt, schemas.UnsignedMediumInt, schemas.UnsignedTinyInt, schemas.UnsignedSmallInt: res = schemas.Int case schemas.Text, schemas.MediumText, schemas.TinyText, schemas.LongText, schemas.Json: res = db.defaultVarchar + "(MAX)" @@ -377,8 +377,8 @@ func (db *mssql) SQLType(c *schemas.Column) string { return res } - hasLen1 := (c.Length > 0) - hasLen2 := (c.Length2 > 0) + hasLen1 := c.Length > 0 + hasLen2 := c.Length2 > 0 if hasLen2 { res += "(" + strconv.FormatInt(c.Length, 10) + "," + strconv.FormatInt(c.Length2, 10) + ")" diff --git a/dialects/mysql.go b/dialects/mysql.go index 2c061a14..d11c728b 100644 --- a/dialects/mysql.go +++ b/dialects/mysql.go @@ -326,8 +326,8 @@ func (db *mysql) SQLType(c *schemas.Column) string { res = t } - hasLen1 := (c.Length > 0) - hasLen2 := (c.Length2 > 0) + hasLen1 := c.Length > 0 + hasLen2 := c.Length2 > 0 if res == schemas.BigInt && !hasLen1 && !hasLen2 { c.Length = 20 diff --git a/dialects/oracle.go b/dialects/oracle.go index ac0fb944..5f614b1a 100644 --- a/dialects/oracle.go +++ b/dialects/oracle.go @@ -585,8 +585,8 @@ func (db *oracle) SQLType(c *schemas.Column) string { res = t } - hasLen1 := (c.Length > 0) - hasLen2 := (c.Length2 > 0) + hasLen1 := c.Length > 0 + hasLen2 := c.Length2 > 0 if hasLen2 { res += "(" + strconv.FormatInt(c.Length, 10) + "," + strconv.FormatInt(c.Length2, 10) + ")" diff --git a/dialects/postgres.go b/dialects/postgres.go index 99574459..6e379583 100644 --- a/dialects/postgres.go +++ b/dialects/postgres.go @@ -957,8 +957,8 @@ func (db *postgres) SQLType(c *schemas.Column) string { // for bool, we don't need length information return res } - hasLen1 := (c.Length > 0) - hasLen2 := (c.Length2 > 0) + hasLen1 := c.Length > 0 + hasLen2 := c.Length2 > 0 if hasLen2 { res += "(" + strconv.FormatInt(c.Length, 10) + "," + strconv.FormatInt(c.Length2, 10) + ")" @@ -1185,7 +1185,7 @@ WHERE n.nspname= s.table_schema AND c.relkind = 'r' AND c.relname = $1%s AND f.a col.IsPrimaryKey = true } - col.Nullable = (isNullable == "YES") + col.Nullable = isNullable == "YES" switch strings.ToLower(dataType) { case "character varying", "string": diff --git a/engine.go b/engine.go index 0cbfdede..671f00f2 100644 --- a/engine.go +++ b/engine.go @@ -1206,7 +1206,7 @@ func (engine *Engine) Insert(beans ...interface{}) (int64, error) { func (engine *Engine) InsertOne(bean interface{}) (int64, error) { session := engine.NewSession() defer session.Close() - return session.InsertOne(bean) + return session.Insert(bean) } // Update records, bean's non-empty fields are updated contents, diff --git a/internal/statements/order_by.go b/internal/statements/order_by.go index 54a3c6e0..04197fb7 100644 --- a/internal/statements/order_by.go +++ b/internal/statements/order_by.go @@ -50,7 +50,7 @@ var ErrNoColumnName = errors.New("no column name") func (statement *Statement) writeOrderBy(w *builder.BytesWriter, orderBy orderBy) error { switch t := orderBy.orderStr.(type) { - case (*builder.Expression): + case *builder.Expression: if _, err := fmt.Fprint(w.Builder, statement.dialect.Quoter().Replace(t.Content())); err != nil { return err } diff --git a/names/mapper.go b/names/mapper.go index 69f67171..4f5910e8 100644 --- a/names/mapper.go +++ b/names/mapper.go @@ -149,7 +149,7 @@ func isASCIIUpper(r rune) bool { func toASCIIUpper(r rune) rune { if 'a' <= r && r <= 'z' { - r -= ('a' - 'A') + r -= 'a' - 'A' } return r } diff --git a/tags/tag.go b/tags/tag.go index 024c9c18..55f0b7c7 100644 --- a/tags/tag.go +++ b/tags/tag.go @@ -163,7 +163,7 @@ func PKTagHandler(ctx *Context) error { // NULLTagHandler describes null tag handler func NULLTagHandler(ctx *Context) error { - ctx.col.Nullable = (strings.ToUpper(ctx.preTag) != "NOT") + ctx.col.Nullable = strings.ToUpper(ctx.preTag) != "NOT" return nil }