Using Postgres functions like `LEVENSHTEIN` and `btrim`?

39 views
Skip to first unread message

Alec Taylor

unread,
May 21, 2015, 12:09:07 AM5/21/15
to peewe...@googlegroups.com
Is it possible to use Postgres functions without dropping out of the ORM?

Thanks for all suggestions

Alec Taylor

unread,
May 21, 2015, 12:14:27 AM5/21/15
to peewe...@googlegroups.com

Charles Leifer

unread,
May 21, 2015, 12:18:31 AM5/21/15
to peewe...@googlegroups.com
Peewee supports calling any arbitrary database function using the `fn` object:

User.select(fn.UPPER(User.username).alias('username_upper'))

I imagine you can just call `fn.LEVENSHTEIN` the same way:

SomeModel.select().where(fn.LEVENSHTEIN(SomeModel.col_a, 'other_value') < 10)

On Wed, May 20, 2015 at 11:09 PM, Alec Taylor <alec.t...@gmail.com> wrote:
Is it possible to use Postgres functions without dropping out of the ORM?

Thanks for all suggestions

--
You received this message because you are subscribed to the Google Groups "peewee-orm" group.
To unsubscribe from this group and stop receiving emails from it, send an email to peewee-orm+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages