Skip to content

fix: compare workbook names as strings for postgres - #1253

Open
chdecultot wants to merge 1 commit into
frappe:developfrom
chdecultot:fix/postgres-workbook-name-type-mismatch
Open

fix: compare workbook names as strings for postgres#1253
chdecultot wants to merge 1 commit into
frappe:developfrom
chdecultot:fix/postgres-workbook-name-type-mismatch

Conversation

@chdecultot

Copy link
Copy Markdown
Contributor

Insights Workbook is autoincrement, so its name is an int, while every column that references it is varchar(140): View Log.reference_name and DocShare.share_name (Dynamic Link) and the workbook Link fields. The pypika-based list query binds filter values as-is (the legacy db_query path used to cstr them), so postgres gets "reference_name" IN (3,2,1) and fails with operator does not exist: character varying = integer.

Stringify the name everywhere it reaches a filter or an insert. Link columns need the controllers to do it: _validate_links re-sets the link to the fetched name (an int) before validate/before_save run, so the client sending "3" isn't enough.

Also cast the bigint side of the four workbook joins in the permission queries. Admins short-circuit those, which is why only the View Log error surfaced; without the cast a non-admin can't list workbooks at all. MariaDB coerces on its own, so the cast is postgres-only and plans there are unchanged.

Fixes #1193

`Insights Workbook` is autoincrement, so its `name` is an int, while every
column that references it is varchar(140): `View Log.reference_name` and
`DocShare.share_name` (Dynamic Link) and the `workbook` Link fields. The
pypika-based list query binds filter values as-is (the legacy db_query path
used to cstr them), so postgres gets `"reference_name" IN (3,2,1)` and fails
with `operator does not exist: character varying = integer`.

Stringify the name everywhere it reaches a filter or an insert. Link columns
need the controllers to do it: `_validate_links` re-sets the link to the
fetched `name` (an int) before `validate`/`before_save` run, so the client
sending "3" isn't enough.

Also cast the bigint side of the four workbook joins in the permission
queries. Admins short-circuit those, which is why only the View Log error
surfaced; without the cast a non-admin can't list workbooks at all. MariaDB
coerces on its own, so the cast is postgres-only and plans there are unchanged.

Fixes frappe#1193

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mergify

mergify Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@greptile-apps

greptile-apps Bot commented Jul 22, 2026

Copy link
Copy Markdown

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Reviews (1): Last reviewed commit: "fix: compare workbook names as strings f..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PostgreSQL: View Log reference_name ⋅ operator does not exist "character varying = integer"

1 participant