jsor / doctrine-postgis

Spatial and Geographic Data with PostGIS and Doctrine.
MIT License
209 stars 50 forks source link

Index not created as type spatial when using XML-config #29

Closed swen100 closed 7 years ago

swen100 commented 7 years ago

Hi,

I am using Symfony v3.3.0 and doctrine v2.5.5 As described here https://github.com/jsor/doctrine-postgis#spatial-indexes my doctrine-config is the following:

<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
                                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                     xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
                   https://raw.github.com/doctrine/doctrine2/master/doctrine-mapping.xsd">

<entity name="Dummy\Module\GeoBundle\Entity\Geo" table="geo"
        repository-class="Dummy\Module\GeoBundle\Entity\Repository\GeoRepository">
    <field name="title" type="string" nullable="true"/>
    <field name="geometry" type="geometry" nullable="false"/>
    <indexes>
        <index name="geometry_IDX" columns="geometry" flags="spatial"/>
    </indexes>
</entity>
</doctrine-mapping>

So, I have set the flag with flags="spatial", but with the console I only get a "normal" index:

php bin\console doctrine:schema:update --dump-sql

gives: CREATE INDEX geometry_IDX ON geo (geometry);

jsor commented 7 years ago

I can't reproduce this. Could you give a little bit more information about the setup, ideally a minimal reproducible test case?

swen100 commented 7 years ago

Hi,

my entity has two attributes: title and a geometry. As described in your documentation, I just set the "spatial" flag to create a spatial index on the geometry column "geometry". But I am using xml instead of annotation or yaml.

This is what is on the documentation site:

/**
 * @Entity
 * @Table(
 *     indexes={
 *         @Index(name="idx_point", columns={"point"}, flags={"spatial"})),
 *         @Index(name="idx_polygon", columns={"polygon"}, flags={"spatial"}))
 *     }
 * )
 */
class MyEntity
{
}

Everything works fine until creation of spatial index.

php bin/console doctrine:schema:create

-> table is created, but if I add the "spatial"-flag and then call

php bin\console doctrine:schema:update --dump-sql

I get CREATE INDEX geometry_IDX ON geo (geometry);

But it should be: CREATE INDEX geometry_IDX ON geo USING gist(geometry);

jsor commented 7 years ago

Yes, that's what i tested (with XML mapping instead of annotations) and it worked correctly for me. That's why i asked for a reduced test case which reproduces the behaviour because i've been not able to reproduce it.

swen100 commented 7 years ago

Hm, I tried it out again and it works now. I don't know what I did wrong nor what I had changed meanwhile to get it work. Anyway, this issue can be closed. I'm sorry for the inconvenience.