Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Comments

fix(postgres): add pg compatible query for copying comm_date#35488

Merged
ankush merged 2 commits intofrappe:developfrom
AarDG10:fix-pg-query-comm-link
Jan 4, 2026
Merged

fix(postgres): add pg compatible query for copying comm_date#35488
ankush merged 2 commits intofrappe:developfrom
AarDG10:fix-pg-query-comm-link

Conversation

@AarDG10
Copy link
Member

@AarDG10 AarDG10 commented Dec 29, 2025

Problem:
fix(Postgres): This PR focusses on adding a Postgres compatible query in copy_communication_date_to_link.py and fixes #35281 . Previously the query was very MariaDB specific, this PR adds multi-db support for this feature for Postgres accounting for rules enforced by Postgres i.e. (Update with Limit (Not Allowed!), Update with Join (Not Allowed!). This PR is also a step forward towards resolving #21613.

Before:
image

After:
Migration works successfully

fixes #35281

@AarDG10 AarDG10 added the postgres postgres db related issue/PRs label Dec 29, 2025
@AarDG10 AarDG10 requested a review from akhilnarang December 29, 2025 08:25
@AarDG10 AarDG10 marked this pull request as ready for review December 29, 2025 08:25
@NagariaHussain
Copy link
Collaborator

Can't be done via qb? 👀

@AarDG10
Copy link
Member Author

AarDG10 commented Dec 29, 2025

Can't be done via qb? 👀

Possible tbf, would still need to use multisql though because the QB is not respecting Postgres Behavior i.e. using Join with Update and LIMIT , both of which are disallowed for update statements in PG

@akhilnarang
Copy link
Member

the QB is not respecting Postgres Behavior

This happens in pypika itself, or because of our changes?

@AarDG10
Copy link
Member Author

AarDG10 commented Dec 29, 2025

This happens in pypika itself, or because of our changes?

Seemingly an inherent constraint of Pypika itself, it does not seem to account for such "rules" of Postgres

@ankush
Copy link
Member

ankush commented Dec 29, 2025

We gave enough tries to PyPika, it's just not supported 😬

ankush
ankush previously requested changes Dec 29, 2025
@abhishek0010
Copy link

This test actions needs an update

@ili-ad
Copy link
Contributor

ili-ad commented Jan 3, 2026

Thanks — I hit the same failure during bench --site <site> migrate on Postgres and can confirm this PR unblocks copy_communication_date_to_link.

After this patch succeeds, my migration run then fails on a separate patch with the same class of root cause (MariaDB-specific DDL):

  • Patch that fails next: frappe.core.doctype.communication.patches.drop_ref_dt_dn_index
  • That patch calls: frappe.database.utils.drop_index_if_exists("tabCommunication", index_name)
  • Current DDL emitted by drop_index_if_exists:
    ALTER TABLE {table}DROP INDEX{index}`` (MariaDB-only)
  • Postgres error:
    syntax error at or near "INDEX" / Postgres expects DROP INDEX [IF EXISTS] <index>

So the linkage is: once Postgres can proceed past copy_communication_date_to_link, the next migration-time blocker is drop_index_if_exists using Maria-only ALTER TABLE ... DROP INDEX.

I have a minimal fix ready that preserves the existing click output/behavior and switches to:
DROP INDEX IF EXISTS "<index>" when frappe.db.db_type == "postgres".
Happy to open a PR against develop and request backport if you’d like.

@AarDG10
Copy link
Member Author

AarDG10 commented Jan 3, 2026

I have a minimal fix ready that preserves the existing click output/behavior and switches to: DROP INDEX IF EXISTS "<index>" when frappe.db.db_type == "postgres". Happy to open a PR against develop and request backport if you’d like.

@ili-ad feel free to raise a PR for the same. Thank You.

@ili-ad
Copy link
Contributor

ili-ad commented Jan 3, 2026

I have a minimal fix ready that preserves the existing click output/behavior and switches to: DROP INDEX IF EXISTS "<index>" when frappe.db.db_type == "postgres". Happy to open a PR against develop and request backport if you’d like.

@ili-ad feel free to raise a PR for the same. Thank You.

@AarDG10 PR up as requested: #35636

This addresses the next Postgres migration blocker after copy_communication_date_to_link:
drop_ref_dt_dn_indexdrop_index_if_exists emitting MariaDB-only ALTER TABLE ... DROP INDEX.

@AarDG10
Copy link
Member Author

AarDG10 commented Jan 4, 2026

@Mergifyio update

@mergify
Copy link
Contributor

mergify bot commented Jan 4, 2026

update

✅ Branch has been successfully updated

@ankush ankush merged commit 8d8fa78 into frappe:develop Jan 4, 2026
24 checks passed
mergify bot pushed a commit that referenced this pull request Jan 4, 2026
AarDG10 added a commit that referenced this pull request Jan 4, 2026
…-35488

