Repository: go-gorm/gorm
Pull request #4987 (2022-01-10 07:11:08)

chore(deps): bump gorm.io/driver/mysql from 1.2.1 to 1.2.3 in /tests
Bumps [gorm.io/driver/mysql](https://github.com/go-gorm/mysql) from 1.2.1 to 1.2.3.
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/go-gorm/mysql/commit/373b1f04e6b8d18e5b4a611c8e2aa5abc1d75dc2"><code>373b1f0</code></a> feat: get column types by ordinal position order (<a href="https://github-redirect.dependabot.com/go-gorm/mysql/issues/60">#60</a>)</li>
<li><a href="https://github.com/go-gorm/mysql/commit/35981aaa22321f404133fe048931a10336b1bdc8"><code>35981aa</code></a> feat: impl GetTables (<a href="https://github-redirect.dependabot.com/go-gorm/mysql/issues/59">#59</a>)</li>
<li>See full diff in <a href="https://github.com/go-gorm/mysql/compare/v1.2.1...v1.2.3">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=gorm.io/driver/mysql&package-manager=go_modules&previous-version=1.2.1&new-version=1.2.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>


Patch:
diff --git a/schema/field.go b/schema/field.go
index d4f879c..485bbdf 100644
--- a/schema/field.go
+++ b/schema/field.go
@@ -346,7 +346,8 @@ func (schema *Schema) ParseField(fieldStruct reflect.StructField) *Field {
 		}
 	}
 
-	if _, ok := field.TagSettings["EMBEDDED"]; ok || (fieldStruct.Anonymous && !isValuer && (field.Creatable || field.Updatable || field.Readable)) {
+	if _, ok := field.TagSettings["EMBEDDED"]; field.GORMDataType != Time && field.GORMDataType != Bytes &&
+		(ok || (fieldStruct.Anonymous && !isValuer && (field.Creatable || field.Updatable || field.Readable))) {
 		kind := reflect.Indirect(fieldValue).Kind()
 		switch kind {
 		case reflect.Struct:
diff --git a/statement.go b/statement.go
index f69339d..146722a 100644
--- a/statement.go
+++ b/statement.go
@@ -232,6 +232,9 @@ func (stmt *Statement) AddVar(writer clause.Writer, vars ...interface{}) {
 			case reflect.Slice, reflect.Array:
 				if rv.Len() == 0 {
 					writer.WriteString("(NULL)")
+				} else if rv.Type().Elem() == reflect.TypeOf(uint8(0)) {
+					stmt.Vars = append(stmt.Vars, v)
+					stmt.DB.Dialector.BindVarTo(writer, stmt, v)
 				} else {
 					writer.WriteByte('(')
 					for i := 0; i < rv.Len(); i++ {


Test patch:
diff --git a/schema/field_test.go b/schema/field_test.go
index 2cf2d08..8fa46b8 100644
--- a/schema/field_test.go
+++ b/schema/field_test.go
@@ -262,21 +262,24 @@ func TestParseFieldWithPermission(t *testing.T) {
 }
 
 type (
-	ID        int64
-	INT       int
-	INT8      int8
-	INT16     int16
-	INT32     int32
-	INT64     int64
-	UINT      uint
-	UINT8     uint8
-	UINT16    uint16
-	UINT32    uint32
-	UINT64    uint64
-	FLOAT32   float32
-	FLOAT64   float64
-	BOOL      bool
-	STRING    string
+	ID      int64
+	INT     int
+	INT8    int8
+	INT16   int16
+	INT32   int32
+	INT64   int64
+	UINT    uint
+	UINT8   uint8
+	UINT16  uint16
+	UINT32  uint32
+	UINT64  uint64
+	FLOAT32 float32
+	FLOAT64 float64
+	BOOL    bool
+	STRING  string
+	TIME    time.Time
+	BYTES   []byte
+
 	TypeAlias struct {
 		ID
 		INT     `gorm:"column:fint"`
@@ -293,6 +296,8 @@ type (
 		FLOAT64 `gorm:"column:ffloat64"`
 		BOOL    `gorm:"column:fbool"`
 		STRING  `gorm:"column:fstring"`
+		TIME    `gorm:"column:ftime"`
+		BYTES   `gorm:"column:fbytes"`
 	}
 )
 
@@ -318,6 +323,8 @@ func TestTypeAliasField(t *testing.T) {
 		{Name: "FLOAT64", DBName: "ffloat64", BindNames: []string{"FLOAT64"}, DataType: schema.Float, Creatable: true, Updatable: true, Readable: true, Size: 64, Tag: `gorm:"column:ffloat64"`},
 		{Name: "BOOL", DBName: "fbool", BindNames: []string{"BOOL"}, DataType: schema.Bool, Creatable: true, Updatable: true, Readable: true, Tag: `gorm:"column:fbool"`},
 		{Name: "STRING", DBName: "fstring", BindNames: []string{"STRING"}, DataType: schema.String, Creatable: true, Updatable: true, Readable: true, Tag: `gorm:"column:fstring"`},
+		{Name: "TIME", DBName: "ftime", BindNames: []string{"TIME"}, DataType: schema.Time, Creatable: true, Updatable: true, Readable: true, Tag: `gorm:"column:ftime"`},
+		{Name: "BYTES", DBName: "fbytes", BindNames: []string{"BYTES"}, DataType: schema.Bytes, Creatable: true, Updatable: true, Readable: true, Tag: `gorm:"column:fbytes"`},
 	}
 
 	for _, f := range fields {
diff --git a/tests/go.mod b/tests/go.mod
index c3133f3..3233ea9 100644
--- a/tests/go.mod
+++ b/tests/go.mod
@@ -8,7 +8,7 @@ require (
 	github.com/jinzhu/now v1.1.4
 	github.com/lib/pq v1.10.4
 	golang.org/x/crypto v0.0.0-20211209193657-4570a0811e8b // indirect
-	gorm.io/driver/mysql v1.2.1
+	gorm.io/driver/mysql v1.2.3
 	gorm.io/driver/postgres v1.2.3
 	gorm.io/driver/sqlite v1.2.6
 	gorm.io/driver/sqlserver v1.2.1