Skip to content
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

Bug/53706 reordering project attributes is popping back on render #15166

Merged

Conversation

jjabari-op
Copy link
Collaborator

@jjabari-op jjabari-op requested a review from dombesz April 4, 2024 12:23
@jjabari-op jjabari-op self-assigned this Apr 4, 2024
@jjabari-op
Copy link
Collaborator Author

@dombesz do you have an idea why the CI build step fails?

Copy link
Contributor

@dombesz dombesz left a comment

Choose a reason for hiding this comment

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

LGMT 👍

@dombesz
Copy link
Contributor

dombesz commented Apr 4, 2024

@dombesz do you have an idea why the CI build step fails?

@jjabari-op according to the logs, the field position_in_custom_field_section does not exist when the migration CreateProjectCustomFieldProjectMappings is ran:

PG::UndefinedColumn: ERROR:  column "position_in_custom_field_section" does not exist
LINE 1: ...ields" WHERE "custom_fields"."type" = $1 ORDER BY "position_...
                                                             ^
/app/db/migrate/20231031133334_create_project_custom_field_project_mappings.rb:23:in `create_default_mapping'
/app/db/migrate/20231031133334_create_project_custom_field_project_mappings.rb:12:in `up'

This happens, because calling the ProjectCustomField in the line 20231031133334_create_project_custom_field_project_mappings.rb:23: will trigger the default scope, but the position_in_custom_field_section does not exist yet, because it is added in a latter migration. /app/db/migrate/20231123111357_create_custom_field_sections.rb

Usually the issue is solved by defining a custom class for the table inside the migration. I provided a fix for it 1adf080

@dombesz
Copy link
Contributor

dombesz commented Apr 4, 2024

@jonasjabari Seems like the default scope ordering on the ProjectCustomField class is causing issues on merged queries. I would suggest adding the default order on the ProjectCustomFieldSection#custom_fields relation instead. I provided a commit for my suggestion.

@dombesz dombesz marked this pull request as ready for review April 4, 2024 14:17
@dombesz dombesz merged commit 1a45a2b into dev Apr 4, 2024
9 checks passed
@dombesz dombesz deleted the bug/53706-reordering-project-attributes-is-popping-back-on-render branch April 4, 2024 14:17
@jjabari-op
Copy link
Collaborator Author

Thank you @dombesz

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

Successfully merging this pull request may close these issues.

2 participants