forked from ckan/ckan
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ckan#7583 from ckan/sqlalchemy-2.0
SQLAlchemy 2.0
- Loading branch information
Showing
77 changed files
with
1,263 additions
and
1,138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
:py:meth:`~ckanext.datastore.interfaces.IDatastore.datastore_search` of | ||
:py:class:`~ckanext.datastore.interfaces.IDatastore` interface is not completely | ||
compatible with old version. | ||
|
||
``where`` key of the ``query_dict`` returned from this method has a different | ||
format. Before it was a collection of tuples with an SQL where-clause with | ||
positional/named ``%``-style placeholders on the first position, followed by | ||
arbitrary number of parameters:: | ||
|
||
return { | ||
..., | ||
"where": [('"age" BETWEEN %s AND %s', param1, param2, ...), ...] | ||
} | ||
|
||
Now every element of collection must be a tuple that contains SQL where-clause | ||
with **named** ``:``-style placeholders and a dict with the values for all the | ||
placeholders: | ||
|
||
|
||
return { | ||
..., | ||
"where": [( | ||
'"age" BETWEEN :my_ext_min AND :my_ext_max', | ||
{"my_ext_min": age_between[0], "my_ext_max": age_between[1]}, | ||
)] | ||
} | ||
|
||
In order to avoid name conflicts with placeholders from different plugin, don't | ||
use simple names, i.e. ``val``, ``min``, ``name``, and add unique prefix to all | ||
the placeholders. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
SQLAlchemy's Metadata object(:py:attr:`ckan.model.meta.metadata`) is no longer | ||
bound the the DB engine. [A number of | ||
operations](https://docs.sqlalchemy.org/en/14/changelog/migration_20.html#implicit-and-connectionless-execution-bound-metadata-removed), | ||
such as `table.exists()`, `table.create()`, `metadata.create_all()`, | ||
`metadata.reflect()`, now produce an error | ||
:py:class:`sqlalchemy.exc.UnboundExecutionError`. | ||
|
||
Depending on the situation, following changes may be required: | ||
|
||
* Instead of creating tables via custom CLI command or during application | ||
startup, use [Alembic | ||
migrations](https://docs.ckan.org/en/2.10/extensions/best-practices.html#use-migrations-when-introducing-new-models) | ||
|
||
* If there is no other way, change `table.create()`/`table.exists()` to | ||
`table.create(engine)`/`table.exists()`. Get `engine` by calling | ||
:py:func:`~ckan.model.ensure_engine`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.