[postgres] after purging submissions click the log link and get DatabaseExceptionWrapper: SQLSTATE[42601]: Syntax error: 7 ERROR

Created on 31 August 2022, over 2 years ago
Updated 14 September 2023, over 1 year ago

Problem/Motivation

Error occured: line 133 of modules/contrib/webform/modules/webform_submission_log/src/WebformSubmissionLogManager.php

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "."
LINE 6: ...T OUTER JOIN "users_field_data" "user" ON log.uid = user.uid
         ^: SELECT COUNT(*) AS "expression" 
FROM 
(SELECT 1 AS "expression" 
FROM "webform_submission_log" "log" 
LEFT OUTER JOIN "users_field_data" "user" ON log.uid = user.uid 
LEFT OUTER JOIN "webform_submission" "submission" ON log.sid = submission.sid) "subquery";

Array ( ) in Drupal\webform_submission_log\WebformSubmissionLogManager->loadByEntities() (line 133 of modules/contrib/webform/modules/webform_submission_log/src/WebformSubmissionLogManager.php).

Steps to reproduce

Action: purged webform submissions.
Next Action: Clicked the 'log' link at : /admin/structure/webform/submissions/log
Drupal version 9.3.21
Webform version 6.1.3
DB Version Postgresql v12
PHP version 8.0.16

Proposed resolution

TBD

Remaining tasks

TBD

User interface changes

TBD

API changes

TBD

Data model changes

TBD

πŸ› Bug report
Status

Fixed

Version

6.1

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada joseph.olstad

Live updates comments and jobs are added and updated live.
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.

  • πŸ‡ΊπŸ‡ΈUnited States jrockowitz Brooklyn, NY

    Prepending [postgres] to the title to see if someone using postgres can fix it.

  • Had a different issue, but similar with a Postgres db, while using webform autosave, that was calling into WebformSubmissionLogManager

    This change fixed it for me.
    Would like to set up automated tests for postgres, but don't know yet how, yet.

    
    pgdb_1  | 2023-07-04 18:57:39.489 UTC [38] ERROR:  syntax error at or near "." at character 482
    pgdb_1  | 2023-07-04 18:57:39.489 UTC [38] STATEMENT:  SELECT "log"."lid" AS "lid", "log"."uid" AS "uid", "log"."webform_id" AS "webform_id", "log"."sid" AS "sid", "log"."handler_id" AS "handler_id", "log"."operation" AS "operation", "log"."message" AS "message", "log"."variables" AS "variables", "log"."timestamp" AS "timestamp", "log"."data" AS "data", "submission"."entity_type" AS "entity_type", "submission"."entity_id" AS "entity_id"
    pgdb_1  | 	FROM
    pgdb_1  | 	"webform_submission_log" "log"
    pgdb_1  | 	LEFT OUTER JOIN "users_field_data" "user" ON log.uid = user.uid
    pgdb_1  | 	LEFT OUTER JOIN "webform_submission" "submission" ON log.sid = submission.sid
    pgdb_1  | 	WHERE ("log"."webform_id" = 'demo_cop') AND ("log"."sid" = '28')
    pgdb_1  | 	ORDER BY "timestamp" DESC NULLS LAST
    pgdb_1  | 	LIMIT 1 OFFSET 0
    web_1   | [Tue Jul 04 18:57:39.497438 2023] [php:notice] [pid 19] [client 172.24.0.1:36616] Uncaught PHP Exception Drupal\\Core\\Database\\DatabaseExceptionWrapper: "SQLSTATE[42601]: Syntax error: 7 ERROR:  syntax error at or near "."\nLINE 4: ...T OUTER JOIN "users_field_data" "user" ON log.uid = user.uid\n                                                                   ^: SELECT "log"."lid" AS "lid", "log"."uid" AS "uid", "log"."webform_id" AS "webform_id", "log"."sid" AS "sid", "log"."handler_id" AS "handler_id", "log"."operation" AS "operation", "log"."message" AS "message", "log"."variables" AS "variables", "log"."timestamp" AS "timestamp", "log"."data" AS "data", "submission"."entity_type" AS "entity_type", "submission"."entity_id" AS "entity_id"\nFROM\n"webform_submission_log" "log"\nLEFT OUTER JOIN "users_field_data" "user" ON log.uid = user.uid\nLEFT OUTER JOIN "webform_submission" "submission" ON log.sid = submission.sid\nWHERE ("log"."webform_id" = :db_condition_placeholder_0) AND ("log"."sid" = :db_condition_placeholder_1)\nORDER BY "timestamp" DESC NULLS LAST\nLIMIT 1 OFFSET 0; Array\n(\n    [:db_condition_placeholder_0] => demo_cop\n    [:db_condition_placeholder_1] => 28\n)\n" at /opt/drupal/web/core/lib/Drupal/Core/Database/ExceptionHandler.php line 66
    
    

    PS: First time contributor to a drupal project, tried to follow the contribution guide. Let me know if anything needs to change.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 8.1 & pgsql-14.1
    last update over 1 year ago
    537 pass
  • πŸ‡ΊπŸ‡ΈUnited States jrockowitz Brooklyn, NY

    Your patch makes sense because USER is a reserved word in Postgres
    https://www.postgresql.org/docs/current/sql-keywords-appendix.html

    If the test even partially passes for Postgres and MySQL tests are fine, we can probably safely commit the patch.

  • Status changed to Needs review over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States jrockowitz Brooklyn, NY
  • Status changed to RTBC over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States jrockowitz Brooklyn, NY
  • πŸ‡¨πŸ‡¦Canada joseph.olstad

    looks good, should hold up nicely for everyone pgsql/mariadb/mysql/sqlite/mssql/others

    • pirvudoru β†’ authored 8646caaf on 6.1.x
      Issue #3307128 by pirvudoru: [postgres] after purging submissions click...
  • πŸ‡ΊπŸ‡ΈUnited States jrockowitz Brooklyn, NY
  • Status changed to Fixed over 1 year ago
    • pirvudoru β†’ authored 8646caaf on 6.2.x
      Issue #3307128 by pirvudoru: [postgres] after purging submissions click...
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024