Skip to content

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

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions