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

Check Select FieldType behavior when not nullable #6003

Open
charlesBochet opened this issue Jun 24, 2024 · 2 comments
Open

Check Select FieldType behavior when not nullable #6003

charlesBochet opened this issue Jun 24, 2024 · 2 comments

Comments

@charlesBochet
Copy link
Member

Scope & Context

I have noticed that we don't handle well select options enums update. When a select is non nullable (in fieldMetadata), this leads to an issue where the defaultValue is not properly set.

Check that the Settings > Field Edit behavior is working with all use cases (remove, add, update options x remove, add defaultValue).
Also check that the health check is complaining about defaultValue NULL + isNullable false

@ijreilly FYI

Copy link

greptile-apps bot commented Jun 24, 2024

Steps to Resolve

  1. Locate Field Metadata Handling: Check fieldMetadata handling in src/settings/FieldEdit.js.

  2. Update Default Value Logic: Ensure default values are set correctly when isNullable is false. Modify the logic in src/settings/FieldEdit.js around line where defaultValue is assigned.

    if (!fieldMetadata.isNullable && !fieldMetadata.defaultValue) {
        fieldMetadata.defaultValue = fieldMetadata.options[0]; // or appropriate default
    }
  3. Health Check: Verify health check logic in src/health/FieldHealthCheck.js to ensure it flags defaultValue as NULL when isNullable is false.

    if (!fieldMetadata.isNullable && fieldMetadata.defaultValue === null) {
        // Add health check warning or error
    }
  4. Test Cases: Add test cases for removing, adding, and updating options and default values in src/tests/FieldEdit.test.js.

    test('should handle non-nullable select field default value', () => {
        // Add test implementation
    });

References

@charlesBochet
Copy link
Member Author

charlesBochet commented Jun 24, 2024

Made a small change here: #6004

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🆕 New
Development

No branches or pull requests

1 participant