summaryrefslogtreecommitdiff
path: root/test/ext/test_automap.py
Commit message (Collapse)AuthorAgeFilesLines
* repair broken lambda patchMike Bayer2023-03-101-1/+1
| | | | | | | | | | | | | | | | in I4e0b627bfa187f1780dc68ec81b94db1c78f846a the 1.4 version has more changes than the main version, which failed to get the entire change, yet the whole thing was merged. Restore the missing mutex related code to the main version. Fixed regression where the fix for :ticket:`8098`, which was released in the 1.4 series and provided a layer of concurrency-safe checks for the lambda SQL API, included additional fixes in the patch that failed to be applied to the main branch. These additional fixes have been applied. Change-Id: Id172e09c421dafa6ef1d40b383aa4371de343864 References: #8098 Fixes: #9461
* locate automap base in hierarchy directlyMike Bayer2023-02-241-0/+12
| | | | | | | | | | | | Fixed issue in automap where calling ``.prepare()`` from one of the mapped classes would not use the correct base class when automap detected new tables, instead using the given class, leading to mappers trying to configure inheritance. While one should normally call ``.prepare()`` from the base in any case, it shouldn't misbehave that badly when called from a subclass. Fixes: #9367 Change-Id: I705d4d939d45af52bc58a74e65994205ab791634
* add hooks/docs for automap w/ multiple schemasMike Bayer2023-01-261-0/+185
| | | | | | | | | | | Added new feature to :class:`.Automap` for autoload of classes across multiple schemas which may have overlapping names, by providing both a :paramref:`.Automap.prepare.modulename_for_class` parameter as well as a new collection :attr:`.AutomapBase.by_module`, which stores a dot-separated namespace of module names linked to classes. Fixes: #5145 Change-Id: I735fecaacdfc267f1f901d76c2b3880e48f5969d
* Try running pyupgrade on the codeFederico Caselli2022-11-161-2/+2
| | | | | | | | command run is "pyupgrade --py37-plus --keep-runtime-typing --keep-percent-format <files...>" pyupgrade will change assert_ to assertTrue. That was reverted since assertTrue does not exists in sqlalchemy fixtures Change-Id: Ie1ed2675c7b11d893d78e028aad0d1576baebb55
* Update Black's target-version to py37Hugo van Kemenade2022-01-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | <!-- Provide a general summary of your proposed changes in the Title field above --> ### Description <!-- Describe your changes in detail --> Black's `target-version` was still set to `['py27', 'py36']`. Set it to `[py37]` instead. Also update Black and other pre-commit hooks and re-format with Black. ### Checklist <!-- go over following points. check them with an `x` if they do apply, (they turn into clickable checkboxes once the PR is submitted, so no need to do everything at once) --> This pull request is: - [ ] A documentation / typographical error fix - Good to go, no issue or tests are needed - [ ] A short code fix - please include the issue number, and create an issue if none exists, which must include a complete example of the issue. one line code fixes without an issue and demonstration will not be accepted. - Please include: `Fixes: #<issue number>` in the commit message - please include tests. one line code fixes without tests will not be accepted. - [ ] A new feature implementation - please include the issue number, and create an issue if none exists, which must include a complete example of how the feature would look. - Please include: `Fixes: #<issue number>` in the commit message - please include tests. **Have a nice day!** Closes: #7536 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7536 Pull-request-sha: b3aedf5570d7e0ba6c354e5989835260d0591b08 Change-Id: I8be85636fd2c9449b07a8626050c8bd35bd119d5
* Clean up most py3k compatFederico Caselli2021-11-241-2/+2
| | | | Change-Id: I8172fdcc3103ff92aa049827728484c8779af6b7
* have automap suppress overlaps warning for mapped secondaryMike Bayer2021-06-251-0/+41
| | | | | | | | | | | | | | | | Fixed regression in :mod:`sqlalchemy.ext.automap` extension such that the use case of creating an explicit mapped class to a table that is also the :paramref:`_orm.relationship.secondary` element of a :func:`_orm.relationship` that automap will be generating would emit the "overlaps" warnings introduced in 1.4 and discussed at :ref:`error_qzyx`. While generating this case from automap is still subject to the same caveats that the "overlaps" warning refers towards, as automap is intended for more ad-hoc use cases, the condition which produces the warning is disabled when a many-to-many relationship with this particular pattern is generated. Fixes: #6679 Change-Id: Ib3a53982b076ed4999b0d3235f84008b9e2f1cce
* Add reflection_options to automapbase.prepare()Gord Thompson2021-02-251-0/+26
| | | | | Fixes: #5942 Change-Id: If72ccca93fbe303799b1bacb7339c4c85e4251aa
* remove metadata.bind use from test suiteMike Bayer2021-01-031-12/+12
| | | | | | | | | | | | | | importantly this means we can remove bound metadata from the fixtures that are used by Alembic's test suite. hopefully this is the last one that has to happen to allow Alembic to be fully 1.4/2.0. Start moving from @testing.provide_metadata to a pytest metadata fixture. This does not seem to have any negative effects even though TablesTest uses a "self.metadata" attribute. Change-Id: Iae6ab95938a7e92b6d42086aec534af27b5577d3
* Deprecate bound metadataMike Bayer2020-10-121-7/+6
| | | | | | | | | | | | | | | | | The :paramref:`_schema.MetaData.bind` argument as well as the overall concept of "bound metadata" is deprecated in SQLAlchemy 1.4 and will be removed in SQLAlchemy 2.0. The parameter as well as related functions now emit a :class:`_exc.RemovedIn20Warning` when :ref:`deprecation_20_mode` is in use. Added new parameter :paramref:`_automap.AutomapBase.prepare.autoload_with` which supersedes :paramref:`_automap.AutomapBase.prepare.reflect` and :paramref:`_automap.AutomapBase.prepare.engine`. Fixes: #4634 Fixes: #5142 Change-Id: Iaabf9b481931e2fb68b97b5954c32e65772a298e
* Fix a wide variety of typos and broken linksaplatkouski2020-06-251-2/+2
| | | | | | | | | | | | Note the PR has a few remaining doc linking issues listed in the comment that must be addressed separately. Signed-off-by: aplatkouski <5857672+aplatkouski@users.noreply.github.com> Closes: #5371 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5371 Pull-request-sha: 7e7d233cf3a0c66980c27db0fcdb3c7d93bc2510 Change-Id: I9c36e8d8804483950db4b42c38ee456e384c59e3
* Add informative failure modes to _DeferredMapperConfigMike Bayer2019-01-301-0/+20
| | | | | | | | | | | Added some helper exceptions that invoke when a mapping based on :class:`.AbstractConcreteBase`, :class:`.DeferredReflection`, or :class:`.AutoMap` is used before the mapping is ready to be used, which contain descriptive information on the class, rather than falling through into other failure modes that are less informative. Fixes: #4470 Change-Id: I9bc51697f63cedaa7809a0adb17b2398c209e289
* Post black reformattingMike Bayer2019-01-061-12/+19
| | | | | | | | | | | | | Applied on top of a pure run of black -l 79 in I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9, this set of changes resolves all remaining flake8 conditions for those codes we have enabled in setup.cfg. Included are resolutions for all remaining flake8 issues including shadowed builtins, long lines, import order, unused imports, duplicate imports, and docstring issues. Change-Id: I4f72d3ba1380dd601610ff80b8fb06a2aff8b0fe
* Run black -l 79 against all source filesMike Bayer2019-01-061-73/+94
| | | | | | | | | | | | | | This is a straight reformat run using black as is, with no edits applied at all. The black run will format code consistently, however in some cases that are prevalent in SQLAlchemy code it produces too-long lines. The too-long lines will be resolved in the following commit that will resolve all remaining flake8 issues including shadowed builtins, long lines, import order, unused imports, duplicate imports, and docstring issues. Change-Id: I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9
* Mutex on _CONFIGURE_MUTEX in automap.prepare()Mike Bayer2018-05-281-1/+59
| | | | | | | | | | | | Fixed a race condition which could occur if automap :meth:`.AutomapBase.prepare` were used within a multi-threaded context against other threads which may call :func:`.configure_mappers` as a result of use of other mappers. The unfinished mapping work of automap is particularly sensitive to being pulled in by a :func:`.configure_mappers` step leading to errors. Change-Id: I6d36df6639bf5cb8f137187dff68f386f5e84f88 Fixes: #4266
* Make all tests to be PEP8 compliantKhairi Hafsham2017-02-071-1/+2
| | | | | | | | tested using pycodestyle version 2.2.0 Fixes: #3885 Change-Id: I5df43adc3aefe318f9eeab72a078247a548ec566 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/343
* Add schema argument to AutomapBase.prepare()Josh Marlow2016-06-021-1/+36
| | | | | | | | | This allows automap to reflect tables from a schema other than the default without the need to resort to calling MetaData.reflect directly. Change-Id: Ie73cb113bd6d115555c09c5efc33d27ad2c9c512 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/237
* - The :mod:`sqlalchemy.ext.automap` extension will now setMike Bayer2014-09-221-1/+67
| | | | | | | | | | | | | | ``cascade="all, delete-orphan"`` automatically on a one-to-many relationship/backref where the foreign key is detected as containing one or more non-nullable columns. This argument is present in the keywords passed to :func:`.automap.generate_relationship` in this case and can still be overridden. Additionally, if the :class:`.ForeignKeyConstraint` specifies ``ondelete="CASCADE"`` for a non-nullable or ``ondelete="SET NULL"`` for a nullable set of columns, the argument ``passive_deletes=True`` is also added to the relationship. Note that not all backends support reflection of ondelete, but backends that do include Postgresql and MySQL. fixes #3210
* pep8/flake8Mike Bayer2014-09-221-42/+59
|
* - fix this test for MySQL, needs InnoDBMike Bayer2014-05-301-3/+7
|
* Documentation fix-up: "its" vs. "it's"pr/91Matthias Urlichs2014-05-111-1/+1
| | | | | | | | | Removed ungrammatical apostrophes from documentation, replacing "it's" with "its" where appropriate (but in a few cases with "it is" when that read better). While doing that, I also fixed a couple of minor typos etc. as I noticed them.
* - Added support to automap for the case where a relationship shouldMike Bayer2014-03-281-0/+7
| | | | | | | not be created between two classes that are in a joined inheritance relationship, for those foreign keys that link the subclass back to the superclass. fixes #3004
* - Fixed bug where the :class:`.AutomapBase` class of theMike Bayer2014-02-081-0/+65
| | | | | | | new automap extension would fail if classes were pre-arranged in single or potentially joined inheritance patterns. The repaired joined inheritance issue could also potentially apply when using :class:`.DeferredReflection` as well.
* - docs + testsMike Bayer2014-01-051-0/+146