summaryrefslogtreecommitdiff
path: root/test/ext/declarative
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2022-01-24 17:04:27 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2022-02-13 14:23:04 -0500
commite545298e35ea9f126054b337e4b5ba01988b29f7 (patch)
treee64aea159111d5921ff01f08b1c4efb667249dfe /test/ext/declarative
parentf1da1623b800cd4de3b71fd1b2ad5ccfde286780 (diff)
downloadsqlalchemy-e545298e35ea9f126054b337e4b5ba01988b29f7.tar.gz
establish mypy / typing approach for v2.0
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
Diffstat (limited to 'test/ext/declarative')
-rw-r--r--test/ext/declarative/test_inheritance.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/test/ext/declarative/test_inheritance.py b/test/ext/declarative/test_inheritance.py
index 64c32c76b..a695aadba 100644
--- a/test/ext/declarative/test_inheritance.py
+++ b/test/ext/declarative/test_inheritance.py
@@ -547,9 +547,9 @@ class ConcreteInhTest(
configure_mappers()
self.assert_compile(
select(Employee),
- "SELECT pjoin.name, pjoin.employee_id, pjoin.type, pjoin._type "
- "FROM (SELECT manager.name AS name, manager.employee_id AS "
- "employee_id, manager.type AS type, 'manager' AS _type "
+ "SELECT pjoin.employee_id, pjoin.type, pjoin.name, pjoin._type "
+ "FROM (SELECT manager.employee_id AS employee_id, "
+ "manager.type AS type, manager.name AS name, 'manager' AS _type "
"FROM manager) AS pjoin",
)
@@ -859,13 +859,13 @@ class ConcreteExtensionConfigTest(
session = Session()
self.assert_compile(
session.query(Document),
- "SELECT pjoin.doctype AS pjoin_doctype, "
- "pjoin.send_method AS pjoin_send_method, "
- "pjoin.id AS pjoin_id, pjoin.type AS pjoin_type "
- "FROM (SELECT actual_documents.doctype AS doctype, "
+ "SELECT pjoin.id AS pjoin_id, pjoin.send_method AS "
+ "pjoin_send_method, pjoin.doctype AS pjoin_doctype, "
+ "pjoin.type AS pjoin_type FROM "
+ "(SELECT actual_documents.id AS id, "
"actual_documents.send_method AS send_method, "
- "actual_documents.id AS id, 'actual' AS type "
- "FROM actual_documents) AS pjoin",
+ "actual_documents.doctype AS doctype, "
+ "'actual' AS type FROM actual_documents) AS pjoin",
)
def test_column_attr_names(self):
@@ -886,14 +886,14 @@ class ConcreteExtensionConfigTest(
session.query(Document),
"SELECT pjoin.documenttype AS pjoin_documenttype, "
"pjoin.id AS pjoin_id, pjoin.type AS pjoin_type FROM "
- "(SELECT offers.documenttype AS documenttype, offers.id AS id, "
+ "(SELECT offers.id AS id, offers.documenttype AS documenttype, "
"'offer' AS type FROM offers) AS pjoin",
)
self.assert_compile(
session.query(Document.documentType),
"SELECT pjoin.documenttype AS pjoin_documenttype FROM "
- "(SELECT offers.documenttype AS documenttype, offers.id AS id, "
+ "(SELECT offers.id AS id, offers.documenttype AS documenttype, "
"'offer' AS type FROM offers) AS pjoin",
)