summaryrefslogtreecommitdiff
path: root/oslo_db/sqlalchemy
Commit message (Collapse)AuthorAgeFilesLines
...
| * types: Set 'cache_ok'Stephen Finucane2021-06-221-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Resolves the following warning that has been popping up on tests: SAWarning: TypeDecorator SoftDeleteInteger() will not produce a cache key because the ``cache_ok`` flag is not set to True. Set this flag to True if this type object's state is safe to use in a cache key, or False to disable this warning. Both SoftDeleteInteger and the various subclasses of 'JsonEncodedType' are hashable and should return a consistent hash and key. For more information, refer to the SQLAlchemy docs [1]. [1] https://docs.sqlalchemy.org/en/14/core/custom_types.html#sqlalchemy.types.TypeDecorator.cache_ok Change-Id: Idf6fd858fad9521c7c5ba82c31b6d3077756abd9 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
* | Merge "Remove the useless else."Zuul2021-06-231-2/+1
|\ \
| * | Remove the useless else.Daniel Bengtsson2021-06-231-2/+1
| | | | | | | | | | | | | | | | | | We return the value in the if condition, so the else is not necessary. Change-Id: I1de4b7f7f7ea3634e3a2d49704f689205f746085
* | | Merge "Remove the idle_timeout option."Zuul2021-06-231-4/+0
|\ \ \
| * | | Remove the idle_timeout option.Daniel Bengtsson2021-06-231-4/+0
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | The option was replaced 4 years ago[1] by connection_recycle_time. The option is not anymore present in sqlalchemy. It's the good time to remove it. [1] https://opendev.org/openstack/oslo.db/commit/6634218415906192fca891362b8fa0ac50b66284 Change-Id: I0c26c3e14ad9ad9a4f30af80757e369d6042441a
* | | Merge "Replace getargspec with getfullargspec"Zuul2021-06-222-22/+2
|\ \ \ | |_|/ |/| |
| * | Replace getargspec with getfullargspeclikui2021-05-112-22/+2
| |/ | | | | | | | | | | | | | | getargspec() is deprecated since py3 [1] https://docs.python.org/3/library/inspect.html#inspect.getargspec Change-Id: Ie1513f9b4911e54ce6714074eb2dc4052323ef42
* | Added handler for mysql 8.0.19 duplicate key error updateKamlesh Chauvhan2021-06-041-0/+9
|/ | | | | | | | | | | In mysql 8.0.19 , Duplicate key error information is extended to include the table name of the key.Previously, duplicate key error information included only the key value and key name. Unit tests are provided for updated changes. Change-Id: Ic78059b625e73cece355541cb4d89e641abc1103 Closes-Bug: #1896916
* Merge "Don't use private API to get query criteria"8.6.0Zuul2021-04-281-4/+3
|\
| * Don't use private API to get query criteriaMike Bayer2021-04-281-4/+3
| | | | | | | | | | | | | | | | | | Another change for SQLAlchemy 1.4 is the mechanics of how the ``QueryContext`` object works. Update the update_match extension such that it does not rely upon the ``QueryContext`` object and uses public APIs instead. Change-Id: I27e20e59bce8c98b5a507c617364652aa6eb33f5
* | Merge "Accommodate immutable URL api"Zuul2021-04-282-2/+21
|\ \ | |/
| * Accommodate immutable URL apiMike Bayer2020-12-112-2/+21
| | | | | | | | | | | | | | | | | | | | | | SQLAlchemy 1.4 has modified the URL object to be immutable. This patch makes the adjustments needed, using duck-typing to check if the URL object is of the new style. When requirements reach SQLAlchemy 1.4 as the minimum required version, these conditionals should be removed in favor of the noted option in each. Change-Id: Id2f0663b13ed0f81e91a8d44f73d8541015bf844
* | remove unicode from codexuanyandong2021-01-031-3/+3
| | | | | | | | Change-Id: Ia782bc7127a1cb967e2f475065b1fb963b9c184f
* | Deprecate the 'oslo_db.sqlalchemy.migration_cli' moduleStephen Finucane2020-10-301-0/+7
| | | | | | | | | | | | | | | | | | | | | | This API allowed users to abstract the differences between sqlalchemy-migrate and alembic. However, no one is using it for that and its continued existence necessitates continued support for sqlalchemy-migrate. Deprecate it now and encourage the odd user to switch to alembic directly. Change-Id: Ia5979369f23b38a2c7307f4112651a8bedb45c01 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
* | Deprecate 'oslo_db.sqlalchemy.migration' moduleStephen Finucane2020-10-301-0/+10
|/ | | | | | | | | This module hasn't been touched with years and 'sqlalchemy-migrate' is effectively abandoned. It's time to drop support for this an encourage the laggards to switch to alembic and use it directly. Change-Id: I59335b4f318bae2e29ab139cdea089a4d6e14305 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
* Remove use of deprecated LOG.warnSean McGinnis2020-04-141-2/+2
| | | | | Change-Id: Icea747aff5fe51b96c70d263fa0f0e2e9c5ab917 Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
* Update hacking for Python3Andreas Jaeger2020-03-303-0/+3
| | | | | | | | | | | | | The repo is Python 3 now, so update hacking to version 3.0 which supports Python 3. blacklist: W504 line break after binary operator Fix: E305 expected 2 blank lines after class or function definition, found 1 Change-Id: I56d62f67914f07e7aef74f857c4b42e3bfd3416e
* Remove 'handle_connect_error'8.0.0Stephen Finucane2020-02-251-5/+0
| | | | | | | | | Nothing appears to be using this, based on codesearch.o.o, and it's useless. Drop it. Change-Id: I9ce39e69a6fdb2e216da9fd903b5dc8aa7eaab80 Signed-off-by: Stephen Finucane <stephenfin@redhat.com> Sem-Ver: api-break
* Drop use of sixStephen Finucane2020-02-258-43/+21
| | | | | | | No need for this in a Python 3-only world. Change-Id: I8923f2b87c1bd114b8c55210100c7485a0de8f28 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
* Raise minimum SQLAlchemy version to 1.2.0Stephen Finucane2020-02-254-78/+3
| | | | | | | | | | Per [1], this is the latest supported version of SQLAlchemy. 1.1.x and earlier are EOL. [1] https://www.sqlalchemy.org/download.html#relstatus Change-Id: I63e4baf772be9ddfb787ac3aff01fcaddf7b901c Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
* Reduce severity of wrapped exceptions logs to warningDarragh O'Reilly2019-11-131-3/+2
| | | | | Change-Id: I6ea68fb17ceac23337bfb7405eb3f7a6df8b61f2 Closes-Bug: 1851797
* Rollback existing nested transacvtion before restarting5.0.1Mike Bayer2019-06-071-0/+4
| | | | | | | | | | SQLAlchemy 1.4 will be adding stricter rules to Connection objects such that a new transaction cannot be started while an old one hasn't been cleared. Ensure this particular test fixture clears the "savepoint" transaction first before starting a new one. References: https://github.com/sqlalchemy/sqlalchemy/issues/4712 Change-Id: Idcb616fd3add4d58f22b91865cec8a54fe492093
* Merge "Support context function argument as keyword"Zuul2019-05-151-1/+4
|\
| * Support context function argument as keywordAdrian Chiris2019-04-071-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Today, when a user uses enginefacade reader/writer decorators he/she is forced to pass the context argument as the first positional argument. performing a decorated function call with this argument passed as a keyword would lead to an out of range exception. This patch proposes to add support for the context argument to be passed as a keyword argument in decorated functions. e.g @enginefacade.reader def foo(context): ... foo(context=ctxt) <- will now be possible Change-Id: Ief0b71bf9a7eb75935612431bdcc26d33bce852d
* | Merge "Removing deprecated min_pool_size"Zuul2019-04-241-1/+1
|\ \
| * | Removing deprecated min_pool_sizeErik Olof Gunnar Andersson2019-04-061-1/+1
| |/ | | | | | | | | | | | | | | | | | | The database option min_pool_size is not actually used in oslo.db. This is a folllow up to Ib07b7b4200b5cf3a34b8eed441e6754da7d446cf Change-Id: I89754e9e4b42c45259729b0b0bb0a4bf464a981c
* | Fix deprecation warnings under py36Sean McGinnis2019-04-112-11/+17
|/ | | | | | | | | | | | | | | | | This addresses two sources of deprecation warnings. The collections package has moved ABC classes under collections.abc. Six does not support this move yet, so this updates the code to try to import from the newer locations, and if that fails, import from the old location. Py36 is also more strict about escape sequences in strings. This happens move often with regex strings that are valid regex but not a valid normal string escape sequence. This addresses those errors by switching to raw strings. Change-Id: I4c61df6b6432b135297f38c02b4538e4ba56be51 Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
* Merge "Resolve SAWarning in Query.soft_delete()"4.44.0Zuul2019-02-131-3/+3
|\
| * Resolve SAWarning in Query.soft_delete()Mike Bayer2019-02-011-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We currently see a lot of warnings like this from the soft_delete() method: sqlalchemy.exc.SAWarning: Evaluating non-mapped column expression 'updated_at' onto ORM instances; this is a deprecated use case. Please make use of the actual mapped columns in ORM-evaluated UPDATE / DELETE expressions. This is because the "evaluate" synchronization strategy would like to search for objects and update them based on the UPDATE criteria passed, however the columns given, literal_column('id'), literal_column('updated_at'), are not mapped to anything. The evaluator has to make a guess that the string contained in these expressions should be matched to a mapped attribute on the given entity and this guess was first removed in [1], then added back in [2] with a warning (likely since oslo.db is invoking it). This uses the actual entity-mapped column for the query rather than the literal string column. [1] https://docs.sqlalchemy.org/en/latest/changelog/changelog_12.html#change-b1e620dece39006ab44c47044e9a6fee [2] https://docs.sqlalchemy.org/en/latest/changelog/changelog_12.html#change-dff3a469788c81a46440584406cb22be Change-Id: I192e84ce757d12d33085a209dd58d8ea46fb90fb Closes-Bug: #1814199
* | exc_filters: fix deadlock detection for MariaDB/Galera clusterPierre-Samuel Le Stang2019-02-081-0/+2
|/ | | | | | | | | | | MariasDB/Galera cluster server produces an error like: (1213, u'Deadlock: wsrep aborted transaction') which is currently not detected properly and, thus, not retried. Change-Id: Ifb4a81d50e490e734e12986e51efd6bd3c339c31 Signed-off-by: Pierre-Samuel Le Stang <pierre-samuel.le-stang@corp.ovh.com>
* Merge "Update hacking version"Zuul2019-01-221-2/+2
|\
| * Update hacking versionZhijunWei2019-01-031-2/+2
| | | | | | | | | | | | | | | | update the hacking to latest, due to [1] [1]: https://github.com/openstack/oslo.db/blob/master/HACKING.rst Change-Id: I04147f3cbcb9c89a9a1afc1bcb299be8bdf06718
* | Remove convert_unicode flag4.43.0Mike Bayer2018-12-211-1/+0
|/ | | | | | | | | | | | | | This flag is to be deprecated in SQLAlchemy version 1.3, as it is a leftover from the pre-Python 3 legacy days when DBAPIs under Python 2 would crash if you passed them a u'' object. While still available in 1.3, it will emit a deprecation warning, so it's time to stop using this flag and to locate any downstream Openstack projects that might be relying on its behavior in a Python 2 context; the flag has no real effect on Python 3. Change-Id: I01984b4ff7e03dcf91ef8dcb05da67dda8270ae3 References: https://github.com/sqlalchemy/sqlalchemy/issues/4393
* Merge "Move warnings to their own module"4.42.0Zuul2018-10-301-3/+3
|\
| * Move warnings to their own moduleStephen Finucane2018-10-171-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Raising warnings from an exception module can result in a rather confusing message: Running command: '/usr/bin/nova-scheduler ' /.../sqlalchemy/enginefacade.py:332: NotSupportedWarning: Configuration option(s) ['use_tpool'] not supported exception.NotSupportedWarning For someone not used to Python's 'warning' infrastructure, this can look worse than it is, as seen at [1]. While this particular warning was resolved in change I4a5f8958c3e, it's possible that a similar warning could be raised for other options. Best to move this out of the 'exception' module and into something more sensible. [1] https://bugzilla.redhat.com/show_bug.cgi?id=1639423 Change-Id: I8e0480fb11123067a111ed6aeda6b47614615645 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
* | Add "is_started" flag to enginefacadeMike Bayer2018-10-241-1/+20
|/ | | | | | | | | | | | | | | | Some module reloading scenarios such as that which occurs within mod_wsgi mean that an existing module-level enginefacade is already in the "started" state, however initialization routines from the calling application may still attempt to call the ``.configure`` method. Add a new flag is_started to both _TransactionContextManager and _TransactionFactory so that calling code can check for this state ahead of time; additionally, promote the TypeError raised to a specific subclass enginefacade.AlreadyStartedError to allow for better optimistic schemes. Change-Id: I2f5a9e35c2fae0c28b78beef3dcd2c4794362766 References: I704196711d30c1124e713ac31111a8ea6fa2f1ba
* Fix FOREIGN KEY messages for MariaDB 10.2, 10.34.41.14.41.0Mike Bayer2018-08-301-4/+4
| | | | | | | | | | | | | | | | | | | | | | | MariaDB 10.2 and 10.3 have changed the format diplayed for MySQL error 1091, adding the phrase "FOREIGN KEY", changing the quoting style of the constraint name, and replacing the phrase "column/key" with the word "it". Adjust the regular expression in exc_filters to accommodate these. - "check that column/key" -> "check that constraint/column/key" https://github.com/MariaDB/server/commit/db7edfed17efe6bc - single quotes -> backticks - "check that constraint/column/key" -> "check that it" https://github.com/MariaDB/server/commit/99e48cb1d94e2d88 - "Can't DROP" -> "Can't DROP FOREIGN KEY" https://github.com/MariaDB/server/commit/5c764a0eb82c87ac Change-Id: I165c595edbbdc101ebd2367ca5680b6cd81eaa7b
* Merge "Rename enginefacade.async to enginefacade.async_"4.40.0Zuul2018-07-041-1/+13
|\
| * Rename enginefacade.async to enginefacade.async_Mike Bayer2018-07-021-1/+13
| | | | | | | | | | | | | | | | | | | | Python 3.7 now makes "async" a keyword, so deprecate the "async" name and replace with "async_". Additionally, use attribute name access only in order to implement and test "async" as it won't work under Python 3.7. Closes-Bug: #1775866 Change-Id: Ifb2c59c2cfbd615b04570b31fcfe868f4ffea3c6
* | Remove most server_default comparison logic4.39.0Mike Bayer2018-06-151-20/+0
|/ | | | | | | | | | | | | | | | | | Added a new test case that covers comparison of a MySQL server default defined as text("0") in the model as well as in the database. The MySQL default comaprison logic in oslo.db was not accommodating of the model side here being a text() construct. As modern Alembic versions supports most of the use cases tested here, remove all server defaut comparison logic except for the boolean comparison workaround. Alembic minimum is bumped to 0.9.6; the issue repaired between 0.8.10 and 0.9.6 is http://alembic.zzzcomputing.com/en/latest/ changelog.html#change-5459a7552a17d8b658f0f710bedf6da0 Depends-on: I1a8244edae47b04b7b1fed54e577d6534945bcd8 Closes-bug: #1776527 Change-Id: I48a103e28d86128ea84466da4d9d6faab1dd9a9d
* Merge "Ignore 'use_tpool' option"Zuul2018-03-091-4/+4
|\
| * Ignore 'use_tpool' optionStephen Finucane2018-03-091-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | The sheer act of registering the 'use_tpool' option seems to be enough to cause the following warning: NotSupportedWarning: Configuration option(s) ['use_tpool'] not supported Add it to the list of ignored opts, thus silencing this warning. Change-Id: I4a5f8958c3e0fc68fa3a4ae979f284c4fbd9b82b
* | Ensure all test fixtures in oslo_db.tests are privateMike Bayer2018-03-021-2/+6
| | | | | | | | | | | | | | | | | | | | | | Downstream projects have started using the fixtures inside of oslo_db.tests in response to the deprecations added in I0163e637ffef6d45d2573ebe29b5438911d01fce. This was not the intent of these deprecations, so add messsaging to this effect and ensure fixtures used by the test suite itself are noted as private. Change-Id: I3afe0a440a3ab66904aaecf556948df9d4e16b8e
* | Merge "Conditionally adjust for quoting in comparing MySQL defaults"Zuul2018-03-011-3/+5
|\ \
| * | Conditionally adjust for quoting in comparing MySQL defaultsMike Bayer2018-02-221-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MariaDB 10.2 appears to not return server defaults with quotes around integer values which breaks the assumption that we have to de-quote server default values. Make the dequoting a regexp that will pass when the quotes are not present. Change-Id: Ie5aeffcc3c550673a7fdd82769a315821cebb272 Closes-bug: #1750414
* | | Merge "Allow connection query string to be passed separately."Zuul2018-02-202-2/+24
|\ \ \ | |/ / |/| |
| * | Allow connection query string to be passed separately.Mike Bayer2018-01-302-2/+24
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Nova project has made the decision to store the entire contents of the "sql_connection" field in the database, with alterations to the host value, such that various "cells" database URLs can be located using Nova's database itself as a central registry of database URLs. This architecture has produced several problems. The first is that it is impossible to apply parameters to the URL that are local to the client machine; the leading example of this is the MySQL "bind_host" variable, which must match the hostname of the connecting host. Because cells puts these URLs into the database and shares them with all controllers, we have to use a workaround with the read_default_file parameter to specify a controller-local file of options; this is not a standard thing for other database drivers, and these parameters only apply to the MySQL driver and not the SQLAlchemy engine. The next issue is that it is inconvenient to add parameters to the URL at all, once Nova has already been running, as one must manually use Nova's command line tools to alter all the URLs that have already been copied into the database and alter the query parameters with each of those individually, and then restart *all* services who will all receive the parameter (no way to add params to just one controller). Nova's "store the URL in the database" feature only needs to be able to locate the host / database name of the alternate database, and not change the URL tuning parameters. This patch adds a new oslo.db parameter connection_parameters which allows the params to be applied separately from the sql_connection parameter, so that Nova can continue persisting sql_connection but the parameters remain local to the nova.conf file. A URL parameter that truly had to remain persisted in Nova's database (there aren't any) could still be applied at the sql_connection level. This feature is essential not just so that we can again place simple parameters into controller-local files like "bind_host", but also to allow for configuration of SQLAlchemy features such as plugins that do connection pool monitoring. Change-Id: Id4de4b09ec4719cbf8b372629fcf58cf368a33d4
* | Reverse role of synchronous_readerMike Bayer2018-01-291-2/+4
|/ | | | | | | | | | | Repaired the "synchronous_reader" modifier of enginefacade so that it refers to the "writer" engine when set to True, thereby allowing "synchronous" behavior with the writer. When set to False, this is "asynchronous", so this should be associated with the async engines. The flag had the reverse behavior previously. Change-Id: Id7fea7562ba90eb710176d497af103303f230531 Closes-bug: #1746116
* Merge "Remove function optimize_db_test_loader in test_base.py"Zuul2018-01-052-7/+3
|\
| * Remove function optimize_db_test_loader in test_base.pyzhangyangyang2017-09-072-7/+3
| | | | | | | | | | | | | | | | optimize_db_test_loader is replaced by optimize_package_test_loader in test_fixtures.py.So this function is deprecated for removal. Change-Id: I12cdf846f1e23d74ae8a87bea33fbc8477974bfc Closes-Bug:#1715572