Problem/Motivation

In WebformSubmissionLogManager::getQuery() the database table users_field_data gets aliased to user.

Since user is a reserved term in PostgreSQL the query fails and raises an exception.

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
WHERE ("log"."webform_id" = :db_condition_placeholder_0) AND ("log"."sid" = :db_condition_placeholder_1)) "subquery";

See PostgreSQL documentation appendix for reference.

Steps to reproduce

Open route entity.webform_submission.edit_form on any submission

Proposed resolution

Rename the alias user to user_data

Remaining tasks

apply fix

User interface changes

none

API changes

none

Data model changes

none

Issue fork webform-3565422

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:

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

guedressel created an issue. See original summary.

guedressel changed the visibility of the branch 3565422-sql-table-alias to hidden.

guedressel’s picture

Project: Webform Workflows Element » Webform
Version: 2.0.x-dev » 6.3.x-dev
guedressel’s picture

I've submitted this issue on the wrong module first. Please ignore the issue fork "Issue fork webform_workflows_element-3565422".

mably’s picture

We could even shorten it to ufd.

cilefen’s picture

I had a quick and cursory look at the Webform codebase, and only at a glance, I see users_field_data being aliased to u but not to user.

mably’s picture

Here is what I get when in do a quick search in my Drupal install:

Search users_field_data

cilefen’s picture

I overlooked WebformSubmissionLogManager in my findings. That's probably the one! It looks like a simple fix.

guedressel’s picture

Simple fix just committed to the issue fork and created a merge request. Thanks for your support.

guedressel’s picture

Status: Active » Needs review
mably’s picture

Change looks ok to me.

liam morland made their first commit to this issue’s fork.

liam morland’s picture

Status: Needs review » Fixed

Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

liam morland’s picture

Issue tags: +PostgreSQL

Status: Fixed » Closed (fixed)

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