GeoAlchemy2 0.13.1__py3-none-any.whl → 0.13.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {GeoAlchemy2-0.13.1.dist-info → GeoAlchemy2-0.13.2.dist-info}/COPYING.rst +0 -0
- {GeoAlchemy2-0.13.1.dist-info → GeoAlchemy2-0.13.2.dist-info}/METADATA +1 -1
- {GeoAlchemy2-0.13.1.dist-info → GeoAlchemy2-0.13.2.dist-info}/RECORD +9 -9
- {GeoAlchemy2-0.13.1.dist-info → GeoAlchemy2-0.13.2.dist-info}/WHEEL +1 -1
- {GeoAlchemy2-0.13.1.dist-info → GeoAlchemy2-0.13.2.dist-info}/top_level.txt +0 -0
- geoalchemy2/alembic_helpers.py +8 -5
- geoalchemy2/comparator.py +0 -1
- geoalchemy2/dialects/sqlite.py +41 -4
- geoalchemy2/functions.py +0 -52
File without changes
|
@@ -1,18 +1,18 @@
|
|
1
1
|
geoalchemy2/__init__.py,sha256=osB4UEZhXaj5uscV-Nzy1bXroSBw9MTAmGTM1g97iTc,4874
|
2
2
|
geoalchemy2/_functions.py,sha256=JdZdgGgRrjv7EySEEHfo1WDIJaGyldTqpCD6jUXVzEQ,62680
|
3
|
-
geoalchemy2/alembic_helpers.py,sha256=
|
4
|
-
geoalchemy2/comparator.py,sha256=
|
3
|
+
geoalchemy2/alembic_helpers.py,sha256=zNuiBTv-zBgv-tU_F6RK6qdv9If5UlzHZpAJUrqjxhU,24834
|
4
|
+
geoalchemy2/comparator.py,sha256=1GkzKi2-kmHPjwoTxMgGGEzMChlo3_XXEv_Vm9-YKIg,7277
|
5
5
|
geoalchemy2/elements.py,sha256=XOEJUfzHiULxFflLyrlvm-korIA9wvAz3CHSrHsIrWg,8032
|
6
6
|
geoalchemy2/exc.py,sha256=Nn9bRKB_35skWDMkEf4_Y2GL6gvguPVycPZcbOfa69g,226
|
7
|
-
geoalchemy2/functions.py,sha256=
|
7
|
+
geoalchemy2/functions.py,sha256=BhT_tRBxQw9k4pMaDwR9gICo7tmgwTtbyZGsoPq8_x4,10037
|
8
8
|
geoalchemy2/shape.py,sha256=uLs2vCW7VnSsaS58f43bg60VjuyoEr9Eq_g7pMGI4-0,3432
|
9
9
|
geoalchemy2/types.py,sha256=F8Qa7ZsDgOB7wjawlgpsJPtzhaTOFNjWdmWlByQ9emU,16733
|
10
10
|
geoalchemy2/dialects/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
11
|
geoalchemy2/dialects/common.py,sha256=5fC6w59JtAkqigkq01TBaQo5teGmknfYA0wyvXeHpEs,2744
|
12
12
|
geoalchemy2/dialects/postgresql.py,sha256=btr-a5ckQRXoEUZCCddoyPAyl2bqTZQuuvRllrAtDCQ,6751
|
13
|
-
geoalchemy2/dialects/sqlite.py,sha256=
|
14
|
-
GeoAlchemy2-0.13.
|
15
|
-
GeoAlchemy2-0.13.
|
16
|
-
GeoAlchemy2-0.13.
|
17
|
-
GeoAlchemy2-0.13.
|
18
|
-
GeoAlchemy2-0.13.
|
13
|
+
geoalchemy2/dialects/sqlite.py,sha256=g4frIyZYGzalhi_PlPOnDUvkeIDJ0KObgjwWH9JkY2g,9253
|
14
|
+
GeoAlchemy2-0.13.2.dist-info/COPYING.rst,sha256=-bQKftq9uMOROzF7oN65kYBBIJKxTmBuDoftp27IC3I,1056
|
15
|
+
GeoAlchemy2-0.13.2.dist-info/METADATA,sha256=T_VK6Fuyzg21OLIlD8EC2S3nUTNEdHmhZ4iw8fvRg1A,1751
|
16
|
+
GeoAlchemy2-0.13.2.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
|
17
|
+
GeoAlchemy2-0.13.2.dist-info/top_level.txt,sha256=3kGUTcfBeXd61zFpof6-qiuw1peNF_HuZabgHQgrdis,12
|
18
|
+
GeoAlchemy2-0.13.2.dist-info/RECORD,,
|
File without changes
|
geoalchemy2/alembic_helpers.py
CHANGED
@@ -41,11 +41,14 @@ def _monkey_patch_get_indexes_for_sqlite():
|
|
41
41
|
def spatial_behavior(self, connection, table_name, schema=None, **kw):
|
42
42
|
indexes = self._get_indexes_normal_behavior(connection, table_name, schema=None, **kw)
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
44
|
+
try:
|
45
|
+
# Check that SpatiaLite was loaded into the DB
|
46
|
+
is_spatial_db = connection.exec_driver_sql(
|
47
|
+
"""PRAGMA main.table_info(geometry_columns)"""
|
48
|
+
).fetchall()
|
49
|
+
if not is_spatial_db:
|
50
|
+
return indexes
|
51
|
+
except AttributeError:
|
49
52
|
return indexes
|
50
53
|
|
51
54
|
# Get spatial indexes
|
geoalchemy2/comparator.py
CHANGED
geoalchemy2/dialects/sqlite.py
CHANGED
@@ -2,9 +2,11 @@
|
|
2
2
|
import os
|
3
3
|
|
4
4
|
from sqlalchemy import text
|
5
|
+
from sqlalchemy.ext.compiler import compiles
|
5
6
|
from sqlalchemy.sql import func
|
6
7
|
from sqlalchemy.sql import select
|
7
8
|
|
9
|
+
from geoalchemy2 import functions
|
8
10
|
from geoalchemy2.dialects.common import _check_spatial_type
|
9
11
|
from geoalchemy2.dialects.common import _format_select_args
|
10
12
|
from geoalchemy2.dialects.common import _spatial_idx_name
|
@@ -185,8 +187,7 @@ def after_create(table, bind, **kw):
|
|
185
187
|
col.type = col._actual_type
|
186
188
|
del col._actual_type
|
187
189
|
dimension = get_col_dim(col)
|
188
|
-
args = [table.
|
189
|
-
args.extend([table.name, col.name, col.type.srid, col.type.geometry_type, dimension])
|
190
|
+
args = [table.name, col.name, col.type.srid, col.type.geometry_type, dimension]
|
190
191
|
|
191
192
|
stmt = select(*_format_select_args(func.RecoverGeometryColumn(*args)))
|
192
193
|
stmt = stmt.execution_options(autocommit=True)
|
@@ -211,8 +212,7 @@ def before_drop(table, bind, **kw):
|
|
211
212
|
# Disable spatial indexes if present
|
212
213
|
disable_spatial_index(bind, table, col)
|
213
214
|
|
214
|
-
args = [table.
|
215
|
-
args.extend([table.name, col.name])
|
215
|
+
args = [table.name, col.name]
|
216
216
|
|
217
217
|
stmt = select(*_format_select_args(func.DiscardGeometryColumn(*args)))
|
218
218
|
stmt = stmt.execution_options(autocommit=True)
|
@@ -222,3 +222,40 @@ def before_drop(table, bind, **kw):
|
|
222
222
|
def after_drop(table, bind, **kw):
|
223
223
|
"""Handle spatial indexes during the after_drop event."""
|
224
224
|
table.columns = table.info.pop("_saved_columns")
|
225
|
+
|
226
|
+
|
227
|
+
# Define compiled versions for functions in SpatiaLite whose names don't have
|
228
|
+
# the ST_ prefix.
|
229
|
+
_SQLITE_FUNCTIONS = {
|
230
|
+
"ST_GeomFromEWKT": "GeomFromEWKT",
|
231
|
+
"ST_GeomFromEWKB": "GeomFromEWKB",
|
232
|
+
"ST_AsBinary": "AsBinary",
|
233
|
+
"ST_AsEWKB": "AsEWKB",
|
234
|
+
"ST_AsGeoJSON": "AsGeoJSON",
|
235
|
+
}
|
236
|
+
|
237
|
+
|
238
|
+
def _compiles_sqlite(cls, fn):
|
239
|
+
def _compile_sqlite(element, compiler, **kw):
|
240
|
+
return "{}({})".format(fn, compiler.process(element.clauses, **kw))
|
241
|
+
|
242
|
+
compiles(getattr(functions, cls), "sqlite")(_compile_sqlite)
|
243
|
+
|
244
|
+
|
245
|
+
def register_sqlite_mapping(mapping):
|
246
|
+
"""Register compilation mappings for the given functions.
|
247
|
+
|
248
|
+
Args:
|
249
|
+
mapping: Should have the following form::
|
250
|
+
|
251
|
+
{
|
252
|
+
"function_name_1": "sqlite_function_name_1",
|
253
|
+
"function_name_2": "sqlite_function_name_2",
|
254
|
+
...
|
255
|
+
}
|
256
|
+
"""
|
257
|
+
for cls, fn in mapping.items():
|
258
|
+
_compiles_sqlite(cls, fn)
|
259
|
+
|
260
|
+
|
261
|
+
register_sqlite_mapping(_SQLITE_FUNCTIONS)
|
geoalchemy2/functions.py
CHANGED
@@ -125,7 +125,6 @@ except ImportError:
|
|
125
125
|
|
126
126
|
|
127
127
|
class TableRowElement(ColumnElement):
|
128
|
-
|
129
128
|
inherit_cache = False
|
130
129
|
"""The cache is disabled for this class."""
|
131
130
|
|
@@ -278,54 +277,3 @@ for name, type_, doc in _FUNCTIONS:
|
|
278
277
|
attributes["__doc__"] = "\n\n".join(docs)
|
279
278
|
|
280
279
|
globals()[name] = type(name, (GenericFunction,), attributes)
|
281
|
-
|
282
|
-
|
283
|
-
#
|
284
|
-
# Define compiled versions for functions in SpatiaLite whose names don't have
|
285
|
-
# the ST_ prefix.
|
286
|
-
#
|
287
|
-
|
288
|
-
|
289
|
-
_SQLITE_FUNCTIONS = {
|
290
|
-
"ST_GeomFromEWKT": "GeomFromEWKT",
|
291
|
-
"ST_GeomFromEWKB": "GeomFromEWKB",
|
292
|
-
"ST_AsBinary": "AsBinary",
|
293
|
-
"ST_AsEWKB": "AsEWKB",
|
294
|
-
"ST_AsGeoJSON": "AsGeoJSON",
|
295
|
-
}
|
296
|
-
|
297
|
-
|
298
|
-
# Default handlers are required for SQLAlchemy < 1.1
|
299
|
-
# See more details in https://github.com/geoalchemy/geoalchemy2/issues/213
|
300
|
-
def _compiles_default(cls):
|
301
|
-
def _compile_default(element, compiler, **kw):
|
302
|
-
return "{}({})".format(cls, compiler.process(element.clauses, **kw))
|
303
|
-
|
304
|
-
compiles(globals()[cls])(_compile_default)
|
305
|
-
|
306
|
-
|
307
|
-
def _compiles_sqlite(cls, fn):
|
308
|
-
def _compile_sqlite(element, compiler, **kw):
|
309
|
-
return "{}({})".format(fn, compiler.process(element.clauses, **kw))
|
310
|
-
|
311
|
-
compiles(globals()[cls], "sqlite")(_compile_sqlite)
|
312
|
-
|
313
|
-
|
314
|
-
def register_sqlite_mapping(mapping):
|
315
|
-
"""Register compilation mappings for the given functions.
|
316
|
-
|
317
|
-
Args:
|
318
|
-
mapping: Should have the following form::
|
319
|
-
|
320
|
-
{
|
321
|
-
"function_name_1": "sqlite_function_name_1",
|
322
|
-
"function_name_2": "sqlite_function_name_2",
|
323
|
-
...
|
324
|
-
}
|
325
|
-
"""
|
326
|
-
for cls, fn in mapping.items():
|
327
|
-
_compiles_default(cls)
|
328
|
-
_compiles_sqlite(cls, fn)
|
329
|
-
|
330
|
-
|
331
|
-
register_sqlite_mapping(_SQLITE_FUNCTIONS)
|