The Go Programming Language
http://golang.org/
Go Playground
Go Projects
Revel Web Framework
hambman

PostgreSQL with Gorm 区分大小写的问题

  •  
  •   hambman · Sep 17, 2020 · 2504 views
    This topic created in 2090 days ago, the information mentioned may be changed or developed.

    PostgreSQL 不区分大小写, 大家推荐的方案或者用 citext, 或者自定义的 validator

    但是我用 gorm 作为 orm, 没有看到 gorm 的支持,请教大家。 @jinzhu

    2 replies    2020-09-17 23:55:02 +08:00
    PopRain
        1
    PopRain  
       Sep 17, 2020
    看你写的,PostgreSQL 查询区分大小写,不支持大小写不敏感的查询,citext 是个“插件”,所以要加类型声明,否则查询效率很低,很多 orm 都不支持
    hambman
        2
    hambman  
    OP
       Sep 17, 2020
    @PopRain 是的,问题描述不太准确。暂时先用简单的办法,select * from foo where lower(username) = lower(key)
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   961 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 21:53 · PVG 05:53 · LAX 14:53 · JFK 17:53
    ♥ Do have faith in what you're doing.