Skip to content

Add Index on a query using JSON_GET or other methods #92

@alexander-schranz

Description

@alexander-schranz

More a question. I want to add a index on a specific JSON query I know its possible via PostgreSQL the query looks like this:

$queryBuilder->leftJoin(
    Contact::class,
    'contact',
    Join::WITH,
    'CAST(JSON_GET(JSON_GET(visit.data, \'code\'), \'contactId\') AS INT) = contact.id',
)

It is a third party entity and I wanted to use Events::loadClassMetadata to add a index but the following:

$builder = new ClassMetadataBuilder($metadata);
$builder->addIndex(['CAST(JSON_GET(JSON_GET(visit.data, \'code\'), \'contactId\') AS INT)'], 'data_code_contactId_idx');

because it is not a column maybe somebody achieved something like this, without that the ORM is throwing the index away on the next migration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions