SQLAlchemy requires extend_existing
- Dominant language
- XSLT
- Stars
- 136
- Forks
- 207
- PR merge metrics
- No merged PRs in 30d
Description
Datacats CKAN "latest" (2.5a) with our ckanext-spatial [fork](https://github.com/datawagovau/ckanext-spatial) which is exactly up to date with upstream/master.
With SQLAlchemy==0.9.6 installed, booting up CKAN trips when spatial inits their tables.
SQLAlchemy defaults to creating/updating tables with `Table(..., column defs, extend_existing=False)`, we'll need True:
```
File "/project/ckanext-spatial/ckanext/spatial/plugin.py", line 78, in configure
setup_model()
File "/project/ckanext-spatial/ckanext/spatial/model/package_extent.py", line 22, in setup
define_spatial_tables(srid)
File "/project/ckanext-spatial/ckanext/spatial/model/package_extent.py", line 69, in define_spatial_tables
package_extent_table = setup_spatial_table(PackageExtent, db_srid)
File "/project/ckanext-spatial/ckanext/spatial/geoalchemy_common.py", line 74, in setup_spatial_table
management=management)),
File "/usr/lib/ckan/local/lib/python2.7/site-packages/sqlalchemy/sql/schema.py", line 339, in __new__
"existing Table object." % key)
sqlalchemy.exc.InvalidRequestError: Table 'package_extent' is already defined for this MetaData instance. Specify 'extend_existing=True' to redefine options and columns on an existing Table object.
Starting subprocess with file monitor
```
This sounds similar to ckan/ckanext-pages#27. I'll attempt a fix now, if you don't hear a PR from me, send coffee and help.
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the CKAN startup failure with SQLAlchemy 0.9.6, then inspect ckanext/spatial/model/package_extent.py and ckanext/spatial/geoalchemy_common.py, especially setup and setup_spatial_table. Done means spatial table initialization completes without the existing MetaData InvalidRequestError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, sqlalchemy
- Domain
- database
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100