Skip to content

Conversation

HeshamaMohamed
Copy link

@HeshamaMohamed HeshamaMohamed commented May 31, 2025

Checklist:

  • I have updated the necessary documentation
  • I have signed off all my commits as required by DCO
  • My build is green

TODO:

  • Add warnings if you're passing an array (or loaded query) instead of a relation to a blueprint that has fields with custom select options to indicate that it's not working as expected.
  • Make sure that ColumnSelector works with Preloader use: :includes, when the includes makes a JOIN instead of separate queries.

Next iteration

  • Make it auto-select association columns as well not just the relation's main model columns.

Signed-off-by: Hesham Mohamed <[email protected]>
@HeshamaMohamed HeshamaMohamed force-pushed the heshamaly/add_column_selector_extension branch 2 times, most recently from 5ebff42 to dd2b459 Compare May 31, 2025 14:13
@HeshamaMohamed HeshamaMohamed force-pushed the heshamaly/add_column_selector_extension branch from 6b97423 to 7da75b1 Compare June 1, 2025 04:58
Copy link

github-actions bot commented Jul 2, 2025

This PR is stale because it has been open for 30 days with no activity and will be closed in 14 days unless you add a comment.

@jhollinger
Copy link
Contributor

Planning to review thoroughly soon

@jhollinger jhollinger added the enhancement New feature or request label Jul 8, 2025
@jhollinger jhollinger self-assigned this Jul 8, 2025
Copy link
Contributor

@jhollinger jhollinger left a comment

Choose a reason for hiding this comment

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

At first glance I think this looks promising - just a few minor comments/changes. I'll continue to study & review it. Thanks again!

@values[:preload_blueprint_method]
end

def select_blueprint_columns_method
Copy link
Contributor

Choose a reason for hiding this comment

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

The _method suffix doesn't make sense IMO, since we're just storing a boolean. Maybe something like select_blueprint_columns?.

@values[:before_preload_blueprint] = val
end

# Get the selects present before the ColumnSelector extension ran (internal, for logging)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can get rid of these two methods, unless you're planning to add an optional, no-op logging extension like the Preloader has.

# @param model [Class|:polymorphic] The ActiveRecord model class that blueprint represents
# @return [Array<String>] Array of column names to select
#
def self.columns(blueprint, view_name, model:)
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to break this method into some smaller ones.

elsif ref.through_reflection
# For has_many/one through belongs_to associations, we need the foreign key of the intermediate association
# Example: has_many :customer_projects, through: :customer
# We need the customer_id foreign key
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this handle multiple levels of "through" associations?

end
end
end
# Databases often cache query plans. Consistent column order means:
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link

github-actions bot commented Aug 8, 2025

This PR is stale because it has been open for 30 days with no activity and will be closed in 14 days unless you add a comment.

Copy link

This PR was closed because it has been stalled for 14 days with no activity.

Copy link

This PR is stale because it has been open for 30 days with no activity and will be closed in 14 days unless you add a comment.

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

Labels

enhancement New feature or request no-pr-activity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants