切片类型的bug? #1486

Closed
opened 2019-11-29 15:13:59 +00:00 by leigg · 11 comments

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 ? ```
Author

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

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

是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"` } ```
Author

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

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

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

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

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

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

还有一个问题就是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)
Author

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 2019-12-02 06:32:09 +00:00
lunny added this to the 0.8.2 milestone 2019-12-02 06:32:28 +00:00
Author

3ks

3ks
lunny modified the milestone from 0.8.2 to 1.3.0 2020-01-20 06:02:05 +00:00
lunny modified the milestone from 1.3.0 to 1.1.1 2021-06-09 03:44:54 +00:00
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 2021-06-09 06:06:15 +00:00
lunny referenced this issue from a commit 2021-06-09 11:30:16 +00:00
lunny closed this issue 2021-06-09 11:30:29 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: xorm/xorm#1486
No description provided.