Docs feedback: Suggest using regexp operator in favor of like/ilike

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

  • Close this issue

https://docs.gitlab.com/ee/development/sql.html

This document discusses using LIKE and ILIKE in SQL. It does not, however, cover a common user oversight when it comes to using the LIKE/ILIKE expressions, namely that the '_' character is a single-character wildcard and if you want to match a literal '_' then it needs escaped just as '%' would.

Both PostgreSQL and MySQL offer regexp operators, and since everyone is generally more fluent with regular expressions than SQL LIKE/ILIKE/SIMILAR TO syntax, the likelihood of making a mistake due to not realizing the '_' character needs escaped when intended to match literally is less. Regular expressions are also much more powerful, and for some cases (particularly SIMILAR TO), is significantly faster.

I would advocate that the document be updated to promote the use of regular expression operators first, and add documentation of the single character wildcard character if LIKE remains encouraged at all. I am not familiar with Arel or Ruby however, and am not sure how these operators may be exposed to the programming language.

Edited Sep 13, 2025 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading