Repository navigation
fix(agent): keep the search and segments of a select-all in delete, actions and dissociate [PRD-1667] #414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2fbea6c
5640593
b9b6b40
76957e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,30 +23,55 @@ def execute_query(datasource, query, connection_name, permissions, caller, conte | |
| end | ||
|
|
||
| def parse_query_segment(collection, args, permissions, caller) | ||
| return unless args[:params][:segmentQuery] | ||
| segment_query = QueryStringParser.subset_or_query(args, :segmentQuery) | ||
| return unless segment_query | ||
|
|
||
| unless args[:params][:connectionName] | ||
| connection_name = QueryStringParser.subset_or_query(args, :connectionName) | ||
| unless connection_name | ||
| raise ForestAdminAgent::Http::Exceptions::UnprocessableError, 'Missing native query connection attribute' | ||
| end | ||
|
|
||
| QueryValidator.valid?(args[:params][:segmentQuery]) | ||
| QueryValidator.valid?(segment_query) | ||
|
|
||
| permissions.can_execute_query_segment?(collection, args[:params][:segmentQuery], args[:params][:connectionName]) | ||
| permissions.can_execute_query_segment?(collection, segment_query, connection_name) | ||
|
|
||
| ids = execute_query( | ||
| collection.datasource, | ||
| args[:params][:segmentQuery], | ||
| args[:params][:connectionName], | ||
| segment_query, | ||
| connection_name, | ||
| permissions, | ||
| caller, | ||
| args[:params][:contextVariables] | ||
| QueryStringParser.subset_or_query(args, :contextVariables) | ||
| ).map(&:values) | ||
|
|
||
| condition_tree_segment = ConditionTree::ConditionTreeFactory.match_ids(collection, ids) | ||
| ConditionTreeValidator.validate(condition_tree_segment, collection) | ||
|
|
||
| condition_tree_segment | ||
| end | ||
|
|
||
| def build_context_filter(collection, args, permissions, caller, sort: nil) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| condition_tree = QueryStringParser.parse_condition_tree(collection, args) | ||
| search = QueryStringParser.parse_search(collection, args) | ||
| search_extended = QueryStringParser.parse_search_extended(args) | ||
| applied = { condition_tree: condition_tree, search: search, search_extended: search_extended } | ||
| applied[:sort] = sort if sort | ||
| permissions.assert_can_read_query_fields(collection, **applied) | ||
|
|
||
| Filter.new( | ||
| condition_tree: ConditionTree::ConditionTreeFactory.intersect( | ||
| [ | ||
| permissions.get_scope(collection), | ||
| condition_tree, | ||
| parse_query_segment(collection, args, permissions, caller) | ||
| ] | ||
| ), | ||
| search: search, | ||
| search_extended: search_extended, | ||
| sort: sort, | ||
| segment: QueryStringParser.parse_segment(collection, args) | ||
| ) | ||
| end | ||
| end | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ class DissociateRelated < AbstractRelatedRoute | |
| include ForestAdminAgent::Builder | ||
| include ForestAdminDatasourceToolkit::Utils | ||
| include ForestAdminDatasourceToolkit::Components::Query | ||
| include ForestAdminAgent::Routes::QueryHandler | ||
|
|
||
| def setup_routes | ||
| add_route( | ||
|
|
@@ -126,14 +127,9 @@ def get_base_foreign_filter(args, context) | |
| raise ForestAdminDatasourceToolkit::Exceptions::ForestException, 'Expected no empty id list' | ||
| end | ||
|
|
||
| Filter.new( | ||
| condition_tree: ConditionTree::ConditionTreeFactory.intersect( | ||
| [ | ||
| context.permissions.get_scope(context.child_collection), | ||
| Utils::QueryStringParser.parse_condition_tree(context.child_collection, args), | ||
| selected_ids | ||
| ] | ||
| ) | ||
| filter = build_context_filter(context.child_collection, args, context.permissions, context.caller) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Claude Opus 5.5 (claude-opus-5-5), from manual testing at
Before this PR the same action deleted all 3, since the related list and the delete both ignored the search. Now the delete honours it through A way out: build those three filters with
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Claude Opus 5.5 (claude-opus-5-5): Related list, count and csv now build their filter through build_context_filter, so they show and count what a select-all delete reaches. WhyEach route has a spec where a search and a segment reach the related filter. |
||
| filter.override( | ||
| condition_tree: ConditionTree::ConditionTreeFactory.intersect([filter.condition_tree, selected_ids]) | ||
| ) | ||
| end | ||
| end | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.