Code

Opened 13 months ago

Closed 13 months ago

Last modified 12 months ago

#20656 closed Uncategorized (needsinfo)

test db spatial extentsion not created when using new postgis 2.0 "CREATE EXTENSION postgis;" method

Reported by: monkut Owned by: nobody
Component: Uncategorized Version: 1.5
Severity: Normal Keywords:
Cc: flavio.curella@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Following the directions here:

https://docs.djangoproject.com/en/dev/ref/contrib/gis/install/postgis/#creating-a-spatial-database-with-postgis-2-0-and-postgresql-9-1

I created my database using the new "CREATE EXTENSION postgis;" method and then attempted to run tests using the standard, manage.py test, but it appears that test does not properly add the necessary postgis extensions and errors with:

DatabaseError: type "geometry" does not exist
LINE 7:     "center" geometry(POINT,3122),

In addition, I attempted to define the POSTGIS_VERSION in my settings.py file thinking this might just be undocumented, but even after adding this, the same error above is still seen.

https://docs.djangoproject.com/en/1.5/ref/contrib/gis/testing/#postgis-version

I guess the work around is to revert to using the create postgis template method.

It would be nice if testing was supported when the "CREATE EXTENTSION" method is used, but if not supported, at least update the docs to mention testing can't be done when this method is used.

Attachments (0)

Change History (10)

comment:1 Changed 13 months ago by anonymous

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Summary changed from test db not created when using new postgis 2.0 "CREATE EXTENSION postgis;" method to test db spatial extentsion not created when using new postgis 2.0 "CREATE EXTENSION postgis;" method

comment:2 Changed 13 months ago by ramiro

  • Component changed from Uncategorized to GIS
  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 13 months ago by anonymous

#19152 was supposed to fix this issue. I have no such setup at hand currently, but it should be nice to understand why that fix failed somewhere.

comment:4 Changed 13 months ago by akaariai

Did you also run CREATE EXTENSION postgis_topology;? I remember that error message, IIRC the reason was not creating the postgis_topology extension, or maybe is was having a template database for PostGIS 1.5. The latter case is easy to check - if you have postgis template, rename it so that Django won't see it.

comment:5 Changed 13 months ago by monkut

  • Component changed from GIS to Uncategorized
  • Triage Stage changed from Accepted to Unreviewed

no, "CREATE EXTENSION postgis_topology;" was not run on the initial database.

comment:6 Changed 13 months ago by monkut

just browsed https://github.com/django/django/commit/fbd1df8e16fc17a5d73f36136298c20b8ec3d618 mentioned in #19152, I don't remember if it's required, but the CREATE extension statement appears to be missing a ";" (semicolon).

cursor.execute("CREATE EXTENSION postgis")

comment:7 Changed 13 months ago by fcurella

  • Resolution set to needsinfo
  • Status changed from new to closed

Hi Monkut,

I just tried creating a simple project, and my tests run fine.

I've created my database using:

$ createdb mydb
$ psql mydb
psql (9.2.2)
Type "help" for help.

mydb=# CREATE EXTENSION postgis;
CREATE EXTENSION

I've tested using manage.py test myapp on Django 1.5 and Django Trunk (commit 99b467f272da9). For future reference, my Postgresql version was 9.2.2 and POSTGIS was 2.0.2.

comment:8 Changed 13 months ago by fcurella

  • Component changed from Uncategorized to GIS

comment:9 Changed 13 months ago by monkut

  • Component changed from GIS to Uncategorized

ok, it's probably an error on my part. I've already migrated back to the template method, but if I hit the problem again I'll try to get more details.

Thanks!

comment:10 Changed 12 months ago by fcurella

  • Cc flavio.curella@… added

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.