Comments (6)
不加``当时主要考虑的是可以额外留一点可以trick的空间,来更改sql语句,比如说 可以把 field的[]string{"*"}写成[]string{"SQL_NO_CACHE *"},这样最终构建的sql就是 select SQL_NO_CACHE * from xxx where yyy
,这样可以强制mysql不使用缓存,包括where中的字段,也可以使用mysql自带的函数。主要是这么一个考虑。
谢谢你的建议,我们会思考一下怎样改进,也建议尽量避免使用软件自身的保留字
from gendry.
@zt3862266 @nlimpid @baozh 关于这个问题, 我写了一个wiki来解释, 非常希望大家可以抽时间看一看. 也很希望得到大家阅后的反馈
目前来看, 短期内是没办法直接解决这个问题, 因为这是个breaking change.
对于和关键字冲突的case, 我提供两个解决方法:
- 自己加上`, 比如:
where := map[string]interface{}{"`select`": "football", "`age` >": 10}
- 使用NamedQuery:
builder.NamedQuery("select * from `tb` where `select`={select}", map[string]interface{}{"select": "football",})
from gendry.
插入和读取的语法不同,以最简单的插入为例,其实col_name是不允许修饰,所以非select的builder都应该加``
INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
[INTO] tbl_name
[PARTITION (partition_name [, partition_name] ...)]
[(col_name [, col_name] ...)]
{ {VALUES | VALUE} (value_list) [, (value_list)] ...
|
VALUES row_constructor_list
}
[AS row_alias[(col_alias [, col_alias] ...)]]
[ON DUPLICATE KEY UPDATE assignment_list]
[1] https://dev.mysql.com/doc/refman/8.0/en/insert.html
from gendry.
这个解决了吗?我也遇到这个问题。用到了mysql关键字做字段名,查询失败。有什么方法解决吗?
from gendry.
这个解决了吗?我也遇到这个问题。用到了mysql关键字做字段名,查询失败。有什么方法解决吗?
@baozh 目前推荐暂时不要用数据库保留字做字段名, 下周会上一个版本解决这个问题
from gendry.
另外下周的版本能不能加个debug模式把sql打出来方便调试
from gendry.
Related Issues (20)
- NamedQuery 支持嵌套 map[string]interface{}, 实现过滤条件
- 是否支持MySQL关键词 HOT 2
- scanner.Scan返回错误码 HOT 3
- buildDelete不支持limit操作 HOT 1
- 请问下, BuildInsertOnDuplicate方法支持如下的sql吗? HOT 3
- 支持force index操作吗
- "[scanner]: empty result" HOT 4
- 请问可以支持UNION ALL语句吗? HOT 1
- 支持多个 or 查询 HOT 1
- scanner在go继承模式下,无法scan到父级tag HOT 1
- 请求打个最新版本的tag HOT 1
- mysql传limit句柄错误 HOT 9
- 您好,支持 IS NOT NULL吗?在文档里没有看到 HOT 2
- 对rows进行scan后, 需要检查err
- scan不支持结构体嵌套赋值
- where语句中两列数据相互比较,如何正确声明查询条件呢? HOT 5
- scan 对于继承的struct不生效 HOT 1
- ctx超时或取消情况下,scanner.Scan()方法会把err吞掉,不返回err,导致读出的数据不全
- map[string]interface{} support between ? and ? HOT 2
- buildInsert 对于mysql 5.7升级mysql 8.0 , 用到mysql 8.0关键词的人不友好, HOT 15
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gendry.