Skip to content

make:entity platform-specific types, especially jsonb objects #1387

Open
@tacman

Description

@tacman

I'm pleased to see that postgres is the default database for the recipe when installing doctrine-bundle.

JSONB has been available since postgres 9.4, released in 2014. It's hard to imagine why someone would want a larger, slower JSON column. I'd like to propose that when make:entity make it easier (or make it the default) to create JSONB columns.

The easiest way, I think, is when the type is json to always add the

#[ORM\Column(options: ["jsonb" => true])]
private ?array $data = null;

It appears to not have any effect on databases that don't support it, at least SQLite. I'm not sure how MySQL handles it.

Alternatively, the maker could detect the postgres platform and prompt for jsonb.

On a related note, why is the PHP type an array rather than an object? Or both/either? Again, make:entity could add an additional type, json-object, and keep json as an array.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions