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

Feature Request: pg_trgm #858

Closed
quadrupleslap opened this Issue Apr 13, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@quadrupleslap

quadrupleslap commented Apr 13, 2017

What do you want to do and how do you expect Diesel to support you with that?

I want to use the pg_trgm module, in particular the similarity, % and <-> functions/operators. Diesel should allow the safe construction of queries involving these.

How do you think this can be added to Diesel?

This'd hopefully be added with similarity(text, text) -> real and word_similarity(text, text) -> real functions, and two text expression methods (text <-> text) : real (distance) and (text % text) : bool (is similar to), and maybe the other functions described on https://www.postgresql.org/docs/9.1/static/pgtrgm.html to be comprehensive. It might also be a good idea to introduce another feature gate.

What are possible alternatives?

Dealing with raw queries, but nobody wants that. :P

Are there any disadvantages?

None that I can think of.

@sgrif

This comment has been minimized.

Member

sgrif commented Apr 14, 2017

For non-core modules like these, Diesel is designed to be extended by third party crates. I don't think this makes much sense to be in Diesel proper. Functions can be implemented with the sql_function! macro (http://docs.diesel.rs/diesel/macro.sql_function.html). For a proof of concept of how to implement custom operators/types, please see https://github.com/diesel-rs/diesel_full_text_search

@sgrif sgrif closed this Apr 14, 2017

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