Commit Graph

6315 Commits

Author SHA1 Message Date
8723999afc up 2025-12-04 20:33:08 +08:00
0d122d6fee up 2025-12-04 17:33:57 +08:00
63c2bb7c86 feat(contrib/drivers/dm): add Replace/InsertIgnore support for dm 2025-12-04 17:29:39 +08:00
48845c3473 fix(contrib/drivers/mssql): update tables SQL query for better compatibility (#4170)
修复gf gen在sqlserver上的异常问题:

1. https://github.com/gogf/gf/issues/1722
2. https://github.com/gogf/gf/issues/1761

```powershell
> gf gen dao
fetching tables failed: SELECT NAME FROM SYSOBJECTS WHERE XTYPE='U' AND STATUS >= 0 ORDER BY NAME: mssql: 对象名 
'SYSOBJECTS' 无效。
1. SELECT NAME FROM SYSOBJECTS WHERE XTYPE='U' AND STATUS >= 0 ORDER BY NAME
2. mssql: 对象名 'SYSOBJECTS' 无效。
```

在SqlServer 2022已测试通过:


![image](https://github.com/user-attachments/assets/9f6b7326-c790-4458-93dd-04782b617692)

---------

Co-authored-by: hailaz <739476267@qq.com>
2025-12-03 23:42:16 +08:00
ea956189bf feat(contrib/drivers/dm): add WherePri support (#4157)
The Dameng database supports the wherepri method.
eg: `dao.User.Ctx(ctx).WherePri(id)`

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: John Guo <claymore1986@gmail.com>
Co-authored-by: hailaz <739476267@qq.com>
2025-12-03 17:52:05 +08:00
3912d97811 fix(contrib/drivers/dm): support muti-line sql statement (#4163) (#4164)
Co-authored-by: hailaz <739476267@qq.com>
2025-12-03 16:18:47 +08:00
50fb349bc9 docs: update Chinese documentation and add README.zh_CN.MD (#4534)
Enhance the Chinese documentation by adding a new README file and
updating existing database driver instructions with the latest `go get`
commands. Additionally, provide Chinese explanations for the `gf`
command documentation.

fix https://github.com/gogf/gf/issues/4533
2025-12-01 09:35:06 +08:00
777d7aabb5 feat(container/gtree): add generic tree feature (#4522)
add generic tree feature
improve gmap.TreeMap

---------

Co-authored-by: hailaz <739476267@qq.com>
2025-11-29 21:09:43 +08:00
5a67aac85d feat(container/gmap): add generic list map feature (#4520)
add the generic list map: ListKVMap[K,V] and let ListMap base on it.

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: hailaz <739476267@qq.com>
2025-11-29 20:57:41 +08:00
132a5ab9a3 feat(container/gmap): add generic map feature (#4484)
add hash kvmap and let other hash map base on it.

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: hailaz <739476267@qq.com>
2025-11-28 21:41:30 +08:00
8575f01273 feat(container/gqueue): add generic queuefeature (#4497)
add TQueue

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: hailaz <739476267@qq.com>
2025-11-28 12:42:12 +08:00
ac75026716 feat(container/gring): add generic ring feature (#4496)
add TRing

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: hailaz <739476267@qq.com>
2025-11-28 11:50:09 +08:00
485a9637cc feat(container/gpool): add generic pool feature (#4493)
add TPool[T] and let Pool base on it.

---------

Co-authored-by: hailaz <739476267@qq.com>
2025-11-27 18:18:37 +08:00
b57b49ecca fix(ci): Free Disk Space (#4529)
改用新的方法,清理其他不必要的目录以获取更多可用空间
2025-11-27 16:47:10 +08:00
cdead46c79 fix(ci): update script permissions and add docker cleanup functionality (#4523) 2025-11-25 14:55:56 +08:00
a4883e6e3d feat(container/gset): add generic set feature (#4492)
Add generic set featrue: TSet[T]

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: hailaz <739476267@qq.com>
2025-11-24 17:47:36 +08:00
fe8ba5e35f fix(database/gdb): Resolve column ambiguity in GROUP BY/ORDER BY with MySQL JOIN (#4521)
When using JOIN queries in MySQL with the `Group()` method, column names
in GROUP BY clauses become ambiguous if multiple tables contain columns
with the same name (commonly `id`). This results in MySQL errors like
"Column 'id' in group statement is ambiguous".

**Example Issue:**
```go
model := t.Ctx(ctx).Fields("t_inf_job.*, t_inf_job_attr.*").
    LeftJoin("t_inf_job_attr", "t_inf_job.id = t_inf_job_attr.job_id").
    Where(t.Columns().Deleted, 0)

// This would fail with "Column 'id' in group statement is ambiguous"
err = model.Group(t.Columns().Id).Scan(&jobs)
```


### **Key Changes**

1. **Modified function signature**: `Group(groupBy ...string)` →
`Group(groupBy ...any)` to support Raw SQL expressions
2. **Auto-prefixing logic**: When JOINs are detected (by checking for "
JOIN " in the tables string), unqualified column names are automatically
prefixed with the primary table name
3. **Preserved existing behavior**: Already qualified columns
(containing ".") and Raw expressions are handled as before
4. **Added comprehensive test**: `Test_Model_Group_WithJoin` verifies
the fix works correctly with JOIN queries

---------

Co-authored-by: hailaz <739476267@qq.com>
2025-11-24 15:57:20 +08:00
54b7c249fd fix(os/gcfg): ignore fsnotify event error to avoid package gcfg totally failing (#4400)
问题描述: Windows 11
文件夹映射的网络驱动器里面的go项目在启动的时候会因为系统没有映射磁盘的文件事件监听而报错,从而导致整个项目启动失败,目前我临时的修复是将该错误改为警告进行打印

---------

Co-authored-by: anno <anno@anno.com>
Co-authored-by: houseme <housemecn@gmail.com>
Co-authored-by: hailaz <739476267@qq.com>
2025-11-21 22:51:42 +08:00
99d69857fa refactor(database/gdb): add quote for FieldsPrefix (#4485)
Code example:
``` go
	var res *BasicInfo
	err := g.DB().Model("basic_info").
		FieldsPrefix("basic_info", basicInfoColumns).
		Where("id", 35813305356386305).Scan(&res)
	if err != nil {
		panic(err)
	}
	g.Dump(res)
```

SQL generated before modification :
``` sql
SELECT basic_info.id,basic_info.full_name,basic_info.contact FROM `basic_info` WHERE (`id`=35813305356386305) AND `delete_time` IS NULL LIMIT 1
```

SQL generated after modification:
``` sql
SELECT `basic_info`.`id`,`basic_info`.`full_name`,`basic_info`.`contact` FROM `basic_info` WHERE (`id`=35813305356386305) AND `delete_time` IS NULL LIMIT 1
```

---------

Co-authored-by: hailaz <739476267@qq.com>
2025-11-21 17:27:09 +08:00
1b26013a66 fix: update copyright notice in multiple files to specify correct file reference (#4518)
修复注释
2025-11-21 14:12:56 +08:00
6c2155bd26 feat(container/glist): add generic list feature (#4483)
It is wrote with glist.List's and list.List's source codes and improve
to support T type.

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: hailaz <739476267@qq.com>
2025-11-20 18:20:19 +08:00
9018a3d4ac feat(container/garray): enhance generic array implements (#4482)
Remove the t array of wrapper array. Now it's a real one. Other normal
array will base on it.

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-11-19 18:11:04 +08:00
362d4202c4 fix(contrib/drivers/pgsql): Fixed the problem of overlapping fields in the same table name in pgsql multiple schema mode (#4375)
Co-authored-by: hailaz <739476267@qq.com>
2025-11-19 18:03:52 +08:00
a85b221d32 fix(contrib/config/apollo):where gcfg config apollo failed to retrieve configurations for multiple namespaces, where watch apollo change resulted in missing configurations. (#4509)
Fixed an issue where `gcfg config apollo` failed to retrieve
configurations for multiple namespaces; fixed an issue where `watch
apollo change` resulted in missing configurations.

---------

Co-authored-by: DAWN <xiongchao@cdfsunrise.com>
Co-authored-by: hailaz <739476267@qq.com>
2025-11-19 16:18:55 +08:00
cb8594eb80 refactor(contrib/clickhouse): optimization clickhouse (#4499)
1. close stmt
2.  fix assert  *gtime.Time
2025-11-19 16:03:07 +08:00
ac88e640d1 fix(net/goai): swagger $ref replace (#4512)
修复swagger泛型导致的 []/三个特殊字符不支持

---------

Co-authored-by: hailaz <739476267@qq.com>
2025-11-19 16:00:39 +08:00
2d307c5dd1 feat(contrib/drivers/pgsql): add array type numeric[] and decimal[] converting to Go []float64 support #4457 (#4511)
Co-authored-by: hailaz <739476267@qq.com>
2025-11-19 14:35:30 +08:00
54453c8e8f fix(ci): add cache cleaning step to prevent 'no space left on device' errors (#4513)
修复ci runner免费的磁盘空间不足导致无法完成单元测试的问题
1. 移动example单测到ci sub中
2. 使用go clean -cache清理避免短期内再次出现空间不足的问题
2025-11-19 12:54:51 +08:00
Ray
072b962b81 fix(‎encoding/gjson): fix gjson data race (#4510) 2025-11-17 15:21:38 +08:00
a80f58b7f6 fix: update gf cli to v2.9.5 (#4507)
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>
2025-11-10 21:45:57 +08:00
1e3aa5f080 fix: v2.9.5 (#4503) v2.9.5 contrib/sdk/httpclient/v2.9.5 contrib/config/kubecm/v2.9.5 contrib/drivers/pgsql/v2.9.5 contrib/config/apollo/v2.9.5 contrib/config/consul/v2.9.5 contrib/registry/zookeeper/v2.9.5 contrib/trace/otlpgrpc/v2.9.5 contrib/drivers/dm/v2.9.5 contrib/rpc/grpcx/v2.9.5 contrib/registry/file/v2.9.5 contrib/config/polaris/v2.9.5 contrib/registry/consul/v2.9.5 contrib/nosql/redis/v2.9.5 contrib/trace/otlphttp/v2.9.5 contrib/drivers/oracle/v2.9.5 contrib/drivers/sqlitecgo/v2.9.5 contrib/drivers/mssql/v2.9.5 contrib/registry/nacos/v2.9.5 contrib/drivers/mysql/v2.9.5 contrib/config/nacos/v2.9.5 contrib/registry/polaris/v2.9.5 contrib/metric/otelmetric/v2.9.5 contrib/registry/etcd/v2.9.5 contrib/drivers/clickhouse/v2.9.5 contrib/drivers/sqlite/v2.9.5 2025-11-10 21:40:35 +08:00
fde47e8981 fix(cmd/gf): The problem of the command 'gen dao' becoming very slow (#4498)
fixed #4479

修复gf gen dao执行严重变慢的问题

主要调整,降级两个依赖库
`go get golang.org/x/tools@v0.26.0` // 直接依赖
`go get golang.org/x/text@v0.25.0` // 间接依赖

至于为什么这两个库会导致慢,还需要深入排查
2025-11-10 17:38:50 +08:00
c02148cd6b feat(‎container/garray): Sorted T Array (#4470)
Add the sorted T array

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: hailaz <739476267@qq.com>
2025-10-17 18:10:31 +08:00
XG
1d4e684949 refactor(cmd/gf): Optimize run command to reload only on file write events (#4476)
优化run命令使得只在文件有写入事件时才触发reload:
gf run 的文件监控逻辑之前会对所有文件系统事件做出响应,包括非内容修改的事件(如文件access
time变化),这会导致开发过程中不必要的频繁重载。本次修改在文件监控回调中增加了event.IsWrite()的判断,确保只有在文件内容被实际写入时才触发重载逻辑,优化了开发体验。
2025-10-16 16:20:24 +08:00
8ff0de88b8 build(contrib): upgrade nacos registry&config (#4473)
RT
2025-10-16 11:29:44 +08:00
ac3efe5a00 feat(os/gcfg): Add file watcher with custom callback support (#4446)
为`gcfg`添加配置文件变更自定义回调,实现了`WatcherAdapter`接口,以下是`AdapterFile`的用法
test.yaml
```
b: "b"

```
```
package main

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

func main() {
	ctx := gctx.New()
	file, _ := gcfg.NewAdapterFile("test.yaml")
	file.Data(ctx)
	file.AddWatcher("test", func() {
		value := file.MustGet(ctx, "b")
		fmt.Println(value.String())
	})
	server := g.Server()
	server.Run()
}
```
使用`g`和默认配置文件
```
	file := g.Cfg().GetAdapter().(*gcfg.AdapterFile)
	file.AddWatcher("test", func() {

	})
	file := g.Cfg().GetAdapter().(*gcfg.AdapterFile)
	file.RemoveWatcher("test")
```

注意:由于`gf`的`AdapterFile`使用的监听到文件变化删除缓存下一次重新初始化的懒加载方案,所有除了默认加载的`config.xxx`文件外,自定义的配置文件像`test.yaml`之类的都需要在`AddWatcher`前主动读取一次数据进行初始化监听(
`g.Cfg("test").Data(ctx)`)

---------

Co-authored-by: hailaz <739476267@qq.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Hunk Zhu <hunk@joy999.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-15 16:59:52 +08:00
613
2744fe2212 fix(net/gclient): fix content-type 'application/json;charset=utf-8' … (#4369)
fix(net/gclient): fix content-type 'application/json;charset=utf-8' can
not match `application/json`

---------

Co-authored-by: houseme <housemecn@gmail.com>
2025-10-15 16:14:33 +08:00
1682cc98bb feat(gdb): Allow to set table field metadata and allow to generate table fields registration code when generating dao (#4460)
`gdb`在第一次查询时会拉取一次`table`的`fields meta`信息,为后续orm的字段过滤和时间特性服务,`gen
dao`时已经获得了`table`的所有`fields
meta`,提供一个生成`table`的功能,允许客户自行决定是否生成,是否注入已知表结构缓存到指定`db`实例。
1. 能解决部分兼容`mysql`的二开数据库在获取`fields meta`时无法和`mysql`保持一致的问题。
2.
可以模拟表字段信息而不需要真实的数据库连接,对于已知的表结构,可以直接设置缓存,在无法连接数据库的情况下,仍然可以使用表字段信息,使用gdb构建sql时不需要受限于实际数据库即可使用`gdb.ToSQL()`方法。
4. 提升访问速度

生成的示例目录
<img width="389" height="670" alt="SCR-20251010-ntne"
src="https://github.com/user-attachments/assets/ebb08e70-cce1-4b73-9128-6ff784e4df3b"
/>

生成的示例代码
```golang
// =================================================================================
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
// =================================================================================

package table

import (
	"context"

	"github.com/gogf/gf/v2/database/gdb"
)

// RolePermissions defines the fields of table "role_permissions" with their properties.
// This map is used internally by GoFrame ORM to understand table structure.
var RolePermissions = map[string]*gdb.TableField{
	"role_id": {
		Index:   0,
		Name:    "role_id",
		Type:    "bigint unsigned",
		Null:    false,
		Key:     "PRI",
		Default: nil,
		Extra:   "",
		Comment: "",
	},
	"permission_id": {
		Index:   1,
		Name:    "permission_id",
		Type:    "bigint unsigned",
		Null:    false,
		Key:     "PRI",
		Default: nil,
		Extra:   "",
		Comment: "",
	},
	"created_at": {
		Index:   2,
		Name:    "created_at",
		Type:    "timestamp",
		Null:    false,
		Key:     "",
		Default: "CURRENT_TIMESTAMP",
		Extra:   "DEFAULT_GENERATED",
		Comment: "",
	},
	"updated_at": {
		Index:   3,
		Name:    "updated_at",
		Type:    "timestamp",
		Null:    false,
		Key:     "",
		Default: "CURRENT_TIMESTAMP",
		Extra:   "DEFAULT_GENERATED on update CURRENT_TIMESTAMP",
		Comment: "",
	},
	"deleted_at": {
		Index:   4,
		Name:    "deleted_at",
		Type:    "timestamp",
		Null:    true,
		Key:     "",
		Default: nil,
		Extra:   "",
		Comment: "",
	},
}

// SetRolePermissionsTableFields registers the table fields definition to the database instance.
// db: database instance that implements gdb.DB interface.
// schema: optional schema/namespace name, especially for databases that support schemas.
func SetRolePermissionsTableFields(ctx context.Context, db gdb.DB, schema ...string) error {
	return db.GetCore().SetTableFields(ctx, "role_permissions", RolePermissions, schema...)
}

```
2025-10-15 15:50:16 +08:00
613
2742c98c06 fix(os/gcron): unit testing case of package gcron occasionally failed (#4419)
fix https://github.com/gogf/gf/issues/3999

1. fix  jobWaiter   sync.WaitGroup  data race
2. fix logger      glog.ILogger data race

---------

Co-authored-by: hailaz <739476267@qq.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-15 15:17:05 +08:00
4226a23a39 feat(container/garray): add TArray (#4466)
Add TArray[T] for wrapping Array

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-15 15:08:26 +08:00
613
b8e414e125 fix(os/gcache): defaultcache lazy init (#4468)
defaultcache更改为懒加载,在用户使用redis缓存时,避免了程序启动时不必要的初始化开销。


<img width="2638" height="806" alt="image"
src="https://github.com/user-attachments/assets/96bb0097-8463-4303-971c-ee1a9ef671a6"
/>

---------

Co-authored-by: hailaz <739476267@qq.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-15 15:01:47 +08:00
08c34b5ed7 feat(gf/build): Add support for the Loongson architecture (loong64) (#4467)
添加对龙芯架构(loong64)的支持

---------

Co-authored-by: hailaz <739476267@qq.com>
2025-10-15 14:38:42 +08:00
416f314390 fix(contrib/drivers/pgsql): Merge duplicated fields, especially for key constraints. (#4465)
pgsql 执行TableFields 或者字段信息时需要合并key信息
2025-10-13 18:16:09 +08:00
98f0c36a1d fix: update gf cli to v2.9.4 (#4463)
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>
2025-10-11 15:10:30 +08:00
2b7b4c8581 fix: v2.9.4 (#4461)
Co-authored-by: houseme <housemecn@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
v2.9.4 contrib/config/nacos/v2.9.4 contrib/sdk/httpclient/v2.9.4 contrib/trace/otlpgrpc/v2.9.4 contrib/drivers/sqlitecgo/v2.9.4 contrib/registry/consul/v2.9.4 contrib/registry/polaris/v2.9.4 contrib/trace/otlphttp/v2.9.4 contrib/drivers/pgsql/v2.9.4 contrib/drivers/mssql/v2.9.4 contrib/rpc/grpcx/v2.9.4 contrib/config/consul/v2.9.4 contrib/config/apollo/v2.9.4 contrib/registry/zookeeper/v2.9.4 contrib/registry/file/v2.9.4 contrib/nosql/redis/v2.9.4 contrib/drivers/mysql/v2.9.4 contrib/config/polaris/v2.9.4 contrib/registry/etcd/v2.9.4 contrib/metric/otelmetric/v2.9.4 contrib/drivers/dm/v2.9.4 contrib/drivers/oracle/v2.9.4 contrib/registry/nacos/v2.9.4 contrib/drivers/clickhouse/v2.9.4 contrib/config/kubecm/v2.9.4 contrib/drivers/sqlite/v2.9.4
2025-10-11 14:58:01 +08:00
613
b8844f3d40 fix(net/ghttp): attachment filename support utf8 (#4459) 2025-10-10 10:32:02 +08:00
3e2176d799 fix:(cmd/gf): matching for table ex fix bug (#4458)
fix the bug: sometimes it won't remove all broad matching talbenames.

---------

Co-authored-by: hailaz <739476267@qq.com>
2025-10-09 12:08:28 +08:00
2f9225057f fix(contrib/drivers/mysql): Fix unit test issue for batch insert in MySQL driver (#4456)
Resolve a temporary issue in the unit tests for batch insertion by
adjusting user IDs.

因为底层的插入随机性,会导致单元测试偶发失败。
2025-09-30 14:33:46 +08:00
7b373446dc feat(cmd/gf): add broad matching to gf gen dao's tableEx attribute. (#4453)
Add "*" and "?" to tableEx for "gf gen dao".

The "*" will match none or some char. And the "?" only match one char.

Co-authored-by: hailaz <739476267@qq.com>
2025-09-30 11:27:03 +08:00
0f6d47c7a8 fix(container/gqueue): Optimize queue length calculation and loop structure in test cases (#4455)
fixed #4376
2025-09-29 17:26:39 +08:00