Skip to content

fix: LIKE on INTEGER columns fails in PostgreSQL#1917

Open
ivan95mq wants to merge 1 commit intoNeoRazorX:masterfrom
ivan95mq:fix/like-integer-postgresql
Open

fix: LIKE on INTEGER columns fails in PostgreSQL#1917
ivan95mq wants to merge 1 commit intoNeoRazorX:masterfrom
ivan95mq:fix/like-integer-postgresql

Conversation

@ivan95mq
Copy link
Copy Markdown

Summary

When using LIKE or NOT LIKE operators on INTEGER columns (e.g. idproyecto), PostgreSQL throws a type error because LOWER() cannot be applied to integer types:

operator does not exist: integer ~~ unknown

This happens in the sqlOperatorLike method in Core/Where.php.

Fix

Wrapping the column reference in CONCAT(col, '') forces an implicit cast to text, making LOWER() work correctly on any column type:

```php
// Before
'LOWER(' . self::sqlColumn($field) . ') ' . $operator

// After
'LOWER(CONCAT(' . self::sqlColumn($field) . ",'')) " . $operator
```

Compatibility

  • PostgreSQL: fixes the type error on integer columns
  • MySQL: `CONCAT()` is fully supported, no behavior change on text columns

Use case

This fixes autocomplete searches on integer fields — for example, searching projects by ID in sales/purchase documents when using the Proyectos plugin (`idproyecto LIKE '%123%'`).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant