Open rushilsrivastava opened 2 years ago
Hi @rushilsrivastava ! Thank you for this suggestion, it's a good idea. I don't have much time to work on this atm so I leave the issue open for now but that's clearly a feature that could be added.
(But if anyone else can work on it it would be nice :wink: )
Hi @jjgarrett0, did you have some time to work on this? (just to know, no pressure :relaxed: )
@adrien-berchet I have not. Life got in the way, I should have some time this October to take a gander at it though.
@adrien-berchet I have not. Life got in the way, I should have some time this October to take a gander at it though.
No problem @jjgarrett0, October will be perfect, thanks!
at geoalchemy2/admin/__init__.py#L92
if we replace following
table.append_constraint(
Index(
_spatial_idx_name(table.name, column.name),
col,
**kwargs,
)
)
with
table.append_constraint(
Index(
None,
col,
**kwargs,
)
)
we could achieve the results. However we need to handle cases where we're doing idx.name != _spatial_idx_name(table.name, col.name)
in before_create
events for multiple dialects.
do we need to save the info about indexes created by geoalchemy?
Another way could be to extract index_naming_convention
and format the pattern using SQLAlchemy's naming.ConventionDict
.. or something similar
index_convention = naming._get_convention(table.metadata.naming_convention, Index)
get index_constraint from table_orm.constraints
index_name = index_constraint % naming.ConventionDict(
index_constraint, table_orm, table_orm.metadata.naming_convention
)
but this needs constraint to be present in table_orm
at this stage, which is not.
how would you suggest @adrien-berchet ..?
Currently, the autogeneration template of indexes is non configurable:
https://github.com/geoalchemy/geoalchemy2/blob/9d89df18a4e96f1edb25b407f3a056c68037b063/geoalchemy2/__init__.py#L47-L48
It would be nice to follow the default conventions established in the metadata if specified, so that it can remain consistent with sqlalchemy.