mongodb-odm
mongodb-odm copied to clipboard
Embedded document index with partialFilterExpression is wrong
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"
}
}
)
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in a week if no further activity occurs. Thank you for your contributions.
Given partial indexes were introduced in 1.1 (#1303) this needs to be fixed in 1.3.x branch and then merged up. Gonna schedule it so the report won't fall through the cracks