From 7cd7438eb7c3749b856711f52369da55205de884 Mon Sep 17 00:00:00 2001 From: sneha122 Date: Tue, 13 May 2025 09:48:31 +0530 Subject: [PATCH] feat: execute on load backwards compatibility backend changes (#40644) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description This PR provides backward compatibility for older actions which do not have runBehaviour property in the DB. When such actions have been configured to be run on page load explicitly, they will get executed as other actions which get set to be run on page load when binding happens. ### Steps to reproduce: - Create app on production ([app.appsmith.com](http://app.appsmith.com/)) - Create mock db users datasource - Create 3 queries, Q1, Q2 and Q3 - Attach Q1 to table so it runs on page load - Change executeOnLoad setting of Q3 to page load - Export this app - Import this on our DP - Observe that Q3 does not run on page load Fixes #40633 _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.Datasource, @tag.Sanity" ### :mag: Cypress test results > [!TIP] > ๐ŸŸข ๐ŸŸข ๐ŸŸข All cypress tests have passed! ๐ŸŽ‰ ๐ŸŽ‰ ๐ŸŽ‰ > Workflow run: > Commit: 5009eb44ac2c1a713f3a604dddf3545c898208e1 > Cypress dashboard. > Tags: `@tag.Datasource, @tag.Sanity` > Spec: >
Tue, 13 May 2025 03:57:32 UTC ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No --------- Co-authored-by: โ€œsneha122โ€ <โ€œsneha@appsmith.comโ€> --- .../com/appsmith/server/domains/ce/NewActionCE.java | 2 ++ .../ce/CustomNewActionRepositoryCEImpl.java | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ce/NewActionCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ce/NewActionCE.java index 9d41434472..28f0e630fb 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ce/NewActionCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ce/NewActionCE.java @@ -73,6 +73,8 @@ public class NewActionCE extends RefAwareDomain { dotted(unpublishedAction, ActionDTO.Fields.userSetOnLoad); public static final String unpublishedAction_runBehaviour = dotted(unpublishedAction, ActionDTO.Fields.runBehaviour); + public static final String unpublishedAction_executeOnLoad = + dotted(unpublishedAction, ActionDTO.Fields.executeOnLoad); public static final String unpublishedAction_fullyQualifiedName = dotted(unpublishedAction, ActionDTO.Fields.fullyQualifiedName); public static final String unpublishedAction_actionConfiguration_httpMethod = diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewActionRepositoryCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewActionRepositoryCEImpl.java index d5690373e4..124767a758 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewActionRepositoryCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewActionRepositoryCEImpl.java @@ -181,12 +181,14 @@ public class CustomNewActionRepositoryCEImpl extends BaseAppsmithRepositoryImpl< @Override public Flux findUnpublishedActionsByPageIdAndRunbehaviourSetByUserOnPageLoad( String pageId, AclPermission permission) { - BridgeQuery q = Bridge.equal( - NewAction.Fields.unpublishedAction_runBehaviour, RunBehaviourEnum.ON_PAGE_LOAD) + BridgeQuery q = Bridge.or( + // First condition: new runBehaviour = ON_PAGE_LOAD + Bridge.equal( + NewAction.Fields.unpublishedAction_runBehaviour, RunBehaviourEnum.ON_PAGE_LOAD), + // Second condition: legacy executeOnLoad = true + Bridge.isTrue(NewAction.Fields.unpublishedAction_executeOnLoad)) .isTrue(NewAction.Fields.unpublishedAction_userSetOnLoad) .equal(NewAction.Fields.unpublishedAction_pageId, pageId) - // In case an action has been deleted in edit mode, but still exists in deployed mode, NewAction object - // would exist. To handle this, only fetch non-deleted actions .isNull(NewAction.Fields.unpublishedAction_deletedAt); return queryBuilder().criteria(q).permission(permission).all();