Skip to content

fix: use sqlite3_value_text for REGEXP to match SQLite coercion#4203

Open
joaquinhuigomez wants to merge 1 commit intolaunchbadge:mainfrom
joaquinhuigomez:fix/sqlite-regexp-text-coercion
Open

fix: use sqlite3_value_text for REGEXP to match SQLite coercion#4203
joaquinhuigomez wants to merge 1 commit intolaunchbadge:mainfrom
joaquinhuigomez:fix/sqlite-regexp-text-coercion

Conversation

@joaquinhuigomez
Copy link
Copy Markdown

The REGEXP implementation rejects non-TEXT values by checking sqlite3_value_type() before calling sqlite3_value_text(). This means 123 REGEXP '23' returns NULL instead of matching.

Per the SQLite docs, calling sqlite3_value_text() on INTEGER/REAL/BLOB values coerces them to their text representation. This change removes the type check (except for NULL) and lets SQLite handle the coercion, matching the behavior users expect from X REGEXP Y on non-TEXT columns.

Added test covering INTEGER, REAL, INTEGER column, and NULL cases.

Closes #4190

Use sqlite3_value_text() instead of checking sqlite3_value_type()
first, matching SQLite's documented text affinity coercion for
the REGEXP operator. NULL values still return NULL.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sqlite: REGEXP rejects non-TEXT values instead of using SQLite text coercion

1 participant