Skip to content

Null equivalence - Empty string default value cleaning#16217

Merged
Weiko merged 2 commits intomainfrom
ej/name-null
Dec 1, 2025
Merged

Null equivalence - Empty string default value cleaning#16217
Weiko merged 2 commits intomainfrom
ej/name-null

Conversation

@etiennejouan
Copy link
Copy Markdown
Contributor

  • on name standard field on custom object (field metadata + db)
  • on text standard fields on standard object (db only)

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Dec 1, 2025

Greptile Overview

Greptile Summary

This PR removes empty string default values for text fields and replaces them with null, aligning with the "null equivalence" feature that's now enabled by default (per commit 638d401).

  • Changed the name standard field on custom objects from isNullable: false, defaultValue: "''" to isNullable: true, defaultValue: null
  • Removed the empty string default value option { defaultValue: "''" } for TEXT field types in the workspace migration factory

This change is consistent with the broader null equivalence initiative where empty strings ('') and null are treated as equivalent. The codebase already has infrastructure to handle this via isNullEquivalentTextFieldValue() and the IS_NULL_EQUIVALENCE_ENABLED feature flag, which is now in the default feature flags list.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are part of a well-established null equivalence initiative with supporting infrastructure already in place. The feature flag is enabled by default, migration commands exist to handle the transition, and the changes are limited in scope to metadata and migration factory configurations.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
packages/twenty-server/src/engine/metadata-modules/object-metadata/utils/build-default-flat-field-metadatas-for-custom-object.util.ts 5/5 Changed name field default from empty string to null and made it nullable - aligns with null equivalence feature flag that's now enabled by default
packages/twenty-server/src/engine/metadata-modules/workspace-migration/workspace-migration.factory.ts 5/5 Removed empty string default value for TEXT fields in database migrations - consistent with null equivalence approach

Sequence Diagram

sequenceDiagram
    participant Client as Client/API Request
    participant Factory as WorkspaceMigrationFactory
    participant Builder as buildDefaultFlatFieldMetadatas
    participant DB as Database
    participant Transformer as transformTextField

    Note over Client,Transformer: Null Equivalence Flow

    alt Creating Custom Object
        Client->>Builder: Create custom object
        Builder->>Builder: Set name field with isNullable: true, defaultValue: null
        Builder->>DB: Store field metadata
    end

    alt Creating TEXT Field Migration
        Client->>Factory: Create TEXT field
        Factory->>Factory: Use basicColumnActionFactory (no default value options)
        Factory->>DB: Create column without default value
    end

    alt Inserting/Updating Records
        Client->>Transformer: Send text field value ('' or null)
        Transformer->>Transformer: isNullEquivalentTextFieldValue() checks
        alt Empty string with feature flag enabled
            Transformer->>Transformer: Convert '' to null
        end
        Transformer->>DB: Store as NULL in database
    end
Loading

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 1, 2025

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:19929

This environment will automatically shut down when the PR is closed or after 5 hours.

Copy link
Copy Markdown
Member

@Weiko Weiko left a comment

Choose a reason for hiding this comment

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

LGTM!

applicationId: applicationId ?? null,
};

const nameFieldId = v4();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good catch!

@Weiko Weiko merged commit 5e00893 into main Dec 1, 2025
64 checks passed
@Weiko Weiko deleted the ej/name-null branch December 1, 2025 16:10
@twenty-eng-sync
Copy link
Copy Markdown

Hey @etiennejouan! After you've done the QA of your Pull Request, you can mark it as done here. Thank you!

etiennejouan added a commit that referenced this pull request Dec 1, 2025
- on name standard field on custom object (field metadata + db)
- on text standard fields on standard object (db only)
charlesBochet pushed a commit that referenced this pull request Dec 2, 2025
Because of [this code I forget to
clean](#16217),
- __workspace created between 1.12.0 and 1.12.2 (from friday 28 nov PM >
monday 1 dec PM)__ have standard objects with empty string default value
set on related TEXT type column (but default value null on field
metadata) (ex: jobTitle on person)
- __custom objects created between 1.12.0 and 1.12.2 (from friday 28 nov
PM > monday 1 dec PM)__ have "name" TEXT field with empty string default
value set + NOT NULL constraint on column

Command cleans data and updates table structure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants