sqlite3 on rails: create_table using collate nocase

后端 未结 2 1778
孤城傲影
孤城傲影 2021-01-24 02:13

Using rails 4.2.0 with ruby v2.3.0p0

I want to create indexes that are case insensitive since most of my searches are case insensitive and I don\'t want to have to do a

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-24 02:49

    Doesn't look like collation on an index has been merged yet:

    https://github.com/rails/rails/pull/18499/files

    This PR, adds collation support for columns by the way.

    The syntax looks like:

    create_table :foo do |t|
      t.string :string_nocase, collation: 'NOCASE'
      t.text :text_rtrim, collation: 'RTRIM'
    end
    
    add_column :foo, :title, :string, collation: 'RTRIM'
    
    change_column :foo, :title, :string, collation: 'NOCASE'
    

提交回复
热议问题