Views PostgreSQL Error | SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for type bigint

Created on 9 March 2022, over 2 years ago
Updated 28 March 2024, 8 months ago

Hello all,

Problem/Motivation

Drupal Version: 9.3.6
PHP Version: 8.1.3
Database: PostgreSQL
Database Version: 13.6
Development Environment: Docker 4 Drupal

I'm trying to create a view, using fields, one relationship with entity reference field between 2 content types and a contextual filter for content ID. When I try to provide the default value by content ID from URL, it works. Unfortunately, I have to provide default value as "raw value from URL" type. When I try to do it, I get the error message which I paste below:

SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for type bigint: "structure" LINE 6: ... ((field_measuring_stations_node_field_data.nid = 'structure... ^: SELECT "node_field_data"."langcode" AS "node_field_data_langcode", "field_measuring_stations_node_field_data"."langcode" AS "field_measuring_stations_node_field_data_langcode", "node_field_data"."created" AS "node_field_data_created", "node_field_data"."nid" AS "nid", "field_measuring_stations_node_field_data"."nid" AS "field_measuring_stations_node_field_data_nid" FROM "node_field_data" "node_field_data" LEFT JOIN "node__field_measuring_stations" "node__field_measuring_stations" ON node_field_data.nid = node__field_measuring_stations.field_measuring_stations_target_id AND node__field_measuring_stations.deleted = :views_join_condition_0 LEFT JOIN "node_field_data" "field_measuring_stations_node_field_data" ON node__field_measuring_stations.entity_id = field_measuring_stations_node_field_data.nid WHERE ((field_measuring_stations_node_field_data.nid = :node_field_data_nid)) AND ("node_field_data"."type" IN (:db_condition_placeholder_1)) ORDER BY "node_field_data_created" DESC NULLS LAST LIMIT 5 OFFSET 0; Array ( [:node_field_data_nid] => structure [:db_condition_placeholder_1] => station [:views_join_condition_0] => 0 )

Steps to reproduce

The way to reproduce the error is:
- Install Drupal 9.3.6 with PHP 8.1.3 and PostgreSQL 13.6 (I'm going to paste docker-compose.yml and .env content as comments, if someone would like to use them).
- Create 2 different content types with entity reference one to another.
- Create a view with contextual filter, providing default value as "raw value from URL" type.

Proposed resolution

I've found this issue β†’ , while searching a solution. It could be helpful for debugging.

Best,
Orkut

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
ViewsΒ  β†’

Last updated 2 days ago

Created by

πŸ‡ΉπŸ‡·Turkey orkut murat yΔ±lmaz Istanbul

Live updates comments and jobs are added and updated live.
  • PostgreSQL

    Particularly affects sites running on the PostgreSQL database.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡·πŸ‡ΊRussia Chi

    There issue appears in many cases. The simplest way to reproduce is adding exposed filter to some int property (i.e. entity ID) and then try to submit it with a string value.

  • πŸ‡·πŸ‡ΊRussia Chi

    Patch #7 is not consistent with MySQL behavior as it uses zero as fallback value. I think if provided input value is not correct the SQL query should not return any results.

    That attached patch fixes the issue for numeric filters. I think for numeric arguments it could be done same way.

Production build 0.71.5 2024