Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Citext support on Postgres #40

Open
dolzenko opened this issue May 10, 2018 · 4 comments
Open

Citext support on Postgres #40

dolzenko opened this issue May 10, 2018 · 4 comments

Comments

@dolzenko
Copy link

Citext column type is useful on Postgres for case-insesitive comparisons [0], currently searching for such column fails with

     NameError:
       uninitialized constant SearchCopGrammar::Attributes::Citext

placing following code in initializer fixes it (I could add a PR but not sure about tests)

module SearchCopGrammar
  module Attributes
    class Citext < String; end
  end
end

module SearchCop
  module Visitors
    class Visitor
      alias :visit_SearchCopGrammar_Attributes_Citext :visit_attribute
    end
  end
end

[0] https://www.postgresql.org/docs/10/static/citext.html

@mrkamel
Copy link
Owner

mrkamel commented May 14, 2018

ok, thx, i'll look into it.

@mrkamel
Copy link
Owner

mrkamel commented May 14, 2018

i'm not quite sure i want to add support for a database specific datatype, that needs to be explicity enabled (postgres module). You can easily get the same (search-wise) via a functional index. Why not use that instead?

@dolzenko
Copy link
Author

Understandable, I think I went for citext instead of index mostly for 'purist' reasons

https://www.postgresql.org/message-id/CAO8h7BJMX5V1TqzScTx2Nr1jH5iUFG8A071y-g1b_kdzpu9PDw%40mail.gmail.com

Conceptually the index is an implementation detail and uniqueness should be
associated only with constraints.

@mrkamel
Copy link
Owner

mrkamel commented May 15, 2018

ok, well, then we probably need to define datatype aliases/mappings or some kind of plugin architecture, such that the main code base stays clean. However, the benefit of adding support for aliases/mappings seems limited. Take #28 for instance, which can't be easily mapped to an existing datatype due to the inet prefix required within queries. Adding a plugin architecture doesn't seem to provide much benefit either, because users will easily end up in sql injection issues as they need to handle all the sql generation themselves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants