Steps to reproduce

Enter "example (test)" value to any entity autocomplete field.

The following exception will be thrown.

The website encountered an unexpected error. Please try again later.

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for type bigint: "test" LINE 5: ...('tags')) AND ("taxonomy_term_field_data"."tid" IN ('test')) ^: SELECT "base_table"."revision_id" AS "revision_id", "base_table"."tid" AS "tid" FROM "taxonomy_term_data" "base_table" INNER JOIN "taxonomy_term_field_data" "taxonomy_term_field_data" ON "taxonomy_term_field_data"."tid" = "base_table"."tid" WHERE ("taxonomy_term_field_data"."vid" IN (:db_condition_placeholder_0)) AND ("taxonomy_term_field_data"."tid" IN (:db_condition_placeholder_1)); Array ( [:db_condition_placeholder_0] => tags [:db_condition_placeholder_1] => test ) in Drupal\Core\Entity\Query\Sql\Query->result() (line 273 of core/lib/Drupal/Core/Entity/Query/Sql/Query.php).

Details

Drupal 10.1.x, PHP 8.2, PostgreSQL 15

Issue fork drupal-3372068

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Chi created an issue. See original summary.

chi’s picture

Status: Active » Needs review
StatusFileSize
new1.37 KB

Status: Needs review » Needs work

The last submitted patch, 2: postgres-invalid-input-syntax_3372068_2.patch, failed testing. View results

chi’s picture

The alternative solution could be casting field entity ID to text in SQL query.

joseph.olstad’s picture

Version: 10.1.x-dev » 11.x-dev
Status: Needs work » Active

Hello @Chi, thank you for this fix, it works for me also. No longer a WSOD running psql with this situation .
I'm not quite sure on steps to reproduce in my case so I'll leave yours as it seems easier to reproduce.
This works on both psql 12 and psql 13

Fix applies to D9.5.x also.

niklan’s picture

Patch for Drupal 10.3+

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

liam morland’s picture

The patch in #6 would stop the error messages, but may end up hiding an underlying issue with entities that have non-integer IDs.

liam morland’s picture

Issue tags: +PostgreSQL

ishani patel made their first commit to this issue’s fork.