Skip to content

Embedded document index with partialFilterExpression is wrong #2214

Open
@Steveb-p

Description

@Steveb-p

Bug Report

Q A
BC Break no
Version 2.1.2

Summary

Embedded documents when creating indexes receive them with wrong partialFilterExpression, as if they were not embedded.

Current behavior

For a document class:

/**
 * @ODM\EmbeddedDocument(indexes={
 *      @ODM\Index(
 *          background=true,
 *          name="statistic_aggregate_transaction_state_idx",
 *          keys={
 *              "last_changed"="asc",
 *              "transaction_state"="asc",
 *          },
 *          partialFilterExpression={
 *              "transaction_state"=StatisticAggregateState::TRANSACTION_STATE_CHANGESET_NEW,
 *          },
 *      ),
 * })
 */
class StatisticAggregateState
{
    private const TRANSACTION_STATE_CHANGESET_APPLIED = 'applied';
    public const TRANSACTION_STATE_CHANGESET_NEW = 'new';
    ...
}

...creates an index with following specification:

db.collection.createIndex(
    {
        "statistic_aggregate_states.transaction_state": 1,
        "statistic_aggregate_states.last_changed": 1
    },
    {
        name: "statistic_aggregate_states_statistic_aggregate_transaction_state_idx",
        background: true,
        partialFilterExpression: {
            transaction_state: "new"
        }
    }
)

Expected behavior

Created index should actually be:

db.collection.createIndex(
    {
        "statistic_aggregate_states.transaction_state": 1,
        "statistic_aggregate_states.last_changed": 1
    },
    {
        name: "statistic_aggregate_states_statistic_aggregate_transaction_state_idx",
        background: true,
        partialFilterExpression: {
            "statistic_aggregate_states.transaction_state": "new"
        }
    }
)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions