diff --git a/.github/workflows/apollo/docker-compose.yml b/.github/workflows/apollo/docker-compose.yml index 5e7377871..942e6fdd1 100644 --- a/.github/workflows/apollo/docker-compose.yml +++ b/.github/workflows/apollo/docker-compose.yml @@ -20,7 +20,7 @@ services: #APOLLO_PORTAL_DB_PASSWORD: 'apollo' apollo-db: - image: "loads/mysql:5.7" + image: "mysql:5.7" container_name: apollo-db environment: TZ: Asia/Shanghai @@ -36,7 +36,7 @@ services: - apollo-dbdata apollo-dbdata: - image: "loads/alpine:3.8" + image: "alpine:3.8" container_name: apollo-dbdata volumes: - /var/lib/mysql diff --git a/.github/workflows/ci-main.yml b/.github/workflows/ci-main.yml index c5c734400..6eeee5dd9 100644 --- a/.github/workflows/ci-main.yml +++ b/.github/workflows/ci-main.yml @@ -37,9 +37,9 @@ jobs: # Service containers to run with `code-test` services: # Etcd service. - # docker run -d --name etcd -p 2379:2379 -e ALLOW_NONE_AUTHENTICATION=yes loads/etcd:3.4.24 + # docker run -d --name etcd -p 2379:2379 -e ALLOW_NONE_AUTHENTICATION=yes bitnami/etcd:3.4.24 etcd: - image: loads/etcd:3.4.24 + image: bitnami/etcd:3.4.24 env: ALLOW_NONE_AUTHENTICATION: yes ports: @@ -47,7 +47,7 @@ jobs: # Redis backend server. redis: - image : loads/redis:7.0 + image : redis:7.0 options: >- --health-cmd "redis-cli ping" --health-interval 10s @@ -62,9 +62,9 @@ jobs: # -p 3306:3306 \ # -e MYSQL_DATABASE=test \ # -e MYSQL_ROOT_PASSWORD=12345678 \ - # loads/mysql:5.7 + # mysql:5.7 mysql: - image: loads/mysql:5.7 + image: mysql:5.7 env: MYSQL_DATABASE : test MYSQL_ROOT_PASSWORD: 12345678 @@ -73,7 +73,7 @@ jobs: # MariaDb backend server. mariadb: - image: loads/mariadb:10.4 + image: mariadb:10.4 env: MARIADB_DATABASE: test MARIADB_ROOT_PASSWORD: 12345678 @@ -87,9 +87,9 @@ jobs: # -e POSTGRES_USER=postgres \ # -e POSTGRES_DB=test \ # -v postgres:/Users/john/Temp/postgresql/data \ - # loads/postgres:13 + # postgres:17-alpine postgres: - image: loads/postgres:13 + image: postgres:17-alpine env: POSTGRES_PASSWORD: 12345678 POSTGRES_USER: postgres @@ -184,7 +184,7 @@ jobs: - 5236:5236 zookeeper: - image: loads/zookeeper:3.8 + image: zookeeper:3.8 ports: - 2181:2181 diff --git a/.github/workflows/nacos/docker-compose.yml b/.github/workflows/nacos/docker-compose.yml index f10a1101b..3e69daa7c 100644 --- a/.github/workflows/nacos/docker-compose.yml +++ b/.github/workflows/nacos/docker-compose.yml @@ -2,7 +2,7 @@ version: "3.8" services: nacos: - image: loads/nacos-server:v2.1.2 + image: nacos/nacos-server:v2.1.2 container_name: nacos env_file: - ./env/nacos.env diff --git a/contrib/drivers/pgsql/pgsql_z_unit_issue_test.go b/contrib/drivers/pgsql/pgsql_z_unit_issue_test.go index 47122c461..c0c9ad8f2 100644 --- a/contrib/drivers/pgsql/pgsql_z_unit_issue_test.go +++ b/contrib/drivers/pgsql/pgsql_z_unit_issue_test.go @@ -171,3 +171,37 @@ func Test_Issue3668(t *testing.T) { t.AssertNil(err) }) } + +type Issue4033Status int + +const ( + Issue4033StatusA Issue4033Status = 1 +) + +func (s Issue4033Status) String() string { + return "somevalue" +} + +func (s Issue4033Status) Int64() int64 { + return int64(s) +} + +// https://github.com/gogf/gf/issues/4033 +func Test_Issue4033(t *testing.T) { + var ( + sqlText = gtest.DataContent("issues", "issue4033.sql") + table = "test_enum" + ) + if _, err := db.Exec(ctx, sqlText); err != nil { + gtest.Fatal(err) + } + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + query := g.Map{ + "status": g.Slice{Issue4033StatusA}, + } + _, err := db.Model(table).Ctx(ctx).Where(query).All() + t.AssertNil(err) + }) +} diff --git a/contrib/drivers/pgsql/testdata/issues/issue4033.sql b/contrib/drivers/pgsql/testdata/issues/issue4033.sql new file mode 100644 index 000000000..57f97252c --- /dev/null +++ b/contrib/drivers/pgsql/testdata/issues/issue4033.sql @@ -0,0 +1,5 @@ +CREATE TABLE test_enum ( + id int8 NOT NULL, + status int2 DEFAULT 0 NOT NULL, + CONSTRAINT test_enum_pk PRIMARY KEY (id) +); \ No newline at end of file diff --git a/database/gdb/gdb_func.go b/database/gdb/gdb_func.go index ce5258e99..ba402e5c9 100644 --- a/database/gdb/gdb_func.go +++ b/database/gdb/gdb_func.go @@ -856,20 +856,9 @@ func handleSliceAndStructArgsForSql( return s }) - default: + // Special struct handling. + case reflect.Struct: switch oldArg.(type) { - // Do not append Raw arg to args but directly into the sql. - case Raw, *Raw: - var counter = 0 - newSql = gstr.ReplaceFunc(newSql, `?`, func(s string) string { - counter++ - if counter == index+insertHolderCount+1 { - return gconv.String(oldArg) - } - return s - }) - continue - // The underlying driver supports time.Time/*time.Time types. case time.Time, *time.Time: newArgs = append(newArgs, oldArg) @@ -892,6 +881,24 @@ func handleSliceAndStructArgsForSql( } } newArgs = append(newArgs, oldArg) + + default: + switch oldArg.(type) { + // Do not append Raw arg to args but directly into the sql. + case Raw, *Raw: + var counter = 0 + newSql = gstr.ReplaceFunc(newSql, `?`, func(s string) string { + counter++ + if counter == index+insertHolderCount+1 { + return gconv.String(oldArg) + } + return s + }) + continue + + default: + } + newArgs = append(newArgs, oldArg) } } return