切片如何转数组? gorm 的 in 查询不支持切片
1
codehz Sep 25, 2019
首先必须长度固定,然后
var target[5]int copy(target[:], source) |
3
codehz Sep 25, 2019
那就
target := make([]int, n) copy(target[:], source) |
4
chotow Sep 25, 2019
gorm 的 in 查询是支持切片的: http://gorm.io/docs/query.html#Plain-SQL
xorm 不支持(吐血) |
5
kedadiannao220 Sep 25, 2019 |
6
252748371 OP |
7
252748371 OP 解决了
原来不能传指针! |
8
chotow Sep 27, 2019
@kedadiannao220 #5
xorm Raw SQL 查询的时候,怎么实现 in 传值呢? 我试了下:db.SQL("select * from test").In("id", []uint64{1, 2, 3}).Find(&ret) 这样子并不可以 |
9
kedadiannao220 Nov 15, 2019
@chotow
使用 raw sql,就不用再使用 In、where 这些函数了; db.SQL("select * from test where id in xxxx"),这样会存在 sql 注入的风险 |