mmikkel/Reasons-Craft3

Package installs correctly, but then all pages display the error (presumably due to config rebuild as `project-config/rebuild` also throws same error):

Closed this issue ยท 4 comments

Experiencing something similar when trying to add Reasons to an existing site. Package installs correctly, but then all pages display the error (presumably due to config rebuild as project-config/rebuild also throws same error):

error: SQLSTATE[42703]: Undefined column: 7 ERROR:  column reasons.fieldlayoutid does not exist
LINE 3: ...fieldlayouts" "fieldlayouts" ON fieldlayouts.id = reasons.fi...
                                                             ^
HINT:  Perhaps you meant to reference the column "reasons.fieldLayoutId".
The SQL being executed was: SELECT "reasons"."uid", "reasons"."conditionals", "fieldlayouts"."uid" AS "fieldLayoutUid"
FROM "reasons" "reasons"
INNER JOIN "fieldlayouts" "fieldlayouts" ON fieldlayouts.id = reasons.fieldLayoutId

Can send through a DB dump and the config/project directory if needed ๐Ÿ‘

Craft: Pro 3.5.14
Reasons: 2.2.2
DB Engine: PostgreSQL 12.1

Originally posted by @slavanossar in #9 (comment)

Hi @slavanossar, thanks for reporting. Not sure if this is project config related problem per se, or a Postgres issue. I'll look into it ASAP.

@mmikkel Thanks for looking into it.

So I did a bit more digging after you mentioned it might be a Postgres issue and came across this SO answer.

I checked the stack trace and this was the line that was causing the error:

->innerJoin('{{%fieldlayouts}} AS fieldlayouts', 'fieldlayouts.id = fieldLayoutId')

Changing it to use "fieldLayoutId" fixes the error, and I created a few conditional field layouts as a test and everything seems to be working correctly. Not sure if it's specific to my environment though.

That's awesome, @slavanossar โ€“ thanks a lot for the follow-up and detective work.

I'll get a fix out ASAP... unless you want to submit a PR? ๐Ÿ˜‡

Issue should be resolved in Reasons 2.2.3