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

Comments

joseph.olstad created an issue. See original summary.

joseph.olstad’s picture

Issue summary: View changes
cilefen’s picture

The Webform module's issue queue is for bugs, feature requests, and planning. Please post general support questions to Drupal Answers. You can also ask questions or help answer questions on the #webform channel on Drupal Slack.

Is this a bug?

joseph.olstad’s picture

yes this is what I would call a 'bug'

joseph.olstad’s picture

Category: Support request » Bug report
joseph.olstad’s picture

might be related somehow

joseph.olstad’s picture

sfcamil’s picture

Hy,

I have the same issue with webform 6.1.3 , core 9.5 with postgres

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).

jrockowitz’s picture

Title: after purging submissions click the log link and get DatabaseExceptionWrapper: SQLSTATE[42601]: Syntax error: 7 ERROR » [postgres] after purging submissions click the log link and get DatabaseExceptionWrapper: SQLSTATE[42601]: Syntax error: 7 ERROR
Status: Active » Needs work

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

pirvudoru’s picture

StatusFileSize
new716 bytes

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.

jrockowitz’s picture

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.

jrockowitz’s picture

Status: Needs work » Needs review
jrockowitz’s picture

Status: Needs review » Reviewed & tested by the community
joseph.olstad’s picture

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...

  • pirvudoru authored 8646caaf on 6.x
    Issue #3307128 by pirvudoru: [postgres] after purging submissions click...
jrockowitz’s picture

Status: Reviewed & tested by the community » Fixed

  • pirvudoru authored 8646caaf on 6.2.x
    Issue #3307128 by pirvudoru: [postgres] after purging submissions click...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

cmanalansan’s picture

Can a maintainer reopen this issue? It got reintroduced when the fix for https://www.drupal.org/project/webform/issues/3508995 get applied