Skip to content

DibiLiteral annotation combined with string #87

@srigi

Description

@srigi

I use PostgreSQL and UUID datatype.
To generate proper UUID you need to set annotation to

@property DibiLiteral $uuid

so resulting SQL looks like this:

INSERT INTO
  "public"."user"
  (uuid, email)
VALUES
  (uuid_generate_v4(), '[email protected]')

If I instead use string as datatype of property, INSERT fails cos uuid_generate_v4 function is wrapped in quotes in resulting SQL.

Problem with DibiLiteral annotation is when accessing $entity->uuid. Since property is annotated as DibiLiteral and DB in fact returns string, LeanMapper throws exeption. So I tried to use this form for annotation

@property string|DibiLiteral $uuid

This crashed EntityReflection at this exact point cos regex didn't matches anything.

Can you suggest any idea how to solve this. I don't want to give up on using Postgre's UUIDs.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions