Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2dsphere indexes get re-created everytime #2574

Closed
buffcode opened this issue Nov 6, 2023 · 1 comment · Fixed by #2575
Closed

2dsphere indexes get re-created everytime #2574

buffcode opened this issue Nov 6, 2023 · 1 comment · Fixed by #2575
Labels
Milestone

Comments

@buffcode
Copy link
Contributor

buffcode commented Nov 6, 2023

Bug Report

Q A
BC Break no
Version 2.5.x

Summary

Indexes of type 2dsphere are always re-created.

Current behavior

Because the server-side options contain a 2dsphereIndexVersion a mismatch is caused when comparing index options.

How to reproduce

/**
 * @ODM\Document
 * @ODM\Index(keys={"coordinatesWith2DIndex"="2d"})
 * @ODM\Index(keys={"coordinatesWithSphereIndex"="2dsphere"})
 */
class GeoIndexDocument
{
    /**
     * @ODM\Id
     *
     * @var string|null
     */
    public $id;

    /** @ODM\Field(type="hash") */
    public $coordinatesWith2DIndex;

    /** @ODM\Field(type="hash") */
    public $coordinatesWithSphereIndex;
}

For debugging purposes add the following code to \Doctrine\ODM\MongoDB\SchemaManager::updateDocumentIndexes, right before $collection->dropIndex(...):

dump('Dropping index ' . $mongoIndex['name'] . ' on ' . $documentName);

Run:

$ bin/console doctrine:mongodb:schema:update
Dropping index coordinates_2dsphere on GeoIndexDocument
Updated indexes for all classes
Updated validation for all classes

Expected behavior

Do not drop/re-create 2dsphere indexes

@alcaeus alcaeus added the Bug label Nov 6, 2023
@alcaeus alcaeus added this to the 2.5.5 milestone Nov 6, 2023
@alcaeus alcaeus linked a pull request Nov 6, 2023 that will close this issue
@alcaeus
Copy link
Member

alcaeus commented Nov 6, 2023

Fixed in #2575.

@alcaeus alcaeus closed this as completed Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants