summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext/automap.py
Commit message (Collapse)AuthorAgeFilesLines
* Remove old versionadded and versionchangedFederico Caselli2023-04-121-8/+0
| | | | | | | Removed versionadded and versionchanged for version prior to 1.2 since they are no longer useful. Change-Id: I5c53d1188bc5fec3ab4be39ef761650ed8fa6d3e
* locate automap base in hierarchy directlyMike Bayer2023-02-241-5/+15
| | | | | | | | | | | | 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
* Unify doc typingHarry Lees2023-01-311-10/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ### Description <!-- Describe your changes in detail --> Fixes #9168 This PR replaces common occurrences of [PEP 585](https://peps.python.org/pep-0585/) style type annotations with annotations compatible with older versions of Python. I searched for instances of the following supported types from the PEP and replaced with their legacy typing couterparts. * tuple # typing.Tuple * list # typing.List * dict # typing.Dict * set # typing.Set * frozenset # typing.FrozenSet * type # typing.Type ``` grep -r "list\[.*\]" ./build --exclude-dir="./build/venv/*" --exclude-dir="./build/output/*" --exclude="changelog_[0-9]*\.rst" ``` I excluded changelog files from being altered, I think some of these could be changed if necessary but others are likely to require manual checking as the change may target the new typing style specifically. For any examples that included imports, I tried to ensure that the correct typing imports were included and properly ordered. ### 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: - [x] 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. Closes: #9198 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9198 Pull-request-sha: 05ad4651b57c6275b29433e5e76e166344ba6c4c Change-Id: I41b93b3dee85f9fe00cfbb3d3eb011212795de29
* add hooks/docs for automap w/ multiple schemasMike Bayer2023-01-261-40/+284
| | | | | | | | | | | 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
* happy new year 2023Mike Bayer2023-01-031-1/+1
| | | | Change-Id: I625af65b3fb1815b1af17dc2ef47dd697fdc3fb1
* Type annotations for sqlalchemy.ext.automapGleb Kisenkov2022-12-051-57/+239
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An attempt to annotate `lib/sqlalchemy/ext/automap.py` with type hints (issue [#6810](https://github.com/sqlalchemy/sqlalchemy/issues/6810#issuecomment-1127062951)). More info on how I approach it could be found in [the earlier PR](https://github.com/sqlalchemy/sqlalchemy/pull/8775). 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. - [x] 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: #8874 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8874 Pull-request-sha: 834d58d77c2cfd09ea874f01eb7b75a2ea0db7cd Change-Id: Ie64b2be7a51ddc83ef8f23385fb63db5b5c1bc17
* Try running pyupgrade on the codeFederico Caselli2022-11-161-3/+3
| | | | | | | | 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
* rework ORM mapping docsMike Bayer2022-06-211-2/+12
| | | | | | | | | | prepare docs for newly incoming mapper styles, including new dataclass mapping. move the existing dataclass/attrs docs all into their own section and try to improve organization and wording into the relatively recent "mapping styles" document. Change-Id: I0b5e2a5b6a70db65ab19b5bb0a2bb7df20e0b498
* Remove reflect=True in Base.prepare examplesGord Thompson2022-06-141-8/+8
| | | | Change-Id: Icdb17fab0f92762a266efbe1a64bec1d5a6dc9ab
* inline mypy config; files ignoring type errors for the momentMike Bayer2022-04-281-0/+1
| | | | | | | | | | | | | | | | | | | to simplify pyproject.toml change the remaining files that aren't going to be typed on this first pass (unless of course someone wants to type some of these) to include # mypy: ignore-errors. for the moment, only a handful of ORM modules are to have more type checking implemented. It's important that ignore-errors is used and not "# type: ignore", as in the latter case, mypy doesn't even read the existing types in the file, which makes it impossible to type any files that refer to those modules at all. to simplify ongoing typing work use inline mypy config for remaining files that are "done" for now, indicating the level of type checking they currently have. Change-Id: I98669c1a305c2f0adba85d10b5425541f3fe9533
* Add missing query before trying to print (#7665)Mike Knudson2022-02-231-0/+1
| | | The documentation had a print before a query was run.
* happy new year 2022Mike Bayer2022-01-061-1/+1
| | | | Change-Id: I49abf2607e0eb0623650efdf0091b1fb3db737ea
* Update Black's target-version to py37Hugo van Kemenade2022-01-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | <!-- 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
* Remove object in class definitionFederico Caselli2021-11-221-1/+1
| | | | | References: #4600 Change-Id: I2a62ddfe00bc562720f0eae700a497495d7a987a
* Replace all http:// links to https://Federico Caselli2021-07-041-2/+2
| | | | | | Also replace http://pypi.python.org/pypi with https://pypi.org/project Change-Id: I84b5005c39969a82140706472989f2a30b0c7685
* have automap suppress overlaps warning for mapped secondaryMike Bayer2021-06-251-0/+9
| | | | | | | | | | | | | | | | 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
* Removed automap deprecation warningjason3gb2021-05-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed a deprecation warning that was emitted when using :func:`_automap.automap_base` without passing an existing ``Base``. Fixes: #6529 <!-- Provide a general summary of your proposed changes in the Title field above --> ### Description Fixed the automap's declarative import from sqlalchemy.orm instead from the deprecated ext.declarative package ### 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 - [x] 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: #6533 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6533 Pull-request-sha: 46d40005eae51fd7423da66f6ad4072f65744c1c Change-Id: I432df70d4221873ca229076d5d3ac20b2870c13b
* Add reflection_options to automapbase.prepare()Gord Thompson2021-02-251-2/+12
| | | | | Fixes: #5942 Change-Id: If72ccca93fbe303799b1bacb7339c4c85e4251aa
* happy new yearMike Bayer2021-01-041-1/+1
| | | | Change-Id: Ic5bb19ca8be3cb47c95a0d3315d84cb484bac47c
* Allow MetaData as the target for column_reflect eventMike Bayer2020-11-181-0/+30
| | | | | | | | | The :meth:`_event.DDLEvents.column_reflect` event may now be applied to a :class:`_schema.MetaData` object where it will take effect for the :class:`_schema.Table` objects local to that collection. Fixes: #5712 Change-Id: I6044baa72d096ebd1fd99128270119747d1461b9
* Deprecate bound metadataMike Bayer2020-10-121-6/+47
| | | | | | | | | | | | | | | | | 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
* Build out new declarative systems; deprecate mapper()Mike Bayer2020-09-101-1/+1
| | | | | | | | | | | | | The ORM Declarative system is now unified into the ORM itself, with new import spaces under ``sqlalchemy.orm`` and new kinds of mappings. Support for decorator-based mappings without using a base class, support for classical style-mapper() calls that have access to the declarative class registry for relationships, and full integration of Declarative with 3rd party class attribute systems like ``dataclasses`` and ``attrs`` is now supported. Fixes: #5508 Change-Id: I130b2b6edff6450bfe8a3e6baa099ff04b5471ff
* Run search and replace of symbolic module namesMike Bayer2020-04-141-51/+79
| | | | | | | | Replaces a wide array of Sphinx-relative doc references with an abbreviated absolute form now supported by zzzeeksphinx. Change-Id: I94bffcc3f37885ffdde6238767224296339698a2
* Merge "Use context managers for threading.Lock()"mike bayer2020-01-031-4/+1
|\
| * Use context managers for threading.Lock()Heckad2020-01-031-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | (zzzeek:) For some reason I thought that threading.Lock() still did not support context managers, at least in Python 2, however this does not seem to be the case. Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Closes: #5069 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5069 Pull-request-sha: efeac06dda5afdbe33abcf9b27c8b5b5725c8444 Change-Id: Ic64fcd99cd587bc70b4ecc5b45d8205b5c76eff2
* | happy new yearMike Bayer2020-01-011-1/+1
|/ | | | Change-Id: I08440dc25e40ea1ccea1778f6ee9e28a00808235
* Add informative failure modes to _DeferredMapperConfigMike Bayer2019-01-301-0/+11
| | | | | | | | | | | 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
* Fix many spell glitchesLele Gaifax2019-01-251-2/+2
| | | | | | | | | | | | This affects mostly docstrings, except in orm/events.py::dispose_collection() where one parameter gets renamed: given that the method is empty, it seemed reasonable to me to fix that too. Closes: #4440 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4440 Pull-request-sha: 779ed75acb6142e1f1daac467b5b14134529bb4b Change-Id: Ic0553fe97853054b09c2453af76d96363de6eb0e
* happy new yearMike Bayer2019-01-111-1/+1
| | | | Change-Id: I6a71f4924d046cf306961c58dffccf21e9c03911
* Post black reformattingMike Bayer2019-01-061-5/+7
| | | | | | | | | | | | | 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-134/+175
| | | | | | | | | | | | | | 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-42/+48
| | | | | | | | | | | | 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
* happy new yearMike Bayer2018-01-121-1/+1
| | | | Change-Id: I3ef36bfd0cb0ba62b3123c8cf92370a43156cf8f
* Include missing import in exampleMichael Stewart2017-06-301-0/+1
|
* Protect against cls weakref becoming NoneMike Bayer2017-05-081-2/+2
| | | | | | | | | | Protected against testing "None" as a class in the case where declarative classes are being garbage collected and new automap prepare() operations are taking place concurrently, very infrequently hitting a weakref that has not been fully acted upon after gc. Change-Id: I32e1dfc5ac46bac4127fe808cfd18368e2fad9dd
* New features from python 2.7Катаев Денис2017-03-171-1/+1
| | | | | | | After bump minimum supported version to 2.7 (1da9d3752160430c91534a8868ceb8c5ad1451d4), we can use new syntax. Change-Id: Ib064c75a00562e641d132f9c57e5e69744200e05 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/347
* - add missing param tagMike Bayer2017-01-281-3/+3
| | | | Change-Id: Ic2cc0bdafbf3f1bc2993a9ad3475530eed91d0f1
* - repair an errant docstring w/o rMike Bayer2017-01-171-2/+2
| | | | Change-Id: I2e9c8dbc79c00b54520748d1d7cae5230a612c96
* Support python3.6Mike Bayer2017-01-131-2/+2
| | | | | | | | | | | Corrects some warnings and adds tox config. Adds DeprecationWarning to the error category. Large sweep for string literals w/ backslashes as this is common in docstrings Co-authored-by: Andrii Soldatenko Fixes: #3886 Change-Id: Ia7c838dfbbe70b262622ed0803d581edc736e085 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/337
* update for 2017 copyrightMike Bayer2017-01-041-1/+1
| | | | Change-Id: I4e8c2aa8fe817bb2af8707410fa0201f938781de
* Add schema argument to AutomapBase.prepare()Josh Marlow2016-06-021-0/+10
| | | | | | | | | 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
* Convert readthedocs link for their .org -> .io migration for hosted projectspr/278Adam Chainz2016-05-291-1/+1
| | | | | | | | As per their email ‘Changes to project subdomains’: > Starting today, Read the Docs will start hosting projects from subdomains on the domain readthedocs.io, instead of on readthedocs.org. This change addresses some security concerns around site cookies while hosting user generated data on the same domain as our dashboard. Test Plan: Manually visited all the links I’ve modified.
* - happy new yearMike Bayer2016-01-291-1/+1
|
* - fix link to types in metadata, fixes #3618Mike Bayer2016-01-101-1/+1
| | | | | | - fix "version" got whacked into "f" in core tutorial - fix short underline in automap - fix unmatched boldface in session events
* fix typo: Explcitly -> ExplicitlySven Schliesing2015-11-101-1/+1
|
* Fix code examples in automap's documentationpr/185Yuri Baida2015-06-261-5/+4
| | | Fix camelize_classname and pluralize_collection functions as they didn't work as expected.
* - automap is stableMike Bayer2015-06-181-6/+0
|
* - fix typo MANYTOONE -> MANYTOMANY, fixes #3415Mike Bayer2015-05-051-1/+1
|
* - add boldface for "viable" plus a note describing that thisMike Bayer2015-04-291-1/+7
| | | | refers to the table having a primary key. fixes #3398
* - copyright 2015Mike Bayer2015-03-101-1/+1
|