Fix: QueryBuilder's TextConstraint for Postgres #15446
Open
+44
−20
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
When a table name or column name contains uppercase letters, both table name and column name gets wrapped between double quotes inside any
TextContraint
operator.for example:
Flight
table name withcode
field name becomes"Flight.code"
which results in column not found error. Instead, it should be"Flight".code
, and if column name contains uppercase letters, it should be"Flight"."Code"
.Example error:
Undefined column: 7 ERROR: column "Flight.code" does not exist LINE 1: ...count(*) as aggregate from "Flight" where (lower("Flight.c... ^ (Connection: pgsql, SQL: select count(*) as aggregate from "Flight" where (lower("Flight.code"::text)::text like search_string%))
It might not be very common when it comes to Laravel naming conventions, but I encountered this issue while building a dashboard for an app that was initially developed with Next.js and prisma, where this naming convention is common.
Functional changes
composer cs
command.