volatiletech / sqlboiler

Generate a Go ORM tailored to your database schema.
BSD 3-Clause "New" or "Revised" License
6.7k stars 542 forks source link

Generate helpers for PostgreSQL SIMILAR TO clause #1391

Closed jerrysalonen closed 3 months ago

jerrysalonen commented 3 months ago

It would be nice to have support for SIMILAR TO expressions in the psql drivers. Something like

models.Examples(
  models.Field.SimilarTo("(foo|bar)"),
).All(ctx, tx)

would generate

SELECT * FROM example WHERE field SIMILAR TO '(foo|bar)';

It is not too much trouble to just write something like models.Where("field SIMILAR TO ?", "(foo|bar)") but a helper would be nice. If this is something that is desirable I could make a PR for this

stephenafamo commented 3 months ago

SIMILAR TO is only supported for text fields, if you can limit this to the Postgres generation and only for text fields, then sure 👍🏾