hinego

Results 10 issues of hinego

以pgsql的decimal类型举例 被映射到了golang float64 但是golang 的float64是用8个字节来储存的(至多能精确表达 2 ** 64个数字) 而pgsql的decimal 是可变长的(可以表达的数字几乎不限量【小数点前 131072 位;小数点后 16383 位】) float64至多能精确表达:18446744073709552000个数字 但是很明显decimal能表达的数字不止这么点。。。。 这明显不是计算时才有问题了 例如:数据库里面有一个大数:88888888888888888888888888888 但是用gf orm去取出来就变成了88888888888888900000000000000 再例如 api提交了一个大数:88888888888888888888888888888 但是保存到数据库里的就是88888888888888900000000000000了 详见:[https://www.runoob.com/postgresql/postgresql-data-type.html ](https://www.runoob.com/postgresql/postgresql-data-type.html) 解决方案: 1. 将decimal类型用golang的string类型承载(这是最轻松的方案) 2. 将decimal类型用...

IP netip.Addr `json:"ip" gorm:"serializer:auto;comment:auto|netip.Addr|注册IP"` 抛砖引玉 先手动写struct 用comment来配置当前的类型与serializer 名称(对于自定义类型在自定义serializer里面实现就好了) ``` if strings.Contains(comment, "|") { arr := strings.Split(comment, "|") comment = arr[1] if len(arr) == 3 { fieldType = arr[1] } }...

挺久之前(可能是v4刚出来)准备把ant design pro换到v4 但是按umi max 配置始终搞不定 主要是配置时 类型定义是: layout?: ({ } | boolean) 。。。。。。。。能不能像之前那样把类型写死 而不是这样的any................................ 且文档也写得不够完善 暂时放弃v4了

某些表里的数据在程序中会被频率读取使用,且更新/删除 都不会太多 这种情况,我认为可以提供一个缓存功能(之前我是手动在应用中进行缓存,但是这样太麻烦了一直写重复的东西,copy paste 也麻烦) ``` //通过那些字段进行缓存吗,需要这些字段是唯一的 func (r *Address) CacheKey() []any { return []any{r.ID, r.Address} } //如果缓存未命中通过那些字段进行查询 func (r *Address) CacheColumn() map[string]string { return map[string]string{ "id": "int64", "address": "string",...

``` err = dao.User.Transaction(ctx, func(ctx context.Context, tx *gdb.TX) error { name := "testinsert1" var user = new(entity.User) user.Passport = name user.Password = name user.Nickname = name user.Gender = 0 user.Avatar...

``` return cache.NewGorm2Cache(&config.CacheConfig{ CacheLevel: config.CacheLevelOnlyPrimary, CacheStorage: storage.NewGcache(gcache.New(1000)), Tables: []string{}, InvalidateWhenUpdate: true, // when you create/update/delete objects, invalidate cache CacheTTL: 5000, // 5000 ms CacheMaxItemCnt: 50, // if length of objects...

## GORM Playground Link [ https://github.com/go-gorm/playground/pull/761 ## Description ``` package main import ( "log" "github.com/gogf/gf/v2/util/grand" "gorm.io/driver/mysql" "gorm.io/gorm" ) type Route struct { ID uint `gorm:"primarykey"` CreatedAt int64 UpdatedAt int64 Name...

type:with reproduction steps

## Explain your user case and expected results ``` package main import ( "log" "github.com/gogf/gf/v2/util/grand" "gorm.io/driver/mysql" "gorm.io/gorm" ) type Route struct { ID uint `gorm:"primarykey"` CreatedAt int64 UpdatedAt int64 Name...

当前问题,使用嵌套字段时无法自动绑定到嵌套字段的文件 【已解决】 ``` type TestData struct { ID int64 `json:"id" dc:"ID"` Name string `json:"name" dc:"Name"` File *ghttp.UploadFile `json:"file" dc:"File" type:"file"` Files *ghttp.UploadFiles `json:"files" dc:"Files" type:"file"` } type TestReq struct {...