summaryrefslogtreecommitdiff
path: root/test/orm/test_dataclasses_py3k.py
Commit message (Collapse)AuthorAgeFilesLines
* establish mypy / typing approach for v2.0Mike Bayer2022-02-131-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | large patch to get ORM / typing efforts started. this is to support adding new test cases to mypy, support dropping sqlalchemy2-stubs entirely from the test suite, validate major ORM typing reorganization to eliminate the need for the mypy plugin. * New declarative approach which uses annotation introspection, fixes: #7535 * Mapped[] is now at the base of all ORM constructs that find themselves in classes, to support direct typing without plugins * Mypy plugin updated for new typing structures * Mypy test suite broken out into "plugin" tests vs. "plain" tests, and enhanced to better support test structures where we assert that various objects are introspected by the type checker as we expect. as we go forward with typing, we will add new use cases to "plain" where we can assert that types are introspected as we expect. * For typing support, users will be much more exposed to the class names of things. Add these all to "sqlalchemy" import space. * Column(ForeignKey()) no longer needs to be `@declared_attr` if the FK refers to a remote table * composite() attributes mapped to a dataclass no longer need to implement a `__composite_values__()` method * with_variant() accepts multiple dialect names Change-Id: I22797c0be73a8fbbd2d6f5e0c0b7258b17fe145d Fixes: #7535 Fixes: #7551 References: #6810
* First round of removal of python 2Federico Caselli2021-11-011-16/+0
| | | | | References: #4600 Change-Id: I61e35bc93fe95610ae75b31c18a3282558cd4ffe
* Modernize tests - session_query_getGord Thompson2021-10-281-2/+2
| | | | | Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Change-Id: I92013aad471baf32df1b51b756e86d95449b5cfd
* Modernize tests - calling_mapper_directlyGord Thompson2021-09-301-4/+5
| | | | | | | | | | | | | a few changes for py2k: * map_imperatively() includes the check that a class is being sent, this was only working for mapper() before * the test suite didn't place the py2k "autouse" workaround in the correct order, seemingly, tried to adjust the per-test ordering setup in pytestplugin.py Change-Id: I4cc39630724e810953cfda7b2afdadc8b948e3c2
* implement declared_attr superclass assignment check for dataclassesMike Bayer2021-04-231-13/+86
| | | | | | | | | | | | | | | | | Adjusted the declarative scan for dataclasses so that the inheritance behavior of :func:`_orm.declared_attr` established on a mixin, when using the new form of having it inside of a ``dataclasses.field()`` construct and not actually a descriptor attribute on the class, correctly accommodates the case when the target class to be mapped is a subclass of an existing mapped class which has already mapped that :func:`_orm.declared_attr`, and therefore should not be re-applied to this class. Also, as changed in ed3f2c617239668d we now have an "is_dataclass" boolean set as we iterate through attrs so we can remove this from declared_attr. Fixes: #6346 Change-Id: Iec75bdefd3bff7d8a9a157c8dd744ac14ff15ea8
* support callable mapped attributes in dataclass mixinsMike Bayer2021-03-191-0/+238
| | | | | | | | Added support for the :class:`_orm.declared_attr` object to work in the context of dataclass fields. Fixes: #6100 Change-Id: Ifaf4a6482c866d6cfee99d8bc2c6294d923460d7
* Adjust dataclass rules to account for field w/ defaultMike Bayer2021-03-181-1/+116
| | | | | | | | | | Fixed issue in new ORM dataclasses functionality where dataclass fields on an abstract base or mixin that contained column or other mapping constructs would not be mapped if they also included a "default" key within the dataclasses.field() object. Fixes: #6093 Change-Id: I628086ceb48ab1dd0702f239cd12be74074f58f1
* Fill-out dataclass-related attr resolutionMike Bayer2021-01-251-7/+226
| | | | | | | | | Fixed issue where mixin attribute rules were not taking effect correctly for attributes pulled from dataclasses using the approach added in #5745. Fixes: #5876 Change-Id: I45099a42de1d9611791e72250fe0edc69bed684c
* Allow Declarative to extract class attr from fieldMike Bayer2020-12-191-0/+96
| | | | | | | | | | Added an alternate resolution scheme to Declarative that will extract the SQLAlchemy column or mapped property from the "metadata" dictionary of a dataclasses.Field object. This allows full declarative mappings to be combined with dataclass fields. Fixes: #5745 Change-Id: I1165bc025246a4cb9fc099b1b7c46a6b0f799b23
* upgrade to black 20.8b1Mike Bayer2020-09-281-2/+5
| | | | | | | It's better, the majority of these changes look more readable to me. also found some docstrings that had formatting / quoting issues. Change-Id: I582a45fde3a5648b2f36bab96bad56881321899b
* Build out new declarative systems; deprecate mapper()Mike Bayer2020-09-101-0/+60
| | | | | | | | | | | | | 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
* Add support for classical mapping of dataclassesVáclav Klusák2020-09-011-0/+227
Added support for direct mapping of Python classes that are defined using the Python ``dataclasses`` decorator. See the section :ref:`mapping_dataclasses` for background. Pull request courtesy Václav Klusák. Fixes: #5027 Closes: #5516 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5516 Pull-request-sha: bb48c63d1561ca48c954ad9f84a3eb2646571115 Change-Id: Ie33db2aae4adeeb5d99633fe926b9c30bab0b885