fix(postgres): add pg compatible query for copying comm_date (backport #35488)
@AarDG10 AarDG10 deleted the fix-pg-query-comm-link branch January 5, 2026 13:11
frappe-pr-bot pushed a commit that referenced this pull request Jan 6, 2026
# [15.95.0](v15.94.1...v15.95.0) (2026-01-06)

### Bug Fixes

* add boolean labels for filter display in print/pdf ([35ae63f](35ae63f))
* add compatibility shim for old `frappe.pulse.utils` imports ([82168fd](82168fd))
* check len(item) before replace "\\n" with "\n" (backport [#35571](#35571)) ([#35665](#35665)) ([a9cfae6](a9cfae6))
* correct boolean label handling for filter display ([d366b13](d366b13))
* **data import:** consider fieldname if label is null for col_build ([e2cc64f](e2cc64f))
* description of the permission types ([#35599](#35599)) ([952a61b](952a61b))
* **desk:** guard owner/modified_by access in update_user_info ([#35581](#35581)) ([#35582](#35582)) ([a117b2b](a117b2b)), closes [#35557](#35557)
* Fetch user info for owner, modified_by and versions ([#35557](#35557)) ([#35558](#35558)) ([d5575f0](d5575f0))
* fix merge conflicts ([95ec208](95ec208))
* handle precision correctly when decimal string is empty ([#35526](#35526)) ([218d6d6](218d6d6))
* handle string input for bulk_capture events ([d2b84bf](d2b84bf))
* invalid import ([01c550e](01c550e))
* is_enabled is not updated on system settings change ([7eaa22f](7eaa22f))
* **kanban:** ensure that we don't try to access [0] of an empty list ([#35680](#35680)) ([#35682](#35682)) ([95bcc4a](95bcc4a))
* Log errors for bulk action update ([#35563](#35563)) ([6cf4284](6cf4284))
* **login:** don't let button text stuck at "Verifying" if you get rate limited ([#35671](#35671)) ([#35678](#35678)) ([a24f79b](a24f79b)), closes [#35402](#35402)
* **oauth2:** introspect_token requires `token` ([#35647](#35647)) ([#35668](#35668)) ([d06c428](d06c428))
* **postgres:** add pg compatible query for copying comm_date from comm to comm_link ([#35488](#35488)) ([8cef157](8cef157))
* **postgres:** drop_index_if_exists uses DROP INDEX IF EXISTS ([#35636](#35636)) ([7ba317f](7ba317f))
* preserve old behaviour ([55b5173](55b5173))
* prevent adding of grid rows on tab press when cannot_add_rows is set ([#35570](#35570)) ([a43d3b8](a43d3b8))
* prevent empty filter export in query report ([#35357](#35357)) ([#35403](#35403)) ([10b8222](10b8222))
* Remove DNT based check ([#35588](#35588)) ([#35591](#35591)) ([f94f28a](f94f28a))
* remove filter to maintain previous behaviour ([#35626](#35626)) ([#35629](#35629)) ([3325871](3325871))
* resolve merge conflicts ([#35609](#35609)) ([1fccdbf](1fccdbf))
* **setup_wizard:** don't update all users ([#35679](#35679)) ([#35691](#35691)) ([62d7985](62d7985)), closes [#33360](#33360)
* skip non-html object types (backport [#24524](#24524)) ([#35632](#35632)) ([ed8b735](ed8b735))
* Tree Report buttons state not matching initial_depth ([#34505](#34505)) ([#35435](#35435)) ([587ad14](587ad14))
* update datetime import for timezone compatibility ([cacb9c6](cacb9c6))
* update get_applied_filters to handle boolean labels correctly ([#35614](#35614)) ([cd36d52](cd36d52))
* use reportview get_count for client get_count ([#35657](#35657)) ([#35694](#35694)) ([6cdb7b6](6cdb7b6))

### Features

* add test cases ([6c7d669](6c7d669))
* import custom DocType Links on app install/migrate ([#34516](#34516)) ([#35612](#35612)) ([ab5c05d](ab5c05d))
* override custom report print format from report settings (backport [#35445](#35445)) ([#35603](#35603)) ([a1b01e6](a1b01e6)), closes [#35606](#35606)
* whitelist capture methods for client side events ([30f59b5](30f59b5))

### Performance Improvements

* Reduce memory usage of exif stripping ([#35566](#35566)) ([#35568](#35568)) ([79715a7](79715a7))
""",
frappe.db.multisql(
{
"mariadb": """
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sqlite?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sagarvora for the catch , working on it

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

backport version-15-hotfix Backport the PR to v15 postgres postgres db related issue/PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Latest patch frappe.core.doctype.communication_link.patches.copy_communication_date_to_link incompatible with postgres

7 participants