6426 Commits

Author SHA1 Message Date
fb89f8bdf8 feat(cmd/gf): gen dao suppport for dm database (#4776) 2026-05-28 15:40:18 +08:00
cae8ce3b51 fix: update gf cli to v2.10.2 (#4773)
Automated changes by
[create-pull-request](https://github.com/peter-evans/create-pull-request)
GitHub action

Co-authored-by: hailaz <hailaz@users.noreply.github.com>
2026-05-14 16:03:35 +08:00
9a91bd203b fix: v2.10.2 (#4772)
fixed #4750
fixed #4757
fixed #4767
v2.10.2 contrib/drivers/pgsql/v2.10.2 contrib/config/consul/v2.10.2 contrib/config/polaris/v2.10.2 contrib/drivers/clickhouse/v2.10.2 contrib/trace/otlphttp/v2.10.2 contrib/drivers/dm/v2.10.2 contrib/drivers/gaussdb/v2.10.2 contrib/drivers/mariadb/v2.10.2 contrib/trace/otlpgrpc/v2.10.2 contrib/drivers/mssql/v2.10.2 contrib/drivers/mysql/v2.10.2 contrib/drivers/oceanbase/v2.10.2 contrib/sdk/httpclient/v2.10.2 contrib/drivers/oracle/v2.10.2 contrib/config/nacos/v2.10.2 contrib/registry/nacos/v2.10.2 contrib/metric/otelmetric/v2.10.2 contrib/drivers/sqlitecgo/v2.10.2 contrib/drivers/tidb/v2.10.2 contrib/config/apollo/v2.10.2 contrib/drivers/sqlite/v2.10.2 contrib/registry/zookeeper/v2.10.2 contrib/rpc/grpcx/v2.10.2 contrib/nosql/redis/v2.10.2 contrib/registry/consul/v2.10.2 contrib/registry/file/v2.10.2 contrib/config/kubecm/v2.10.2 contrib/registry/etcd/v2.10.2 contrib/registry/polaris/v2.10.2
2026-05-14 16:00:16 +08:00
72733e0bad refactor(cmd/gf): improve code structure for readability and maintainability (#4771)
Refactor the code structure to enhance readability and maintainability
without altering functionality.

fixed #4750 #4757 #4767

另外使用`gf init -r github.com/gogf/template-single my-project`方式没有问题

合并后v2.10.2生效
2026-05-14 15:34:43 +08:00
d44e082ff5 fix: update gf cli to v2.10.1 (#4770)
Automated changes by
[create-pull-request](https://github.com/peter-evans/create-pull-request)
GitHub action

Co-authored-by: gqcn <gqcn@users.noreply.github.com>
2026-05-14 14:31:30 +08:00
078c1bc7f9 feat: new version v2.10.1 (#4769)
This pull request updates the GoFrame framework and its related drivers
and configuration modules from version v2.10.0 to v2.10.1 across
multiple `go.mod` files and documentation. The main goal is to ensure
all dependencies consistently use the latest patch version, improving
compatibility and stability.

Dependency version updates:

* Updated `github.com/gogf/gf/v2` and related driver dependencies from
v2.10.0 to v2.10.1 in the following `go.mod` files:
  - `cmd/gf/go.mod`
  - `contrib/config/apollo/go.mod`
  - `contrib/config/consul/go.mod`
  - `contrib/config/kubecm/go.mod`
  - `contrib/config/nacos/go.mod`
  - `contrib/config/polaris/go.mod`
  - `contrib/drivers/clickhouse/go.mod`
  - `contrib/drivers/dm/go.mod`
  - `contrib/drivers/gaussdb/go.mod`
  - `contrib/drivers/mariadb/go.mod`
  - `contrib/drivers/mssql/go.mod`
  - `contrib/drivers/mysql/go.mod`
  - `contrib/drivers/oceanbase/go.mod`
  - `contrib/drivers/oracle/go.mod`
  - `contrib/drivers/pgsql/go.mod`
  - `contrib/drivers/sqlite/go.mod`
  - `contrib/drivers/sqlitecgo/go.mod`
  - `contrib/drivers/tidb/go.mod`

Documentation updates:

* Updated the contributors badge in `README.MD` and `README.zh_CN.MD` to
reflect version v2.10.1.
[[1]](diffhunk://#diff-01e6d9ffed056a02cae8d8a0ec5d476a64d017bf85c0d5a94bb23ca21f33f5aaL49-R49)
[[2]](diffhunk://#diff-c93759cb9a9500f20e551c741eb167fc72825fd638d36121357feb8253ce6ac1L49-R49)
contrib/drivers/tidb/v2.10.1 contrib/config/apollo/v2.10.1 contrib/registry/file/v2.10.1 contrib/config/consul/v2.10.1 contrib/drivers/mssql/v2.10.1 contrib/trace/otlphttp/v2.10.1 contrib/config/polaris/v2.10.1 contrib/drivers/dm/v2.10.1 contrib/registry/etcd/v2.10.1 contrib/registry/nacos/v2.10.1 contrib/drivers/mysql/v2.10.1 contrib/drivers/sqlitecgo/v2.10.1 contrib/trace/otlpgrpc/v2.10.1 contrib/config/kubecm/v2.10.1 contrib/drivers/sqlite/v2.10.1 contrib/rpc/grpcx/v2.10.1 contrib/drivers/mariadb/v2.10.1 contrib/drivers/oracle/v2.10.1 contrib/drivers/clickhouse/v2.10.1 contrib/registry/consul/v2.10.1 contrib/nosql/redis/v2.10.1 contrib/drivers/pgsql/v2.10.1 contrib/drivers/gaussdb/v2.10.1 contrib/metric/otelmetric/v2.10.1 contrib/registry/polaris/v2.10.1 contrib/drivers/oceanbase/v2.10.1 contrib/sdk/httpclient/v2.10.1 contrib/config/nacos/v2.10.1 v2.10.1 contrib/registry/zookeeper/v2.10.1
2026-05-14 13:26:50 +08:00
94623a19d1 feat(cmd/gf): add gendao fileNameCase and ai coding stuffs (#4764)
This pull request introduces new and updated prompt and instruction
documents for the experimental OPSX workflow system, providing detailed,
step-by-step guidance for proposing, applying, archiving, and exploring
changes using OpenSpec. The changes standardize workflow guardrails,
clarify user interactions, and ensure consistent artifact handling
across all major workflow operations.

**OPSX Workflow Prompt Additions and Enhancements:**

* **Propose Workflow**
- Adds `.agents/prompts/opsx/propose.md` outlining how to propose a new
change, including artifact creation order, dependency handling, and user
input requirements. Emphasizes using schema-defined instructions and
templates, and clarifies that context/rules are for internal guidance
only.

* **Apply Workflow**
- Introduces `.agents/prompts/opsx/apply.md` detailing the process for
implementing tasks from an OpenSpec change. Covers change selection,
context reading, task loop execution, state handling, and output
formatting. Includes guardrails for ambiguity, blockers, and minimal
change scope.

* **Archive Workflow**
- Adds `.agents/prompts/opsx/archive.md` specifying the process for
archiving completed changes, including artifact/task completion checks,
delta spec sync assessment, user prompts for incomplete work, and
summary output. Ensures robust handling of archive naming conflicts and
user confirmations.

* **Explore Mode**
- Adds `.agents/prompts/opsx/explore.md` describing "explore mode" for
non-implementation discovery, problem investigation, and requirements
clarification. Outlines stance, behaviors, and guardrails for thinking
and artifact capture without code changes.

**Documentation Standardization:**

* **Markdown Formatting Standards**
- Adds `.agents/instructions/markdown-format.instructions.md` to
standardize markdown document formatting, including heading levels, code
block usage, list formatting, and language-specific punctuation rules
for improved clarity and consistency.
2026-04-25 17:47:05 +08:00
cb7cfa58ab fix: guard os.Args access for wasm which panics when building (#4762)
This pull request improves the reliability and safety of server restart
and reload operations by ensuring the correct retrieval of the current
executable path and process arguments. It replaces direct usage of
`os.Args[0]` with a more robust approach using `gfile.SelfPath()`, and
adds error handling for cases where the executable path cannot be
determined. Additionally, it introduces a helper function to safely
obtain process arguments, and removes an unnecessary import.

**Executable Path Handling and Error Checking:**

- Replaced usage of `os.Args[0]` with `gfile.SelfPath()` throughout the
server admin and process management code to reliably determine the
current executable path; added checks and error responses when the path
cannot be determined.
[[1]](diffhunk://#diff-0d174b149c56c4aa7ffeba2be94d16dc1b8000933f1f2a2e6bf011acdad3272fL122-R134)
[[2]](diffhunk://#diff-0d174b149c56c4aa7ffeba2be94d16dc1b8000933f1f2a2e6bf011acdad3272fL168-R184)
[[3]](diffhunk://#diff-3b4265be7ef0335b832dacfc2fc7ddc0f9dfae5b81340ff57d2b6a526c60d9e1L62-R65)
- Added early returns in initialization functions if `os.Args` is empty,
preventing potential panics or misbehavior when the argument list is
missing.
[[1]](diffhunk://#diff-0aa99f033274ea60b9c466ae4fc98d0816ec13781d8ec787fb3ef106a49a79ecR35-R37)
[[2]](diffhunk://#diff-5782fa47aa858b8e8358fd50353b050ee30418b7844b36e313e9c6d01188c092R47-R49)

**Process Argument Handling:**

- Introduced the `getCurrentProcessArgs()` helper function to safely
return process arguments (excluding the program name), ensuring correct
behavior even if no arguments are provided. Updated process creation
calls to use this helper.

**Code Cleanup:**

- Removed an unused import of the `os` package from
`ghttp_server_admin.go`.

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-04-22 20:44:57 +08:00
1878202625 test(contrib/drivers/mariadb): add layer 3 features and issue regression tests (#4724)
## Summary

- Port 5 feature tests: duplicate-key handling
(OnDuplicate/OnDuplicateEx/Save), JSON field operations, row-level
locking (Lock/LockUpdate/LockShared with transactions), master-slave
configuration, table metadata inspection
- Port 1 partition test: RANGE partitioning with Partition() clause
(adapted from MySQL baseline)
- Port 30 issue regression tests from MySQL baseline
- Includes 14 testdata SQL files for issue-specific table schemas

Layer 3 tests cover MariaDB-specific adaptations where needed (e.g.,
SKIP LOCKED requires MariaDB 10.6+ — commented out for compatibility,
LOCK IN SHARE MODE instead of FOR SHARE for older versions).

All tests are structurally aligned with the MySQL driver baseline.
Package and import references are adapted for MariaDB.

ref #4689

Co-authored-by: John Guo <claymore1986@gmail.com>
2026-04-10 09:38:43 +08:00
bb71ccfd4c fix(database/gdb): strip quote chars from schema in Model.TableFields (#4730)
## Summary

When performing cross-database JOINs with soft-delete, the schema name
parsed from `` `schema`.`table` `` format retains database-specific
quote characters. These quoted schema names break `information_schema`
WHERE clause queries in `TableFields` lookups.

This PR strips quote characters from `usedSchema` in
`Model.TableFields()`, matching the existing unquoting pattern used for
`usedTable` via `guessPrimaryTableName`.

## Changes

- `database/gdb/gdb_model_utility.go`: Add quote-stripping for
`usedSchema` using `gstr.Trim` with database-specific quote chars from
`GetChars()`

## Test

Existing `Test_Issue2338` in MySQL
(`contrib/drivers/mysql/mysql_z_unit_issue_test.go:685`) covers this
case. The MariaDB version exists in PR #4724 branch
(`contrib/drivers/mariadb/mariadb_z_unit_issue_test.go:688`), not yet
merged. Once both PRs are merged, the MariaDB test will also validate
this fix.

closes #4725

Co-authored-by: John Guo <claymore1986@gmail.com>
2026-04-10 09:05:17 +08:00
f67b2dca26 fix(contrib/drivers/mysql): use unreachable port for nodeInvalid test config (#4726)
## Summary
- Change nodeInvalid port from 3307 to 3316 (default 3306 + 10) so the
connection is guaranteed to fail as intended
- Port 3307 may collide with a running MariaDB instance in CI, causing
nodeInvalid to accidentally connect to a live database

ref #4689
2026-03-24 17:51:21 +08:00
68b02218d7 test(contrib/drivers/mariadb): add infrastructure, core and model tests (#4719)
## Summary

- Add full test infrastructure (`mariadb_unit_init_test.go`) with
MariaDB-specific helpers (createTable, createInitTable, dropTable)
matching the MySQL test baseline
- Port 4 basic tests from MySQL: `Test_New`, `Test_DB_Ping`,
`Test_DB_Query`, `Test_DB_Exec`
- Port 47 core tests covering CRUD operations, raw SQL, schema
switching, and DB/TX method parity
- Port 55 model tests covering Model API: Fields, Where, Scan, Save,
Replace, InsertIgnore, InsertGetId, OmitEmpty, Distinct,
Count/Min/Max/Avg/Sum, HasField, chained operations, testdata SQL-based
scenarios and more
- Add 5 testdata SQL files required by model tests (copied from MySQL
baseline)

All tests are structurally identical to the MySQL driver baseline. SQL
syntax is standard and shared. Package and import references are adapted
for MariaDB.

ref #4689

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-03-24 17:50:05 +08:00
766579d868 test(contrib/drivers/mariadb): add transaction, where, hook and ctx tests (#4720)
## Summary

- Port 28 transaction tests: Begin/Commit/Rollback, nested SavePoint,
transaction propagation (Required/Nested/NotSupported), timeout, panic
recovery, concurrent transactions
- Port 41 where-condition tests:
Where/WhereOr/WhereNot/WhereIn/WhereBetween, prefix handling, complex
AND/OR combinations, NULL checks, struct/map/slice parameter types
- Port 11 hook tests: HookSelect/HookInsert/HookUpdate/HookDelete for
both Model and raw SQL paths, hook chaining and context propagation
- Port 8 ctx tests: context propagation through Model/TX operations,
context-based logging with traceId verification

All tests are structurally identical to the MySQL driver baseline. SQL
syntax is standard and shared. Package and import references are adapted
for MariaDB.

ref #4689
2026-03-12 11:16:14 +08:00
030cd84836 test(contrib/drivers/mariadb): add softtime, with, scanlist, union and do tests (#4721)
## Summary

- Port 48 soft-time tests: soft create/update/delete with
timestamp/datetime/date types, SoftTime switches
(SoftTimeTypeOff/Delete/Timestamp), Unscoped, ForceDelete, joined
queries with soft-delete
- Port 19 With/ScanList tests: With/WithAll for eager loading of
hasOne/hasMany/belongsTo relations, ScanList for manual relation
mapping, nested With
- Port 12 union tests: Union/UnionAll with various parameter forms
(string/Model/subquery), combined with OrderBy, Limit, Where conditions
- Port 12 gdb.Do tests: DoSelect/DoInsert/DoUpdate/DoDelete raw
operation hooks, batch insert, InsertIgnore/InsertGetId/Replace via
DoInsert option

Includes testdata SQL files for With relation table schemas (with_tpl).
Soft-time tests create tables inline via SQL, no separate testdata files
needed.

All tests are structurally identical to the MySQL driver baseline. SQL
syntax is standard and shared. Package and import references are adapted
for MariaDB.

ref #4689
2026-03-12 11:15:42 +08:00
6314cd4c89 test(contrib/drivers/mariadb): add builder, struct, join, batch, cache and omit tests (#4722)
## Summary

- Port 25 SQL builder tests: WhereBuilder chaining, complex
Where/WhereOr/WhereNot combinations, nested builders, Build() output
verification
- Port 9 subquery tests: subquery in Where/Having/From, correlated
subqueries, subquery with Model builder
- Port 11 struct-mapping tests: Scan to struct/slice, embedded structs,
tag-based field mapping, pointer fields, OmitEmpty with struct input
- Port 12 join tests: LeftJoin/RightJoin/InnerJoin, multi-table joins,
join with Where/Order/Fields, subquery joins, testdata SQL-based join
scenarios
- Port 8 batch operation tests: Batch insert/update/replace/save with
configurable batch size, conflict handling
- Port 4 cache tests: query result caching, cache invalidation on
update/delete, cache duration, ClearCache
- Port 4 OmitNil/OmitEmpty tests: nil field omission in insert/update,
zero-value vs nil distinction

All tests are structurally identical to the MySQL driver baseline. SQL
syntax is standard and shared. Package and import references are adapted
for MariaDB.

ref #4689
2026-03-12 11:15:17 +08:00
0588009c40 test(contrib/drivers/mariadb): add pagination, error, concurrent, rawtype and sharding tests (#4723)
## Summary

- Port 11 pagination tests: Page/Limit/Offset, combined with
Where/Order, boundary conditions (page 0, large offset), Count with
pagination
- Port 8 error-handling tests: invalid table/field names, syntax errors,
duplicate key, connection errors, error wrapping and message
verification
- Port 5 concurrency tests: parallel read/write with goroutines and
WaitGroup, concurrent transactions, race condition verification
- Port 6 raw-type tests: custom type scanning, time.Time handling,
json.RawMessage, sql.NullString/NullInt64, []byte fields
- Port 6 sharding/table-name tests: dynamic table name via Sharding
callback, table name with prefix, schema.table format

All tests are structurally identical to the MySQL driver baseline. SQL
syntax is standard and shared. Package and import references are adapted
for MariaDB.

ref #4689
2026-03-12 11:14:48 +08:00
6204c132c7 test(contrib/drivers/mysql): add pagination and error handling tests (#4703)
## Summary
- Add comprehensive pagination tests (Limit, Offset, Page, ForPage)
- Add error handling tests for invalid operations
- Add tests for edge cases and boundary conditions

**Test coverage added:**
- Pagination: ~28 test functions
- Error handling: ~20 test functions

Ref #4689

## Test plan
```bash
cd contrib/drivers/mysql
go test -v -run "TestModel_Pagination|TestModel_Error|TestModel_InvalidOperation"
```
2026-02-27 20:00:25 +08:00
a4b80e8680 fix(contrib/drivers/pgsql): preserve bytea data integrity on read and write (#4678)
## Summary

Fix two bytea data corruption issues in the PostgreSQL driver:

1. **READ path** (fixes #4677): `CheckLocalTypeForField` and
`ConvertValueForLocal` had no case for plain `bytea` type, causing it to
fall through to the Core layer which incorrectly mapped it to
`LocalTypeString`. Binary data was then converted to string via
`gconv.String()`, corrupting the bytes on retrieval.

2. **WRITE path** (fixes #4231): `ConvertValueForField` applied
PostgreSQL array syntax conversion (`[` → `{`, `]` → `}`) to all slice
types including `[]byte` for bytea columns, corrupting bytes `0x5B`
(`[`) and `0x5D` (`]`) on insertion.

## Changes

- **`contrib/drivers/pgsql/pgsql_convert.go`**:
  - `CheckLocalTypeForField`: Add `case "bytea"` → `LocalTypeBytes`
- `ConvertValueForLocal`: Add `case "bytea"` to preserve `[]byte` as-is
- `ConvertValueForField`: Skip `[]`→`{}` replacement for `[]byte` with
`bytea` field type

- **`contrib/drivers/pgsql/pgsql_z_unit_convert_test.go`**:
- Add unit tests for `bytea` type in `CheckLocalTypeForField`,
`ConvertValueForLocal`, and `ConvertValueForField`

- **`contrib/drivers/pgsql/pgsql_z_unit_issue_test.go`**:
- Add `Test_Issue4677`: End-to-end round-trip test with various binary
data (including 0x00, 0x5B, 0x5D, 0xFF)
- Add `Test_Issue4231`: Targeted test for 0x5D byte corruption on write

## Test plan

- [x] `Test_CheckLocalTypeForField` - bytea returns `LocalTypeBytes`
- [x] `Test_ConvertValueForLocal` - bytea preserves `[]byte` as-is
- [x] `Test_ConvertValueForField` - bytea skips array syntax replacement
- [x] `Test_Issue4677` - full DB round-trip with binary data
- [x] `Test_Issue4231` - write path preserves 0x5B/0x5D bytes
- [x] Full pgsql test suite passes with no regressions

closes #4677
closes #4231

ref #4689
2026-02-27 16:22:43 +08:00
0e1cb15dc0 fix(os/gstructs): strip tag options in TagPriorityName to avoid field name pollution (#4681)
## Summary
- Fix `TagPriorityName()` to strip comma-separated tag options (e.g.,
`omitempty`) from tag values
- Before: `json:"user_name,omitempty"` → field name =
`user_name,omitempty`
- After: `json:"user_name,omitempty"` → field name = `user_name`
- Aligns with `structcache.genPriorityTagAndFieldName()` which already
handles this correctly
- When tag name is empty (e.g., `gconv:",omitempty"`), continues to next
priority tag instead of breaking

## Test plan
- [x] Reproduced bug: `RuleFuncInput.Field` was `user_name,omitempty`
instead of `user_name`
- [x] Verified fix: field name correctly extracted as `user_name`
- [x] Verified fallthrough: `gconv:",omitempty"` + `json:"name"` → uses
`name`
- [x] Existing `Test_Fields_TagPriorityName` passes
- [x] Full `os/gstructs` test suite passes
- [x] Full `util/gvalid` test suite passes
- [x] Full `util/gconv` test suite passes

closes #4665
2026-02-27 16:14:26 +08:00
612e545ae2 fix(databse/gdb): use COUNT(1) if fields number is greater than 1 even when parameter useFieldForCount is true in AllAndCount/ScanAndCount (#4701)
## Summary
Fix bug where `AllAndCount(true)` with multiple fields generates invalid
SQL `COUNT(field1, field2, ...)` causing syntax error.

## Root Cause
When `useFieldForCount=true`, the COUNT query inherits the fields
configuration from the model:
```go
// Before (buggy code)
if !useFieldForCount {
    countModel.fields = []any{Raw("1")}
}
// When useFieldForCount=true, fields remain as ["id", "nickname"]
// Generates: SELECT COUNT(id, nickname) FROM table 
```

## Fix
Always use `COUNT(1)` regardless of `useFieldForCount` parameter since
COUNT() accepts only one argument:
```go
// After (fixed code)
// Always use COUNT(1) for counting, regardless of useFieldForCount.
// COUNT() accepts only one argument, so we can't use multiple fields.
countModel.fields = []any{Raw("1")}
```

Applied to both `AllAndCount()` and `ScanAndCount()` methods.

## Tests
Added `Test_Issue4698` with 5 test cases:
1. AllAndCount(true) with multiple fields
2. AllAndCount(false) with multiple fields (baseline)
3. ScanAndCount with multiple fields
4. AllAndCount with single field
5. AllAndCount with WHERE condition

All tests verify that COUNT generates valid SQL and returns correct
count.

## Related
Fixes #4698
Ref #4703 (discovered during pagination test development)
2026-02-27 16:12:58 +08:00
bbdd442954 fix(database/gdb): treat negative Limit/Page/Offset values as zero (#4702)
## Summary
Fix bug where negative values in `Limit()`, `Page()`, and `Offset()`
methods generate invalid SQL causing database errors.

## Root Cause
The methods don't validate negative input:
- `Limit(-1)` generates `LIMIT -1` → SQL error
- `Page(1, -10)` generates `LIMIT -10` → SQL error  
- `Offset(-5)` generates `OFFSET -5` → SQL error

## Fix
Treat all negative values as zero (safe default):

**Limit() method**:
```go
case 1:
    if limit[0] < 0 { limit[0] = 0 }
case 2:
    if limit[0] < 0 { limit[0] = 0 }
    if limit[1] < 0 { limit[1] = 0 }
```

**Page() method**:
```go
if limit < 0 { limit = 0 }
```

**Offset() method**:
```go
if offset < 0 { offset = 0 }
```

## Behavior Changes
- `Limit(-1)` → `Limit(0)` (no limit)
- `Limit(-10, -5)` → `Limit(0, 0)` (no offset, no limit)
- `Page(1, -10)` → `Page(1, 0)` (no results)
- `Offset(-5)` → `Offset(0)` (no offset)

## Documentation
Added "Note: Negative values are treated as zero" to all three methods.

## Tests
Added `Test_Issue4699` in `database/gdb/gdb_z_unit_issue_test.go` with 7
test cases:
1. Limit with single negative parameter
2. Limit with two negative parameters
3. Limit with mixed parameters (negative start, positive limit)
4. Page with negative limit
5. Page with negative limit on page 2
6. Offset with negative value
7. Offset with positive value (sanity check)

## Related
Fixes #4699
Ref #4703 (discovered during pagination test development)
2026-02-27 16:00:53 +08:00
6686bd65a2 test(contrib/drivers/mysql): enhance transaction tests (#4704)
## Summary
- Add nested transaction tests
- Add transaction propagation tests
- Add transaction rollback/commit behavior tests
- Add transaction context handling tests

**Test coverage added:** ~25 test functions

Ref #4689

## Test plan
```bash
cd contrib/drivers/mysql
go test -v -run "TestTX_Nested|TestTX_Propagation|TestTX_Transaction"
```
2026-02-27 15:56:16 +08:00
319a812934 test(contrib/drivers/mysql): enhance data type tests (#4705)
## Summary
- Add comprehensive tests for various data types (int, float, string,
[]byte, time, etc.)
- Add struct field type conversion tests
- Add JSON/XML data type tests
- Add binary data handling tests

**Test coverage added:** ~28 test functions

Ref #4689

## Test plan
```bash
cd contrib/drivers/mysql
go test -v -run "TestModel_.*Type|TestModel_.*Convert"
```
2026-02-27 15:53:44 +08:00
307c6ec307 test(contrib/drivers/mysql): enhance complex query tests (#4707)
## Summary
- Add comprehensive JOIN tests (Inner/Left/Right Join)
- Add SubQuery tests
- Add complex WHERE condition tests (Or/Group/Having)
- Add advanced query builder tests

**Test coverage added:** ~26 test functions across 3 files

Ref #4689

## Test plan
```bash
cd contrib/drivers/mysql
go test -v -run "TestModel_Join|TestModel_SubQuery|TestModel_Where.*Complex"
```
2026-02-27 15:52:41 +08:00
bac637570d test(contrib/drivers/mysql): add MySQL-specific feature tests (#4709)
## Summary
- Add ON DUPLICATE KEY UPDATE tests (basic, increment, batch,
conditional, transaction)
- Add MySQL JSON data type tests (insert/update/query, JSON_EXTRACT,
JSON_CONTAINS, struct scanning)
- Add MySQL partition tests (RANGE, HASH, LIST partitioning with CRUD
and transactions)

**Test coverage added:** ~25 test functions across 3 files (Layer 3)

Ref #4689

## Test plan
```bash
cd contrib/drivers/mysql
go test -v -run "Test_OnDuplicateKeyUpdate|Test_DataType_Json|Test_Partition"
```
2026-02-27 15:52:06 +08:00
c8a11f7f6e test(contrib/drivers/mysql): add concurrent/Hook/Ctx tests (#4708)
## Summary
- Add concurrent operation tests
- Add Hook mechanism tests (Insert/Update/Delete/Select)
- Add Context propagation tests
- Add race condition tests

**Test coverage added:** ~28 test functions across 5 files

Ref #4689

## Test plan
```bash
cd contrib/drivers/mysql
go test -v -race -run "TestModel_Concurrent|TestModel_Hook|TestModel_Ctx"
```
2026-02-26 16:28:20 +08:00
e0c032d1b1 fix(database/gdb): handle empty string in Fields() gracefully (#4700)
## Summary
Fix bug where `Fields("")` with empty string generates invalid SQL
`SELECT FROM table`.

## Root Cause
`mappingAndFilterToTableFields` method doesn't skip empty strings when
processing fields:
- `gstr.SplitAndTrim("", ",")` returns empty array
- No fields added to query
- Results in invalid SQL: `SELECT FROM table`

## Fix
Skip empty string fields in `mappingAndFilterToTableFields` (line
97-100):
```go
// Skip empty string fields
if fieldStr == "" {
    continue
}
```

## Behavior Changes
- `Fields("")` → SELECT * FROM table (uses default)
- `Fields("", "id")` → SELECT id FROM table (ignores empty string)
- `Fields("id", "", "nickname")` → SELECT id, nickname FROM table

## Tests
Added `Test_Issue4697` with 3 scenarios covering all cases above.

## Related
Fixes #4697
Ref #4703 (discovered during pagination test development)
2026-02-26 16:27:00 +08:00
063264ebff test(contrib/drivers/mysql): add Lock/Omit/Cache/Batch tests (#4706)
## Summary
- Add Lock/LockUpdate/LockShared tests
- Add OmitNil/OmitEmpty/OmitNilData tests
- Add Cache mechanism tests
- Add Batch operation tests

**Test coverage added:** ~34 test functions across 4 files

Ref #4689

## Test plan
```bash
cd contrib/drivers/mysql
go test -v -run "TestModel_Lock|TestModel_Omit|TestModel_Cache|TestModel_Batch"
```
2026-02-26 09:53:35 +08:00
02abc515a3 test(contrib/drivers/gaussdb): add soft time, with, scanlist test coverage (#4686)
## Summary
- Port 3 test files and 4 testdata SQL files from PgSQL driver to
GaussDB driver
- Add `gaussdb_z_unit_feature_soft_time_test.go` (15 tests): soft time
create/update/delete, bool/int/datetime soft delete
- Add `gaussdb_z_unit_feature_with_test.go` (6 tests): With/WithAll ORM
relation queries, multiple dependency levels
- Add `gaussdb_z_unit_feature_scanlist_test.go` (9 tests): ScanList for
1:1, 1:N, N:N relation mapping
- Add 4 testdata SQL files for With relation tests
- **30 new test functions**, ~3,941 net new lines

## Test plan
- [x] `go build ./...` passes
- [x] `gofmt` and `gci` applied
- [x] No remaining `pgsql` references in new files
- [ ] Run full test suite against GaussDB instance

ref #4689

---------

Co-authored-by: John Guo <claymore1986@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-26 09:51:52 +08:00
be7851c664 test(contrib/drivers/pgsql): add SoftTime, With, ScanList test coverage (#4676)
## Summary
- Add 3 new test files for pgsql driver (39 test functions, ~3800 lines)
- `pgsql_z_unit_feature_soft_time_test.go`: 15 tests — soft delete
(SoftDeleted/Unscoped), auto time fields
(CreatedAt/UpdatedAt/DeletedAt), time format options
- `pgsql_z_unit_feature_with_test.go`: 17 tests — With relation queries
(one-to-one, one-to-many, many-to-many), nested With, WithAll,
conditional With
- `pgsql_z_unit_feature_scanlist_test.go`: 7 tests — ScanList relation
mapping for struct slices
- Add testdata SQL templates for With tests

**PostgreSQL adaptations from MySQL:**
- `AUTO_INCREMENT` → `SERIAL/BIGSERIAL`
- `datetime` → `timestamp`
- MySQL backticks → PostgreSQL double quotes for identifiers
- Timestamp format handling for soft time fields

## Test plan
- [x] Run `go test -v -run "Test_Model_Soft" -count=1` in
`contrib/drivers/pgsql`
- [x] Run `go test -v -run "Test_Model_With" -count=1` in
`contrib/drivers/pgsql`
- [x] Run `go test -v -run "Test_Model_ScanList" -count=1` in
`contrib/drivers/pgsql`

ref #4689
2026-02-26 09:49:48 +08:00
dc08920a7f feat(gcrypto/gsha512): add sha512 implements (#4667)
Signed-off-by: yuluo-yx <yuluo08290126@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-26 09:47:08 +08:00
1ab0b18115 feat(os/gcfg): add GetEffective method with standard config priority (#4673)
## Summary
- Add `GetEffective` and `MustGetEffective` methods following 12-Factor
App config priority
- Priority: Command line > Environment variables > Config file > Default
value
- Add clarifying notes to existing `GetWithEnv`/`GetWithCmd` methods
- Add comprehensive unit tests

## Test plan
- [x] All gcfg unit tests pass (44 tests)
- [x] New `Test_GetEffective` covers 6 scenarios:
  - Config file only
  - Env overrides config
  - Cmd overrides env
  - Default value fallback
  - Empty string override (industry standard)
  - Key only in env

Closes #4650

---------

Co-authored-by: John Guo <claymore1986@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-26 09:45:56 +08:00
ebd78fb533 test(contrib/drivers/pgsql): add transaction, where, hook, ctx test coverage (#4675)
## Summary
- Add 4 new test files for pgsql driver to align with MySQL driver test
coverage (86 test functions, ~3100 lines)
- `pgsql_z_unit_transaction_test.go`: 40 tests — TX CRUD, nested
transactions, propagation behaviors
(Required/RequiresNew/Nested/NotSupported/Mandatory/Never/Supports),
isolation levels (ReadCommitted/RepeatableRead/Serializable), savepoints
- `pgsql_z_unit_model_where_test.go`: 35 tests — Where variants
(string/slice/map/struct/gmap), comparisons (LT/LTE/GT/GTE), IN/NotIn,
Between, Like, Null, EXISTS/NOT EXISTS subqueries, WherePrefix with JOIN
- `pgsql_z_unit_feature_hook_test.go`: 6 tests —
Select/Insert/Update/Delete hooks, Count with hook, hook chaining and
error handling
- `pgsql_z_unit_feature_ctx_test.go`: 5 tests — context propagation,
trace logging (SpanId/TraceId), transaction context, timeout
cancellation
- Migrate `Test_Model_Where` from `pgsql_z_unit_model_test.go` to
dedicated where test file with expanded coverage (2 → 30+ sub-tests)

**PostgreSQL adaptations from MySQL:**
- `?` → `$N` placeholders for raw SQL
- `REPLACE INTO` → `OnConflict("id").Save()` for upsert
- `AUTO_INCREMENT` → `bigserial`
- `user` alias → `"user"` (reserved word in PgSQL)
- Skip `READ UNCOMMITTED` dirty read test (PgSQL treats as READ
COMMITTED)

## Test plan
- [ ] Run `go test -v -run "Test_TX_" -count=1` in
`contrib/drivers/pgsql`
- [ ] Run `go test -v -run "Test_Model_Where" -count=1` in
`contrib/drivers/pgsql`
- [ ] Run `go test -v -run "Test_Model_Hook" -count=1` in
`contrib/drivers/pgsql`
- [ ] Run `go test -v -run "Test_Ctx" -count=1` in
`contrib/drivers/pgsql`
- [ ] Verify `go vet ./...` passes (only unreachable code warnings
matching MySQL driver pattern)

ref #4689

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-02-26 09:43:32 +08:00
841003eeb3 test(contrib/drivers/gaussdb): add transaction, where, hook, ctx test coverage (#4685)
## Summary
- Port 4 test files from PgSQL driver to GaussDB driver to align test
coverage
- Add `gaussdb_z_unit_transaction_test.go` (40 tests): nested
transactions, savepoints, rollback, panic recovery, context propagation
- Add `gaussdb_z_unit_model_where_test.go` (35 tests): comprehensive
Where clause combinations (map, slice, struct, pointer, operators, nil,
empty)
- Add `gaussdb_z_unit_feature_hook_test.go` (6 tests): model hook
callbacks (Select/Insert/Update/Delete)
- Add `gaussdb_z_unit_feature_ctx_test.go` (5 tests): context
propagation, timeout, logging with context
- Remove old `Test_Model_Where` (2 sub-tests) from
`gaussdb_z_unit_model_test.go`, replaced by comprehensive version in
dedicated where test file (35 tests)
- **86 new test functions**, ~3,224 net new lines

## Test plan
- [x] `go build ./...` passes
- [x] `gofmt` and `gci` applied
- [x] No remaining `pgsql` references in new files
- [ ] Run `go test -v -run "Test_TX_" -count=1` against GaussDB instance
- [ ] Run `go test -v -run "Test_Model_Where" -count=1` against GaussDB
instance
- [ ] Run `go test -v -run "Test_Model_Hook" -count=1` against GaussDB
instance
- [ ] Run `go test -v -run "Test_Ctx" -count=1` against GaussDB instance

ref #4689
2026-02-26 09:42:10 +08:00
1739d4dfb2 feat(i18n/gi18n): decoding and loading i18n files content by automatic file extension check (#4662)
The i18n file handling now checks file extensions instead of content. If
no extension info is found, it reverts to checking the file content.
2026-02-11 15:19:40 +08:00
46cc4cef9e test(contrib/drivers/pgsql): add Union, DO and Raw Where test coverage (#4679)
## Summary
- Add `pgsql_z_unit_feature_union_test.go`: 4 tests for Union/UnionAll
on both db and model level
- Add `pgsql_z_unit_feature_model_do_test.go`: 10 tests for DO (Data
Object) pattern - insert, batch insert, update, pointer fields, WHERE,
DAO pattern, and field prefix handling
- Enhance `pgsql_z_unit_raw_test.go`: add `Test_Raw_Where` for subquery
NOT EXISTS and field comparison using `gdb.Raw()`, adapted for PgSQL
double-quote quoting
- Add `testdata/table_with_prefix.sql` for PgSQL-compatible FieldPrefix
test

All tests adapted from MySQL driver test suite with PgSQL-specific
adjustments:
- Nullable table schema for DO partial inserts (PgSQL NOT NULL is
stricter than MySQL)
- Double-quote identifier quoting instead of backticks
- Unquoted table aliases in generated SQL

## Test plan
- [x] All 15 new tests pass locally
- [x] Full pgsql test suite (107 tests) passes with zero regressions

ref #4689

---------

Co-authored-by: John Guo <claymore1986@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-11 14:41:42 +08:00
90331d85bf test(contrib/drivers/gaussdb): add union, DO, raw where test coverage (#4687)
## Summary
- Port 2 test files, 1 testdata SQL, and append Test_Raw_Where from
PgSQL driver to GaussDB driver
- Add `gaussdb_z_unit_feature_union_test.go` (4 tests): Union/UnionAll
query operations
- Add `gaussdb_z_unit_feature_model_do_test.go` (10 tests): DO
struct-based CRUD operations
- Append `Test_Raw_Where` to `gaussdb_z_unit_raw_test.go` (1 test): raw
SQL in Where with subquery and column comparison
- Add `testdata/table_with_prefix.sql` for DO prefix tests
- **15 new test functions**, ~605 net new lines

## Test plan
- [x] `go build ./...` passes
- [x] `gofmt` and `gci` applied
- [x] No remaining `pgsql` references in new files
- [ ] Run full test suite against GaussDB instance

ref #4689

---------

Co-authored-by: John Guo <claymore1986@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-11 14:40:46 +08:00
98fd2a1973 chore: cleanup makefile, remove unnecessary scripts (#4684)
This pull request primarily removes submodule management targets from
the `Makefile` and makes minor updates to the project documentation in
both English and Chinese. The most important changes are grouped below.

Makefile cleanup:

* Removed the `subup` and `subsync` targets from the `Makefile`,
eliminating commands related to updating and committing submodules.

Documentation updates:

* Updated the logo alt text in both `README.MD` and `README.zh_CN.MD`
from "goframe gf logo" to "goframe logo" for clarity.
[[1]](diffhunk://#diff-01e6d9ffed056a02cae8d8a0ec5d476a64d017bf85c0d5a94bb23ca21f33f5aaL4-R4)
[[2]](diffhunk://#diff-c93759cb9a9500f20e551c741eb167fc72825fd638d36121357feb8253ce6ac1L4-R4)
* Revised a description in `README.zh_CN.MD` to clarify the framework's
purpose, changing “一个强大的框架” to “一款强大的框架”.
* Simplified the license description in `README.zh_CN.MD` to state
"100%开源和免费".
2026-02-11 14:37:49 +08:00
d5633ebad7 fix(contrib/registry): etcd doKeepAlive does not exit even when client context done (#4669)
Fixed #4668 

```
// client
package main

import (
	"github.com/gogf/gf/v2/frame/g"
	"github.com/gogf/gf/v2/net/gsvc"
	"github.com/gogf/gf/v2/os/gctx"

	"github.com/gogf/gf/contrib/registry/etcd/v2"
)

func main() {
	gsvc.SetRegistry(etcd.New(`etcd.etcd.orb.local:2379`))

	var (
		ctx    = gctx.New()
		client = g.Client()
	)
	client.SetDiscovery(gsvc.GetRegistry())
	res := client.GetContent(ctx, `http://hello.svc/`)
	g.Log().Info(ctx, res)
}

// server
package main

import (
	"github.com/gogf/gf/contrib/registry/etcd/v2"
	"github.com/gogf/gf/v2/frame/g"
	"github.com/gogf/gf/v2/net/ghttp"
	"github.com/gogf/gf/v2/net/gsvc"
)

func main() {
	gsvc.SetRegistry(etcd.New(`etcd.etcd.orb.local:2379`))

	s := g.Server(`hello.svc`)
	s.BindHandler("/", func(r *ghttp.Request) {
		g.Log().Info(r.Context(), `request received`)
		r.Response.Write(`Hello world`)
	})
	s.Run()
}

```

```
        /Users/shown/workspace/golang/open_source/gf/contrib/registry/etcd/etcd_registrar.go:105
2. context deadline exceeded
 
Stack:
1.  github.com/gogf/gf/contrib/registry/etcd/v2.(*Registry).doKeepAlive
    /Users/shown/workspace/golang/open_source/gf/contrib/registry/etcd/etcd_registrar.go:107

{"level":"warn","ts":"2026-01-30T22:30:33.863409+0800","logger":"etcd-client","caller":"v3@v3.5.17/retry_interceptor.go:63","msg":"retrying of unary invoker failed","target":"etcd-endpoints://0x1400023a780/etcd.etcd.orb.local:2379","attempt":0,"error":"rpc error: code = DeadlineExceeded desc = latest balancer error: last connection error: connection error: desc = \"transport: Error while dialing: dial tcp 192.168.138.6:2379: connect: operation timed out\""}
2026-01-30T22:30:33.863+08:00 [ERRO] keepalive retry register failed, will retry in 2s: etcd grant failed with keepalive ttl "10s": context deadline exceeded
1. etcd grant failed with keepalive ttl "10s"
   1).  github.com/gogf/gf/contrib/registry/etcd/v2.(*Registry).doRegisterLease
        /Users/shown/workspace/golang/open_source/gf/contrib/registry/etcd/etcd_registrar.go:38
   2).  github.com/gogf/gf/contrib/registry/etcd/v2.(*Registry).doKeepAlive
        /Users/shown/workspace/golang/open_source/gf/contrib/registry/etcd/etcd_registrar.go:105
2. context deadline exceeded
 
Stack:
1.  github.com/gogf/gf/contrib/registry/etcd/v2.(*Registry).doKeepAlive
    /Users/shown/workspace/golang/open_source/gf/contrib/registry/etcd/etcd_registrar.go:107

{"level":"warn","ts":"2026-01-30T22:30:40.865971+0800","logger":"etcd-client","caller":"v3@v3.5.17/retry_interceptor.go:63","msg":"retrying of unary invoker failed","target":"etcd-endpoints://0x1400023a780/etcd.etcd.orb.local:2379","attempt":0,"error":"rpc error: code = DeadlineExceeded desc = latest balancer error: last connection error: connection error: desc = \"transport: Error while dialing: dial tcp 192.168.138.6:2379: connect: operation timed out\""}
2026-01-30T22:30:40.866+08:00 [ERRO] keepalive retry register failed, will retry in 3s: etcd grant failed with keepalive ttl "10s": context deadline exceeded
1. etcd grant failed with keepalive ttl "10s"
   1).  github.com/gogf/gf/contrib/registry/etcd/v2.(*Registry).doRegisterLease
        /Users/shown/workspace/golang/open_source/gf/contrib/registry/etcd/etcd_registrar.go:38
   2).  github.com/gogf/gf/contrib/registry/etcd/v2.(*Registry).doKeepAlive
        /Users/shown/workspace/golang/open_source/gf/contrib/registry/etcd/etcd_registrar.go:105
2. context deadline exceeded
 
Stack:
1.  github.com/gogf/gf/contrib/registry/etcd/v2.(*Registry).doKeepAlive
    /Users/shown/workspace/golang/open_source/gf/contrib/registry/etcd/etcd_registrar.go:107

2026-01-30T22:30:43.903+08:00 [DEBU] etcd put success with key "/service/default/default/hello.svc/latest/192.168.27.229:60201,192.168.139.3:60201,192.168.163.0:60201", value "{"insecure":true,"protocol":"http"}", lease "7587892536770637317"
2026-01-30T22:30:43.904+08:00 [INFO] keepalive retry register success for service "/service/default/default/hello.svc/latest/192.168.27.229:60201,192.168.139.3:60201,192.168.163.0:60201"
2026-01-30T22:30:51.385+08:00 [INFO] {e0ffad1cac888f18eed5ef7a3ba3f6d0} request received
2026-01-30T22:30:52.121+08:00 [INFO] {78ca8848ac888f18573a386e0b596eaa} request received
```

---------

Signed-off-by: yuluo-yx <yuluo08290126@gmail.com>
2026-02-11 14:37:15 +08:00
58d6410291 fix(registry/etcd): etcd.NewWithClient() has no DialTimeout (#4670)
# Description

The `etcd.NewWithClient()` function internally does not set a
`DialTimeout` value, which causes it to default to 0. This leads to all
`context.WithTimeout(context.Background(), r.etcdConfig.DialTimeout)`
calls immediately timing out, as a timeout of 0 results in instant
expiration.

# Example

```go
package main

import (
	"context"
	"testing"
	"time"

	"github.com/gogf/gf/contrib/registry/etcd/v2"
	"github.com/gogf/gf/v2/errors/gerror"
	"github.com/gogf/gf/v2/net/gsvc"
	clientv3 "go.etcd.io/etcd/client/v3"
)

func TestEtcdWithClient(t *testing.T) {
	cli, _ := clientv3.New(clientv3.Config{
		Endpoints:   []string{"http://127.0.0.1:2379"},
		DialTimeout: 2 * time.Second,
	})
	defer cli.Close()

	registry := etcd.NewWithClient(cli)
	_, err := registry.Register(context.Background(), &gsvc.LocalService{
		Name:      "test",
		Endpoints: gsvc.NewEndpoints("127.0.0.1:8888"),
	})
	if err != nil {
		t.Error(gerror.Stack(err))
		return
	}
}
```

Running tool: /opt/homebrew/bin/go test -test.fullpath=true -timeout 30s
-run ^TestEtcdWithClient$ etop.roommanageserver

=== RUN   TestEtcdWithClient

{"level":"warn","ts":"2026-01-31T09:59:06.994867+0800","logger":"etcd-client","caller":"v3@v3.6.7/retry_interceptor.go:65","msg":"retrying
of unary invoker
failed","target":"etcd-endpoints://0x14000262f00/127.0.0.1:2379","method":"/etcdserverpb.Lease/LeaseGrant","attempt":0,"error":"rpc
error: code = DeadlineExceeded desc = context deadline exceeded"}
/Users/guolihui/projects/mpl-poker/room-manage-server/main_test.go:27:
1. etcd grant failed with keepalive ttl "10s"
1).
github.com/gogf/gf/contrib/registry/etcd/v2.(*Registry).doRegisterLease

/Users/guolihui/projects/mpl-poker/room-manage-server/gfv2/contrib/registry/etcd/etcd_registrar.go:38
2). github.com/gogf/gf/contrib/registry/etcd/v2.(*Registry).Register

/Users/guolihui/projects/mpl-poker/room-manage-server/gfv2/contrib/registry/etcd/etcd_registrar.go:24
           3).  etop%2eroommanageserver.TestEtcdWithClient
/Users/guolihui/projects/mpl-poker/room-manage-server/main_test.go:22
        2. context deadline exceeded

--- FAIL: TestEtcdWithClient (0.00s)
2026-02-11 14:25:19 +08:00
54087de518 test(contrib/drivers/pgsql): add Builder/Subquery/Join/Struct tests (#4680)
## Summary
- Port MySQL test coverage for Builder, Subquery, Join, and Struct
features to PgSQL driver
- Add 4 new test files with 23 test functions covering builder patterns,
subquery WHERE/HAVING/Model, all JOIN types, and struct scanning
- PgSQL dialect adaptations: double-quoted identifiers, GROUP BY with
HAVING, letter-prefixed table names, int64 id assertions, removed `Uid`
field

## Test plan
- [x] Builder tests pass: `go test -v -run
"Test_Model_Builder|Test_Safe_Builder" -count=1`
- [x] Subquery tests pass: `go test -v -run "Test_Model_SubQuery"
-count=1`
- [x] Join tests pass: `go test -v -run
"Test_Model_.*Join.*|Test_Model_FieldsPrefix" -count=1`
- [x] Struct tests pass: `go test -v -run
"Test_Model_Embedded|Test_Struct|Test_Structs|Test_Model_Scan|Test_Scan_Auto"
-count=1`
- [x] Full PgSQL test suite: 113/113 PASS

ref #4689
2026-02-11 13:51:47 +08:00
fc39fffe9c test(contrib/drivers/gaussdb): add builder, subquery, join, struct test coverage (#4688)
## Summary
- Port 4 test files from PgSQL driver to GaussDB driver
- Add `gaussdb_z_unit_feature_model_builder_test.go` (2 tests): SQL
builder with raw expressions and safe mode
- Add `gaussdb_z_unit_feature_model_subquery_test.go` (3 tests):
subquery in Select/Where/Having
- Add `gaussdb_z_unit_feature_model_join_test.go` (7 tests):
LeftJoin/RightJoin/InnerJoin with various conditions
- Add `gaussdb_z_unit_feature_model_struct_test.go` (11 tests):
struct-based insert/update/scan with tag mapping
- **23 new test functions**, ~861 net new lines

## Test plan
- [x] `go build ./...` passes
- [x] `gofmt` and `gci` applied
- [x] No remaining `pgsql` references in new files
- [ ] Run full test suite against GaussDB instance

ref #4689
2026-02-11 13:50:30 +08:00
6a3ea897a8 docs: Update README Add DeepWiki badges (#4661) 2026-01-28 15:42:11 +08:00
91f9864b25 fix: update gf cli to v2.10.0 (#4658)
Automated changes by
[create-pull-request](https://github.com/peter-evans/create-pull-request)
GitHub action

Co-authored-by: gqcn <gqcn@users.noreply.github.com>
2026-01-27 17:43:29 +08:00
8c8c7c8c71 feat: new version v2.10.0 (#4657)
This pull request upgrades the GoFrame framework and all related
dependencies from version `v2.9.8` (and similar) to `v2.10.0` across the
codebase. It also refactors the `.make_version.sh` script to improve
cross-platform compatibility when editing files, and ensures
documentation reflects the new version. These changes help keep the
project up-to-date and simplify version management.

**Dependency upgrades:**

* Updated all `go.mod` files in the main repo and contrib modules to
require `github.com/gogf/gf/v2 v2.10.0` (replacing `v2.9.8` and similar)
for consistency and latest features/bugfixes.
[[1]](diffhunk://#diff-ee0abb9c50b9f91f424349123e31b7b1ba1e1e4f7497250422696c5bda2e74ceL6-R12)
[[2]](diffhunk://#diff-cef597d401b6dad225f9e2e431bdde7e53cb60bdf287624cef38a6a7bb9ae7a3L7-R7)
[[3]](diffhunk://#diff-970f7eacff9cd97a0d8a00d59ea8041eedaa21c7544c6669aaa58ca692c6b274L6-R6)
[[4]](diffhunk://#diff-c23d0ca80cd6588b7df84de8ef84713f0ce0555ba05d2d9e7f5d1e0324b1ed3aL6-R6)
[[5]](diffhunk://#diff-aa230a2b1198e6ef8afeb7f48335eb2e2f51d87d918d63c4d891fea612d18ff0L6-R6)
[[6]](diffhunk://#diff-86c2390edbede20803cd862908fe95e7207f7dbabd5089ddd4838e1f26e7fecaL6-R6)
[[7]](diffhunk://#diff-5e1af33d38ced461fc0e13981d7051e125876d1692efc3aa9cb4b7faa4c18addL7-R7)
[[8]](diffhunk://#diff-8c6247829130f219981483ccf25af699a63de99afedeb0dd5c1b7bd8ff0919bdL9-R9)
[[9]](diffhunk://#diff-accbd2d37d45e51db3fcb0468043b1e1fd53eeac9e3d3558467ef24444188d2fL7-R7)
[[10]](diffhunk://#diff-15fac9b8e76d2782594c91da72f6a6f42fc18e359c3be35bf6564ac3ca09f700L6-R7)
[[11]](diffhunk://#diff-8e1a76afd564b6073aac7b02ca59f296ae45a24da3dc4d5c40f18169f48ceba1L6-R6)
[[12]](diffhunk://#diff-00a9db26966c21305c72e8f659628dffaff0d6e9dc98a751406d2141d51a5d90L7-R7)
[[13]](diffhunk://#diff-2cbf2f66d5cb77d9f4d00e4c0ce45055620fff50c941a588da31729f09a81f1bL6-R7)
[[14]](diffhunk://#diff-20a21d07addeea398c4adb76d077875894a73b4b5b181b9df1fafe497d3fc843L6-R6)
[[15]](diffhunk://#diff-909670f1c29b0bba24faf1420504b9eacdff124c4cbbec1ddec5de60653ad007L6-R6)
[[16]](diffhunk://#diff-8eef5f0c081743f8002e0faba686e838b323cb53b749706ea42e0440aaa793f1L7-R7)
[[17]](diffhunk://#diff-82345842a29e8eaffa4f51aab96fa2aa78597e6639fe4b0ece797bc60edacea8L6-R6)

**Script improvements:**

* Refactored `.make_version.sh` to use a new `sed_inplace` function for
in-place file editing, improving cross-platform support (Linux/macOS)
and removing reliance on a global variable for the sed command.
* Updated `.make_version.sh` to use `sed_inplace` consistently for
version replacement and dependency cleanup steps, ensuring robust file
modification regardless of OS.
[[1]](diffhunk://#diff-546db9206ba1b7973e6187a1025b3904a0b08681d40d0ee4767082040fd0f661L46-R47)
[[2]](diffhunk://#diff-546db9206ba1b7973e6187a1025b3904a0b08681d40d0ee4767082040fd0f661L84-R97)
* Added a step in `.make_version.sh` to insert local development replace
directives for Go modules, streamlining local testing and development.

**Documentation updates:**

* Updated contributor badge version in `README.MD` and `README.zh_CN.MD`
to reflect the new GoFrame version (`v2.10.0`).
[[1]](diffhunk://#diff-01e6d9ffed056a02cae8d8a0ec5d476a64d017bf85c0d5a94bb23ca21f33f5aaL48-R48)
[[2]](diffhunk://#diff-c93759cb9a9500f20e551c741eb167fc72825fd638d36121357feb8253ce6ac1L48-R48)
contrib/drivers/oceanbase/v2.10.0 contrib/drivers/clickhouse/v2.10.0 contrib/registry/file/v2.10.0 v2.10.0 contrib/drivers/sqlitecgo/v2.10.0 contrib/drivers/mysql/v2.10.0 contrib/drivers/sqlite/v2.10.0 contrib/drivers/mssql/v2.10.0 contrib/registry/consul/v2.10.0 contrib/drivers/mariadb/v2.10.0 contrib/drivers/gaussdb/v2.10.0 contrib/registry/nacos/v2.10.0 contrib/trace/otlphttp/v2.10.0 contrib/drivers/tidb/v2.10.0 contrib/config/kubecm/v2.10.0 contrib/config/nacos/v2.10.0 contrib/trace/otlpgrpc/v2.10.0 contrib/config/polaris/v2.10.0 contrib/sdk/httpclient/v2.10.0 contrib/drivers/pgsql/v2.10.0 contrib/registry/zookeeper/v2.10.0 contrib/rpc/grpcx/v2.10.0 contrib/metric/otelmetric/v2.10.0 contrib/registry/etcd/v2.10.0 contrib/config/consul/v2.10.0 contrib/config/apollo/v2.10.0 contrib/nosql/redis/v2.10.0 contrib/drivers/dm/v2.10.0 contrib/registry/polaris/v2.10.0 contrib/drivers/oracle/v2.10.0
2026-01-26 20:37:48 +08:00
73211707fb refactor(container): add default nil checker, rename RegisterNilChecker to SetNilChecker, migrate instance containers to type-safe generics (#4630)
## 变更说明

本 PR 主要对代码库进行了重构,以提升类型安全性和优化连接管理实现。

### 详细变更

#### 1. 数据库连接管理优化
- 修改 `RegisterNilChecker`方法返回实例以支持链式调用,涉及
`KVMap`、`ListKVMap`、`TSet`、`AVLKVTree`、`BKVTree`、`RedBlackKVTree`
等多个容器类型
- 更新 `Core`结构体中 `links`字段类型为类型安全的 `KVMap[ConfigNode, *sql.DB]`
- 添加专门的链接检查器函数用于连接池管理
- 使用泛型 `KVMap`替代原始 map 类型提升类型安全性
- 简化连接关闭逻辑并移除不必要的类型断言
- 优化统计功能中的迭代器实现提高性能

#### 2. 数据库驱动类型安全增强
- 将 dm、gaussdb、mssql、oracle 驱动中的 `conflictKeySet` 从 `gset.New`修改为
`gset.NewStrSet`
- 统一使用字符串集合类型以提高类型安全性

#### 3. 配置文件适配器类型安全改进
- 将 `jsonMap`从 `StrAnyMap` 类型更改为泛型 `KVMap[string, *gjson.Json]` 类型
- 添加 `jsonMapChecker` 函数用于 JSON 对象验证
- 使用 `NewKVMapWithChecker` 替代 `NewStrAnyMap` 提高类型安全性
- 简化数据库链接关闭日志中的键值转换逻辑

## 影响范围

- 数据库连接管理模块
- 多个数据库驱动实现
- 配置文件管理系统

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: John Guo <john@johng.cn>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-01-23 16:37:38 +08:00
609f44c5fe fix(cmd/gf): fix genservice losing versioned import paths (#4242) (#4638)
## Summary
- Fix `gf gen service` incorrectly handling versioned imports (e.g.,
`github.com/minio/minio-go/v7` → `github.com/minio/minio-go`)
- The root cause was faulty package name inference from import paths -
Go allows package names to differ from directory names
- Solution: Keep all non-anonymous imports and let gofmt clean up unused
ones

## Changes
- Simplified `calculateImportedItems` function in
`genservice_calculate.go`
- Added test case for versioned imports and aliased imports

## Test plan
- [x] All existing genservice tests pass (`Test_Gen_Service_Default`,
`Test_Issue3328`, `Test_Issue3835`)
- [x] New test `Test_Issue4242` verifies both versioned imports and
aliased imports are preserved
- [x] Verified generated files match expected output exactly

Closes #4242

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-01-22 20:45:19 +08:00
0a82036da5 feat(contrib/registry): update nacos sdk to 2.3.5 (#4628)
- Update nacos go sdk to 2.3.5;
- ctx params not use, skip it;
- adjust docs style

---------

Signed-off-by: yuluo-yx <yuluo08290126@gmail.com>
Co-authored-by: hailaz <739476267@qq.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-22 19:09:06 +08:00
b4053ed32e feat(os/gcfg): add Loader with automatic struct binding and config watching (like Spring Boot @ConfigurationProperties) (#4575)
# Loader 配置加载器

Loader 是一个通用的配置管理器,提供了类似于 Spring Boot
的`@ConfigurationProperties`的配置加载、监控、更新和管理功能。

## 功能特性

- **泛型支持**:使用 Go 泛型,类型安全的配置绑定
- **配置加载**:从配置源加载数据并绑定到结构体
- **配置监控**:自动监控配置变化并更新
- **自定义转换器**:支持自定义数据转换函数
- **回调处理**:配置变更时的回调函数
- **错误处理**:灵活的错误处理机制

## 安装

```bash
go get github.com/gogf/gf/v2
```

## 使用示例

### 1. 基本用法

#### 用法一

```go
package main

import (
	"github.com/gogf/gf/v2/frame/g"
	"github.com/gogf/gf/v2/os/gcfg"
	"github.com/gogf/gf/v2/os/gctx"
)

type AppConfig struct {
	Name     string       `json:"name"`
	Age      int          `json:"age"`
	Enabled  bool         `json:"enabled"`
	Features []string     `json:"features"`
	Server   ServerConfig `json:"server"`
}

type ServerConfig struct {
	Host string `json:"host"`
	Port int    `json:"port"`
}

func main() {
	ctx := gctx.New()
	// 创建配置器实例
	loader := gcfg.NewLoader[AppConfig](g.Cfg("test"), "")

	// 加载和监听配置
	loader.MustLoadAndWatch(ctx, "test-watcher")

	// 获取配置
	config := loader.Get()
	fmt.Println(config.Name)
}
```

#### 用法二

```go
package main

import (
	"fmt"
	"github.com/gogf/gf/v2/os/gcfg"
	"github.com/gogf/gf/v2/os/gctx"
)

type AppConfig struct {
	Name     string       `json:"name"`
	Age      int          `json:"age"`
	Enabled  bool         `json:"enabled"`
	Features []string     `json:"features"`
	Server   ServerConfig `json:"server"`
}

type ServerConfig struct {
	Host string `json:"host"`
	Port int    `json:"port"`
}

func main() {
	ctx := gctx.New()

	// 使用单独的适配器创建
	// 创建配置管理器
	cfg, _ := gcfg.NewAdapterFile("test.yaml")
	// 创建配置器实例
	loader := gcfg.NewLoaderWithAdapter[AppConfig](cfg, "")

	// 加载和监听配置
	loader.MustLoadAndWatch(ctx, "test-watcher")

	// 获取配置
	config := loader.Get()
	fmt.Println(config.Name)
}
```

### 2. 配置监控

```go


// 仅加载App配置
loader := gcfg.NewLoaderWithAdapter[AppConfig](cfg, "app")

// 设置配置变更回调
loader.OnChange(func (updated AppConfig) error {
// 配置变更时的处理逻辑
println("配置已更新:", updated.Name)
return nil
})

// 加载数据
err := loader.Load(ctx)
if err != nil {
panic(err)
}

// 开始监控配置变化
err := loader.Watch(context.Background(), "my-watcher")
if err != nil {
panic(err)
}

```

### 3. 自定义转换器

```go
// 设置自定义转换器
loader.SetConverter(func (data any, target *AppConfig) error {
// 自定义数据转换逻辑
return nil
})
```

### 4. 便捷方法

```go
// 一步完成加载和监控
loader.MustLoadAndWatch(context.Background(), "my-app")
```

## API 参考

### `NewLoader`

创建一个新的 Loader 实例。

```go
func NewLoader[T any](config *Config, propertyKey string, targetStruct ...*T) *Loader[T]
```

参数:

- `config`: 配置实例,用于监控变化
- `propertyKey`: 监控的属性键模式(使用 "" 或 "." 监控所有配置)
- `targetStruct`: 接收配置值的结构体指针(可选)

### `NewLoaderWithAdapter`

使用适配器创建一个新的 Loader 实例。

```go
func NewLoaderWithAdapter[T any](adapter Adapter, propertyKey string, targetStruct ...*T) *Loader[T]
```

### `Load`

从配置实例加载数据并绑定到目标结构体。

```go
func (l *Loader[T]) Load(ctx context.Context) error
```

### `MustLoad`

与 Load 类似,但出错时会 panic。

```go
func (l *Loader[T]) MustLoad(ctx context.Context)
```

### `Watch`

开始监控配置变化并自动更新目标结构体。

```go
func (l *Loader[T]) Watch(ctx context.Context, name string) error
```

### `MustWatch`

与 Watch 类似,但出错时会 panic。

```go
func (l *Loader[T]) MustWatch(ctx context.Context, name string)
```

### `MustLoadAndWatch`

便捷方法,调用 MustLoad 和 MustWatch。

```go
func (l *Loader[T]) MustLoadAndWatch(ctx context.Context, name string)
```

### `Get`

返回当前配置结构体。

```go
func (l *Loader[T]) Get() T
```

### `GetPointer() *T`

返回指向当前配置结构体的指针。

```go
func (l *Loader[T]) GetPointer() *T
```

### `OnChange`

设置配置变化时调用的回调函数。

```go
func (l *Loader[T]) OnChange(fn func (updated T) error)
```

### `SetConverter`

设置在 Load 操作期间使用的自定义转换函数。

```go
func (l *Loader[T]) SetConverter(converter func (data any, target *T) error)
```

### `SetWatchErrorHandler`

设置在 Watch 过程中 Load 操作失败时调用的错误处理函数。

```go
func (l *Loader[T]) SetWatchErrorHandler(errorFunc func(ctx context.Context, err error))
```

### `SetReuseTargetStruct`

设置是否在更新时重用相同的目标结构体或创建新结构体。

```go
func (l *Loader[T]) SetReuseTargetStruct(reuse bool)
```

### `StopWatch`

停止监控配置变化并移除关联的监控器。

```go
func (l *Loader[T]) StopWatch(ctx context.Context) (bool, error)
```

### `IsWatching`

返回 Loader 是否正在监控配置变化。

```go
func (l *Loader[T]) IsWatching() bool
```

## 高级用法

### 监控特定配置键

```go
// 只监控特定配置键
loader := gcfg.NewLoaderWithAdapter[ServerConfig](cfg, "server")
```

### 使用默认值

```go
// 创建带默认值的目标结构体
var targetConfig AppConfig
targetConfig.Name = "default-app" // 设置默认值

loader := gcfg.NewLoaderWithAdapter(cfg, "", &targetConfig)
```

## 错误处理

Loader 提供了灵活的错误处理机制:

```go
loader.SetWatchErrorHandler(func(ctx context.Context, err error) {
    // 处理加载错误
    log.Printf("配置加载失败: %v", err)
})
```

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: houseme <housemecn@gmail.com>
2026-01-22 19:04:52 +08:00
110e3fbf16 feat(cmd/gendao): add wildcard pattern support for tables configuration (#4632)
## Summary
- Add wildcard pattern support (`*` and `?`) for `tables` configuration
- Fix `tablesEx` wildcard to use exact match (`^$`) for consistency
- Add warning when exact table name does not exist
- Add unit tests and integration tests for MySQL and PostgreSQL

## Changes
| Configuration | Before | After |
|---------------|--------|-------|
| `tables: "user_*"` | Not supported | Matches tables starting with
"user_" |
| `tables: "*"` | Not supported | Matches all tables |
| `tablesEx: "user_*"` | Partial match | Exact match (consistent with
tables) |

## Features
- `*` matches any characters (e.g., `user_*` matches `user_info`,
`user_log`)
- `?` matches single character (e.g., `user_???` matches `user_log` but
not `user_info`)
- Mixed patterns and exact names supported (e.g., `tables:
"user_*,config"`)
- Non-existent exact table names are skipped with warning message

## Test plan
- [x] Unit tests for `containsWildcard`, `patternToRegex`,
`filterTablesByPatterns` (11 cases)
- [x] Integration tests for MySQL (5 cases)
- [x] Integration tests for PostgreSQL (1 case with tables + tablesEx)
- [x] Standard SQL syntax for cross-database compatibility

Closes #4629

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-01-21 19:16:12 +08:00