Giter VIP home page Giter VIP logo

Comments (6)

caibirdme avatar caibirdme commented on July 24, 2024 2

不加``当时主要考虑的是可以额外留一点可以trick的空间,来更改sql语句,比如说 可以把 field的[]string{"*"}写成[]string{"SQL_NO_CACHE *"},这样最终构建的sql就是 select SQL_NO_CACHE * from xxx where yyy,这样可以强制mysql不使用缓存,包括where中的字段,也可以使用mysql自带的函数。主要是这么一个考虑。

谢谢你的建议,我们会思考一下怎样改进,也建议尽量避免使用软件自身的保留字

from gendry.

caibirdme avatar caibirdme commented on July 24, 2024 1

@zt3862266 @nlimpid @baozh 关于这个问题, 我写了一个wiki来解释, 非常希望大家可以抽时间看一看. 也很希望得到大家阅后的反馈
目前来看, 短期内是没办法直接解决这个问题, 因为这是个breaking change.
对于和关键字冲突的case, 我提供两个解决方法:

  1. 自己加上`, 比如:
where := map[string]interface{}{"`select`": "football", "`age` >": 10}
  1. 使用NamedQuery:
builder.NamedQuery("select * from `tb` where `select`={select}", map[string]interface{}{"select": "football",})

from gendry.

nlimpid avatar nlimpid commented on July 24, 2024

插入和读取的语法不同,以最简单的插入为例,其实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.

baozh avatar baozh commented on July 24, 2024

这个解决了吗?我也遇到这个问题。用到了mysql关键字做字段名,查询失败。有什么方法解决吗?

from gendry.

caibirdme avatar caibirdme commented on July 24, 2024

这个解决了吗?我也遇到这个问题。用到了mysql关键字做字段名,查询失败。有什么方法解决吗?

@baozh 目前推荐暂时不要用数据库保留字做字段名, 下周会上一个版本解决这个问题

from gendry.

flyEagle2010 avatar flyEagle2010 commented on July 24, 2024

另外下周的版本能不能加个debug模式把sql打出来方便调试

from gendry.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.