Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat (dashboard): support empty string as default text value in database tables#3112

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
dbm03 wants to merge6 commits intomain
base:main
Choose a base branch
Loading
fromfeat/add-empty-string-default

Conversation

dbm03
Copy link
Member

@dbm03dbm03 commentedJan 1, 2025
edited by github-actionsbot
Loading

User description

Resolves#2925


PR Type

Enhancement


Description

  • Add empty string default for text fields

  • Update UI to support new default value

  • Modify form handling for empty string defaults

  • Adjust column classification in record forms


Changes walkthrough 📝

Relevant files
Enhancement
BaseRecordForm.tsx
Update form handling for empty string defaults                     

dashboard/src/features/orgs/projects/database/dataGrid/components/BaseRecordForm/BaseRecordForm.tsx

  • Updated column classification logic
  • Modified insertable values handling
  • Changed description for optional columns
  • +11/-3   
    ColumnEditorRow.tsx
    Enhance DefaultValueAutocomplete for empty string               

    dashboard/src/features/orgs/projects/database/dataGrid/components/BaseTableForm/ColumnEditorRow.tsx

  • Added formatting for empty string default value
  • Updated DefaultValueAutocomplete component
  • +9/-2     
    DatabaseRecordInputGroup.tsx
    Update DatabaseRecordInputGroup for empty defaults             

    dashboard/src/features/orgs/projects/database/dataGrid/components/DatabaseRecordInputGroup/DatabaseRecordInputGroup.tsx

  • Updated getPlaceholder function for empty string
  • Modified DatabaseRecordInputGroup component
  • +7/-0     
    postgresqlConstants.ts
    Add empty string default to PostgreSQL functions                 

    dashboard/src/features/orgs/projects/database/dataGrid/utils/postgresqlConstants/postgresqlConstants.ts

    • Added ''::text to postgresFunctions for text type
    +1/-1     
    Documentation
    dry-kids-chew.md
    Add changeset for empty string default feature                     

    .changeset/dry-kids-chew.md

    • Added changeset for new feature
    +5/-0     

    💡PR-Agent usage: Comment/help "your question" on any pull request to receive relevant information

    @dbm03dbm03 requested a review fromdbarrosopJanuary 1, 2025 16:50
    @dbm03dbm03 self-assigned thisJan 1, 2025
    @changeset-botchangeset-bot
    Copy link

    changeset-botbot commentedJan 1, 2025
    edited
    Loading

    🦋 Changeset detected

    Latest commit:f539713

    The changes in this PR will be included in the next version bump.

    This PR includes changesets to release 1 package
    NameType
    @nhost/dashboardMinor

    Not sure what this means?Click here to learn what changesets are.

    Click here if you're a maintainer who wants to add another changeset to this PR

    @vercelVercel
    Copy link

    vercelbot commentedJan 1, 2025
    edited
    Loading

    The latest updates on your projects. Learn more aboutVercel for Git ↗︎

    NameStatusPreviewUpdated (UTC)
    dashboard-staging✅ Ready (Inspect)Visit PreviewMar 17, 2025 10:55am
    example-nextjs-server-components✅ Ready (Inspect)Visit PreviewMar 17, 2025 10:55am
    example-react-apollo✅ Ready (Inspect)Visit PreviewMar 17, 2025 10:55am
    example-sveltekit✅ Ready (Inspect)Visit PreviewMar 17, 2025 10:55am
    example-vue-apollo✅ Ready (Inspect)Visit PreviewMar 17, 2025 10:55am
    1 Skipped Deployment
    NameStatusPreviewUpdated (UTC)
    dashboard⬜️ Ignored (Inspect)Visit PreviewMar 17, 2025 10:55am

    @github-actionsGitHub Actions
    Copy link
    Contributor

    github-actionsbot commentedJan 1, 2025
    edited
    Loading

    PR Reviewer Guide 🔍

    (Review updated until commit4f00d97)

    Here are some key observations to aid the review process:

    🎫 Ticket compliance analysis ✅

    2925 - Fully compliant

    Fully compliant requirements:

    • Add option ''::text for Text default values
    • Include ''::text as a default option for Text fields in the dropdown
    • Allow non-nullable Text fields to have empty string as the default value
    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Logic Complexity

    The changes in the condition for determining required columns and handling default values have increased the complexity of the code. This should be carefully reviewed to ensure it correctly handles all edge cases.

    if(column.isPrimary||(!column.isNullable&&!column.defaultValue&&!column.isDefaultValueCustom&&!column.isIdentity)
    UI Behavior

    The new handling of empty string default values in the UI should be thoroughly tested to ensure it correctly displays and processes these values in all scenarios.

    constformattedInputValue=useMemo(()=>{if(defaultValue?.value===''){return"''::text";}returnisIdentity ?'' :inputValue;},[isIdentity,defaultValue?.value,inputValue]);

    @github-actionsGitHub Actions
    Copy link
    Contributor

    github-actionsbot commentedJan 1, 2025
    edited
    Loading

    PR Code Suggestions ✨

    Latest suggestions up to4f00d97
    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                   Score
    General
    Extract complex condition into a separate function to improve code readability and maintainability

    Consider simplifying the condition for required columns by extracting it into a
    separate function. This will improve readability and make the code easier to
    maintain.

    dashboard/src/features/orgs/projects/database/dataGrid/components/BaseRecordForm/BaseRecordForm.tsx [45-51]

    -if (-  column.isPrimary ||-  (!column.isNullable &&-    !column.defaultValue &&-    !column.isDefaultValueCustom &&-    !column.isIdentity)-) {+const isRequiredColumn = (column) =>+  column.isPrimary ||+  (!column.isNullable && !column.defaultValue && !column.isDefaultValueCustom && !column.isIdentity);+if (isRequiredColumn(column)) {+
    Suggestion importance[1-10]: 6

    Why: The suggestion improves code readability and maintainability by extracting a complex condition into a separate function. This change makes the code easier to understand and modify in the future.

    6
    Extract complex condition into a separate function to enhance code clarity and testability

    The condition for checking if a value should be included in insertableValues is
    complex and may be prone to errors. Consider extracting this logic into a separate
    function to improve readability and testability.

    dashboard/src/features/orgs/projects/database/dataGrid/components/BaseRecordForm/BaseRecordForm.tsx [102-107]

    -if (-  !value &&-  (gridColumn?.defaultValue ||-    gridColumn?.defaultValue === '' ||-    gridColumn?.isIdentity)-) {+const shouldUseDefaultValue = (value, gridColumn) =>+  !value && (gridColumn?.defaultValue !== undefined || gridColumn?.isIdentity);+if (shouldUseDefaultValue(value, gridColumn)) {+
    Suggestion importance[1-10]: 6

    Why: The suggestion enhances code clarity and testability by extracting a complex condition into a separate function. This improves readability and makes the logic easier to test independently.

    6

    Previous suggestions

    Suggestions up to commit021bc2f
    CategorySuggestion                                                                                                                                   Score
    General
    Simplify the condition for checking default values and identity columns using modern JavaScript features

    Use optional chaining and nullish coalescing operators to simplify the condition for
    checking default values and identity columns. This will make the code more concise
    and easier to understand.

    dashboard/src/features/orgs/projects/database/dataGrid/components/BaseRecordForm/BaseRecordForm.tsx [102-107]

    -if (-  !value &&-  (gridColumn?.defaultValue ||-    gridColumn?.defaultValue === '' ||-    gridColumn?.isIdentity)-) {+if (!value && (gridColumn?.defaultValue !== undefined || gridColumn?.isIdentity)) {
    Suggestion importance[1-10]: 8

    Why: This suggestion effectively simplifies the condition using optional chaining and nullish coalescing, which aligns well with the PR's intent to handle empty string default values. It improves code readability and maintainability.

    8
    Simplify the condition for determining required columns to improve readability and reduce potential errors

    Simplify the condition for determining required columns by using the logical OR
    operator (||) instead of multiple AND (&&) operators. This will make the code more
    readable and less prone to errors.

    dashboard/src/features/orgs/projects/database/dataGrid/components/BaseRecordForm/BaseRecordForm.tsx [45-51]

     if (   column.isPrimary ||   (!column.isNullable &&-    !column.defaultValue &&-    column.defaultValue !== '' &&+    (column.defaultValue === null || column.defaultValue === undefined) &&     !column.isIdentity) ) {
    Suggestion importance[1-10]: 7

    Why: The suggestion simplifies the complex condition, making it more readable and less error-prone. It correctly addresses the logic for determining required columns, which is a key part of the PR changes.

    7
    Improve readability of string formatting using template literals

    Use a template literal for the formatted input value to improve readability and
    maintainability. This will make it easier to understand the logic for displaying
    empty string values.

    dashboard/src/features/orgs/projects/database/dataGrid/components/BaseTableForm/ColumnEditorRow.tsx [154-159]

     const formattedInputValue = useMemo(() => {   if (defaultValue?.value === '') {-    return "''::text";+    return `''::text`;   }   return isIdentity ? '' : inputValue; }, [isIdentity, defaultValue?.value, inputValue]);
    Suggestion importance[1-10]: 3

    Why: While the suggestion to use template literals is valid, it offers only a minor improvement in readability. The existing code is already functional and clear, so the impact of this change is relatively low.

    3

    @dbarrosop
    Copy link
    Member

    dbarrosop commentedJan 2, 2025
    edited
    Loading

    I think there is a bug:

    Screenshot 2025-01-02 at 09 25 47

    The automatically generated value thing shows for the wrong types and when there is no actual default value.

    @dbm03dbm03 marked this pull request as draftJanuary 2, 2025 10:57
    @dbm03dbm03force-pushed thefeat/add-empty-string-default branch 2 times, most recently fromdf1332d to4f00d97CompareJanuary 17, 2025 19:59
    @dbm03dbm03 marked this pull request as ready for reviewJanuary 17, 2025 19:59
    @github-actionsGitHub Actions
    Copy link
    Contributor

    Persistent review updated to latest commit4f00d97

    @dbm03dbm03 marked this pull request as draftJanuary 21, 2025 13:55
    @dbm03dbm03force-pushed thefeat/add-empty-string-default branch from87daf1a toe3c41cdCompareJanuary 29, 2025 23:35
    Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
    Reviewers

    @dbarrosopdbarrosopAwaiting requested review from dbarrosop

    @nunopatonunopatoAwaiting requested review from nunopatonunopato is a code owner

    @onehassanonehassanAwaiting requested review from onehassan

    At least 1 approving review is required to merge this pull request.

    Assignees

    @dbm03dbm03

    Labels
    Projects
    None yet
    Milestone
    No milestone
    Development

    Successfully merging this pull request may close these issues.

    Add option ''::text for Text default values
    3 participants
    @dbm03@dbarrosop@nhost-build

    [8]ページ先頭

    ©2009-2025 Movatter.jp