切片类型的bug? #1486

Closed
opened 2 years ago by leigg · 11 comments
leigg commented 2 years ago

code:

type user struct {
     Name []int `xorm:"json notnull"`
}
u := user{[]int{}}
engine.Insert(&u)  // 然后name插入的值是int64的0 ?
code: ``` type user struct { Name []int `xorm:"json notnull"` } u := user{[]int{}} engine.Insert(&u) // 然后name插入的值是int64的0 ? ```
Poster

数据库字段类型被认为是int(11), mysql v5.6.37-log

数据库字段类型被认为是int(11), mysql v5.6.37-log
Poster

是5.6版本不支持json导致的么?如果是,建表时可不可以以err形式展示?

是5.6版本不支持json导致的么?如果是,建表时可不可以以err形式展示?
Owner
type user struct {
     Name []int `xorm:"json text notnull"`
}
```go type user struct { Name []int `xorm:"json text notnull"` } ```
Poster

测试了,不是mysql版本问题,[]string可以识别为text,[]int不行,这需要修复吧?文档说的是array都能识别为text

测试了,不是mysql版本问题,[]string可以识别为text,[]int不行,这需要修复吧?文档说的是array都能识别为text
Poster

[]string类型不需要显式注明text tag

[]string类型不需要显式注明text tag
Poster

sorry,上面说错了。mysql 5.7中[]int可以识别为text类型,看来是mysql版本问题。

sorry,上面说错了。mysql 5.7中[]int可以识别为text类型,看来是mysql版本问题。
Poster

还有一个问题就是array类型,即使指定notnull,在insert时若不填充有效值,xorm仍然会插入一个"null",在查询时还不会报错。

图一

image

图二

image

还有一个问题就是array类型,即使指定notnull,在insert时若不填充有效值,xorm仍然会插入一个"null",在查询时还不会报错。 ##### 图一 ![image](/attachments/d130f163-a70d-4513-b57d-c25346034702) ##### 图二 ![image](/attachments/9582b1bb-2c19-4f1f-9e9c-8878b4783b28)
Poster

Can I know why this problem can't be dealt with? Too busy?

Can I know why this problem can't be dealt with? Too busy?
Owner

还有一个问题就是array类型,即使指定notnull,在insert时若不填充有效值,xorm仍然会插入一个"null",在查询时还不会报错。

图一

image

图二

image

This maybe a bug.

> 还有一个问题就是array类型,即使指定notnull,在insert时若不填充有效值,xorm仍然会插入一个"null",在查询时还不会报错。 > ##### 图一 > ![image](/attachments/d130f163-a70d-4513-b57d-c25346034702) > ##### 图二 > ![image](/attachments/9582b1bb-2c19-4f1f-9e9c-8878b4783b28) This maybe a bug.
lunny added the
kind/bug
label 2 years ago
lunny added this to the 0.8.2 milestone 2 years ago
Poster

3ks

3ks
lunny modified the milestone from 0.8.2 to 1.3.0 2 years ago
lunny modified the milestone from 1.3.0 to 1.1.1 6 months ago
Owner

The null is a json result from nil. So I think it will not affect the result.

The `null` is a json result from `nil`. So I think it will not affect the result.
lunny referenced this issue from a commit 6 months ago
lunny referenced this issue from a commit 6 months ago
lunny closed this issue 6 months ago
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.