]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
2 years agoPosponed annotations
Gleb Kisenkov [Thu, 8 Dec 2022 02:00:45 +0000 (03:00 +0100)] 
Posponed annotations

2 years agoPublic API covered
Gleb Kisenkov [Wed, 7 Dec 2022 07:48:30 +0000 (08:48 +0100)] 
Public API covered

The whole module needs to be refined in the future. Especially addressing the internal types.

2 years agoMerge branch 'main' into issue_6810_type_annotate_sqlalchemy.ext.horizontal_shard
Gleb Kisenkov [Mon, 5 Dec 2022 21:39:05 +0000 (22:39 +0100)] 
Merge branch 'main' into issue_6810_type_annotate_sqlalchemy.ext.horizontal_shard

2 years agoTransient commit
Gleb Kisenkov [Mon, 5 Dec 2022 21:36:34 +0000 (22:36 +0100)] 
Transient commit

Some type annotation fixes

2 years agoMerge "Add compatibility properties to Range; implement pep-484" into main
mike bayer [Mon, 5 Dec 2022 19:32:15 +0000 (19:32 +0000)] 
Merge "Add compatibility properties to Range; implement pep-484" into main

2 years agoAdd compatibility properties to Range; implement pep-484
Lele Gaifax [Mon, 5 Dec 2022 01:51:13 +0000 (20:51 -0500)] 
Add compatibility properties to Range; implement pep-484

This adds a bunch of properties to new PG Range class for compatibility
with other implementations, providing a more similar API to access
emptiness and bounds status.

The naming conventions here derive from PostgreSQL itself,
see https://www.postgresql.org/docs/9.3/functions-range.html .

pep-484 also implemented by Mike, as this is a pretty type-intensive
module.

Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Closes: #8927
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8927
Pull-request-sha: 8b9e7b7e3345673b43aeabd7ec88b88dc3cfa7eb

Change-Id: I0b1d49311517ee1cc1377a974ed0a860ea5756e4

2 years agoMerge "Rewrite positional handling, test for "numeric"" into main
mike bayer [Mon, 5 Dec 2022 16:29:52 +0000 (16:29 +0000)] 
Merge "Rewrite positional handling, test for "numeric"" into main

2 years agoRewrite positional handling, test for "numeric"
Federico Caselli [Fri, 2 Dec 2022 16:58:40 +0000 (11:58 -0500)] 
Rewrite positional handling, test for "numeric"

Changed how the positional compilation is performed. It's rendered by the compiler
the same as the pyformat compilation. The string is then processed to replace
the placeholders with the correct ones, and to obtain the correct order of the
parameters.
This vastly simplifies the computation of the order of the parameters, that in
case of nested CTE is very hard to compute correctly.

Reworked how numeric paramstyle behavers:
- added support for repeated parameter, without duplicating them like in normal
positional dialects
- implement insertmany support. This requires that the dialect supports out of
order placehoders, since all parameters that are not part of the VALUES clauses
are placed at the beginning of the parameter tuple
- support for different identifiers for a numeric parameter. It's for example
possible to use postgresql style placeholder $1, $2, etc

Added two new dialect based on sqlite to test "numeric" fully using
both :1 style and $1 style. Includes a workaround for SQLite's
not-really-correct numeric implementation.

Changed parmstyle of asyncpg dialect to use numeric, rendering with its native
$ identifiers

Fixes: #8926
Fixes: #8849
Change-Id: I7c640467d49adfe6d795cc84296fc7403dcad4d6

2 years agoType annotations for sqlalchemy.ext.automap
Gleb Kisenkov [Mon, 5 Dec 2022 13:45:25 +0000 (08:45 -0500)] 
Type annotations for sqlalchemy.ext.automap

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

2 years agoMerge "adjustments for unreliable gc" into main
mike bayer [Mon, 5 Dec 2022 14:01:12 +0000 (14:01 +0000)] 
Merge "adjustments for unreliable gc" into main

2 years agoMerge "Fixed an invalid syntax in an except statement" into main
mike bayer [Mon, 5 Dec 2022 13:54:51 +0000 (13:54 +0000)] 
Merge "Fixed an invalid syntax in an except statement" into main

2 years agoMerge "Fix grammar (whatsnew_20.rst)" into main
mike bayer [Mon, 5 Dec 2022 13:54:37 +0000 (13:54 +0000)] 
Merge "Fix grammar (whatsnew_20.rst)" into main

2 years agoFixed an invalid syntax in an except statement
wiseaidev [Mon, 5 Dec 2022 13:44:35 +0000 (08:44 -0500)] 
Fixed an invalid syntax in an except statement

### Description

As the title suggests, I have fixed an invalid syntax in the docs for an `except` statement while reading the unusual.

### 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.

**Have a nice day!**

Closes: #8715
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8715
Pull-request-sha: e8be2bc4a5401ab2a5a0fc1d2e50d41fa437ae80

Change-Id: If8512bf1853f7cdb1ae655f0945cd922fff6fbce

2 years agodoc change - Add new external dialect for openGauss
j00356287 [Mon, 5 Dec 2022 13:44:09 +0000 (08:44 -0500)] 
doc change - Add new external dialect for openGauss

<!-- Provide a general summary of your proposed changes in the Title field above -->

### Description
<!-- Describe your changes in detail -->
Added new external dialect for [openGauss](https://www.opengauss.org/en/).

### 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.

**Have a nice day!**

Closes: #8803
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8803
Pull-request-sha: ca5a7f1310b2ce93ce33618e0609abe23b41a3da

Change-Id: Ia8ca38f98f346fa3cc910ceb7af47f8c903eb587

2 years agoFix grammar (whatsnew_20.rst)
Sam Bull [Mon, 5 Dec 2022 13:43:50 +0000 (08:43 -0500)] 
Fix grammar (whatsnew_20.rst)

None

Closes: #8835
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8835
Pull-request-sha: 7488c752d90ce305076ba06b7a4077dc67c0ea66

Change-Id: Iad959dcff21bd1aa593793c4a38cb795529468e8

2 years agoadjustments for unreliable gc
Mike Bayer [Mon, 5 Dec 2022 04:25:14 +0000 (23:25 -0500)] 
adjustments for unreliable gc

sporadic (and at the moment persistent) test failures
related to aiosqlite seem to have in common that Python
gc stops working fully when we run a lot of tests with
aiosqlite.  The failures are not limited to aiosqlite
as they are more involving places where we assume or
expect gc.collect() to get rid of things, and it doesn't.

Identify (based on reproducible case on the d3 CI runner)
the spots where this happens and add fixes.

test/orm/test_transaction.py test_gced_delete_on_rollback
has always been a very sensitive test with a lot of issues,
so here we move it to the test_memusage suite and limit
it only to when the memusage suite is running.

Change-Id: I683412d0effe8732c45980b40722e5bb63431177

2 years agoMerge "disallow same-named columns, unchecked replacement in Table" into main
mike bayer [Sun, 4 Dec 2022 17:25:44 +0000 (17:25 +0000)] 
Merge "disallow same-named columns, unchecked replacement in Table" into main

2 years agodisallow same-named columns, unchecked replacement in Table
Mike Bayer [Sat, 3 Dec 2022 14:11:14 +0000 (09:11 -0500)] 
disallow same-named columns, unchecked replacement in Table

Fixed issue where table reflection using :paramref:`.Table.extend_existing`
would fail to deduplicate a same-named column if the existing
:class:`.Table` used a separate key. The
:paramref:`.Table.autoload_replace` parameter would allow the column to be
skipped but under no circumstances should a :class:`.Table` ever have the
same-named column twice.

Additionally, changed deprecation warnings to exceptions
as were implemented in I1d58c8ebe081079cb669e7ead60886ffc1b1a7f5 .

Fixes: #8925
Change-Id: I83d0f8658177a7ffbb06e01dbca91377d1a98d49

2 years agoMerge "Order_by and group_by accept labels" into main
mike bayer [Sun, 4 Dec 2022 15:00:46 +0000 (15:00 +0000)] 
Merge "Order_by and group_by accept labels" into main

2 years agoSome test pipeline updates
Federico Caselli [Thu, 1 Dec 2022 21:29:50 +0000 (22:29 +0100)] 
Some test pipeline updates

Add back pypy, python 3.12

Change-Id: Ie3b3b890d75b3939b3d5f684ec7eadadfe06a5ea

2 years agoOrder_by and group_by accept labels
Federico Caselli [Sat, 3 Dec 2022 16:39:55 +0000 (17:39 +0100)] 
Order_by and group_by accept labels

Improve typing to accept labels in ordey_by mand group_by.

Change-Id: I33e5d6f64633d39a220108d412ef84d6478b25e6

2 years agoCollected runtime types
Gleb Kisenkov [Sat, 3 Dec 2022 09:56:08 +0000 (10:56 +0100)] 
Collected runtime types

2 years agoadd spaces, leading underscore to oracle checks
Mike Bayer [Fri, 2 Dec 2022 22:00:10 +0000 (17:00 -0500)] 
add spaces, leading underscore to oracle checks

Expand the test suite from #8708 which unfortunately did
not exercise the bound parameter codepaths completely.

Continued fixes for Oracle fix :ticket:`8708` released in 1.4.43 where
bound parameter names that start with underscores, which are disallowed by
Oracle, were still not being properly escaped in all circumstances.

Fixes: #8708
Change-Id: Ic389c09bd7c53b773e5de35f1a18ef20769b92a7

2 years agoadd backports for 2.0/ 1.4 changes
Mike Bayer [Fri, 2 Dec 2022 21:36:42 +0000 (16:36 -0500)] 
add backports for 2.0/ 1.4 changes

Change-Id: I5aab8b25337f67385fc998954ab1fa883c175cc2

2 years agoMerge "Fix positional compiling bugs" into main
mike bayer [Fri, 2 Dec 2022 14:31:17 +0000 (14:31 +0000)] 
Merge "Fix positional compiling bugs" into main

2 years agoMerge "disable setinputsizes only for true DBAPI executemany" into main
mike bayer [Fri, 2 Dec 2022 14:09:05 +0000 (14:09 +0000)] 
Merge "disable setinputsizes only for true DBAPI executemany" into main

2 years agoFix positional compiling bugs
Federico Caselli [Sat, 19 Nov 2022 19:39:10 +0000 (20:39 +0100)] 
Fix positional compiling bugs

Fixed a series of issues regarding positionally rendered bound parameters,
such as those used for SQLite, asyncpg, MySQL and others. Some compiled
forms would not maintain the order of parameters correctly, such as the
PostgreSQL ``regexp_replace()`` function as well as within the "nesting"
feature of the :class:`.CTE` construct first introduced in :ticket:`4123`.

Fixes: #8827
Change-Id: I9813ed7c358cc5c1e26725c48df546b209a442cb

2 years agoMerge "add new pattern for single inh column override" into main
mike bayer [Thu, 1 Dec 2022 21:41:21 +0000 (21:41 +0000)] 
Merge "add new pattern for single inh column override" into main

2 years agodisable setinputsizes only for true DBAPI executemany
Mike Bayer [Thu, 1 Dec 2022 21:03:58 +0000 (16:03 -0500)] 
disable setinputsizes only for true DBAPI executemany

Fixed regression caused by the combination of :ticket:`8177`, re-enable
setinputsizes for SQL server unless fast_executemany + DBAPI executemany is
used for a statement, along with :ticket:`6047`, implement
"insertmanyvalues", which bypasses DBAPI executemany in place of a custom
DBAPI execute for INSERT statements. setinputsizes would incorrectly not be
used for a multiple parameter-set INSERT statement that used
"insertmanyvalues" if fast_executemany were turned on, as the check would
incorrectly assume this is a DBAPI executemany call.  The "regression"
would then be that the "insertmanyvalues" statement format is apparently
slightly more sensitive to multiple rows that don't use the same types
for each row, so in such a case setinputsizes is especially needed.

The fix repairs the fast_executemany check so that it only disables
setinputsizes if true DBAPI executemany is to be used.

Fixes: #8917
Change-Id: I78895606a99848d4f92ecf38ded92dc5d6d48c6f

2 years agoget aiosqlite to run on python 3 but not 3.11, attempt 2
Mike Bayer [Thu, 1 Dec 2022 00:41:15 +0000 (19:41 -0500)] 
get aiosqlite to run on python 3 but not 3.11, attempt 2

Change-Id: Iee0077f8c662da59ee63fa73296cb04ab1b09551

2 years agouse python 3.11 current, dont use aiosqlite on py311
Mike Bayer [Wed, 30 Nov 2022 23:57:07 +0000 (18:57 -0500)] 
use python 3.11 current, dont use aiosqlite on py311

Py 3.11 is released so I assume we can remove "rc" qualifiers
here

aiosqlite is causing python 3.11 crashes, so I assume this is
due to https://github.com/python/cpython/issues/99205.

I'm only guessing the syntax here, so there may be subsequent
commits if this doesnt work

Change-Id: I6f2ead3e0aca933a972efadf3891edbcdd83501c

2 years agoadd new pattern for single inh column override
Mike Bayer [Thu, 17 Nov 2022 17:03:46 +0000 (12:03 -0500)] 
add new pattern for single inh column override

Added a new parameter :paramref:`_orm.mapped_column.use_existing_column` to
accommodate the use case of a single-table inheritance mapping that uses
the pattern of more than one subclass indicating the same column to take
place on the superclass. This pattern was previously possible by using
:func:`_orm.declared_attr` in conjunction with locating the existing column
in the ``.__table__`` of the superclass, however is now updated to work
with :func:`_orm.mapped_column` as well as with pep-484 typing, in a
simple and succinct way.

Fixes: #8822
Change-Id: I2296a4a775da976c642c86567852cdc792610eaf

2 years agoMerge "[sqlite] Reflect DEFERRABLE and INITIALLY options for foreign keys" into main
mike bayer [Wed, 30 Nov 2022 22:36:22 +0000 (22:36 +0000)] 
Merge "[sqlite] Reflect DEFERRABLE and INITIALLY options for foreign keys" into main

2 years agoAdd "compare" on dataclass fields
Simon Schiele [Wed, 30 Nov 2022 13:40:50 +0000 (08:40 -0500)] 
Add "compare" on dataclass fields

Added :paramref:`_orm.mapped_column.compare` parameter to relevant ORM
attribute constructs including :func:`_orm.mapped_column`,
:func:`_orm.relationship` etc. to provide for the Python dataclasses
``compare`` parameter on ``field()``, when using the
:ref:`orm_declarative_native_dataclasses` feature. Pull request courtesy
Simon Schiele.

Added an additional case for associationproxy into
test_dc_transforms.py -> test_attribute_options

Fixes: #8905
Closes: #8906
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8906
Pull-request-sha: ea9a53d2ca60befdd0c570013c0e57a78c11dd4a

Change-Id: I390d043b06c1d668242325ef86e2f7b7dbfac442

2 years ago[sqlite] Reflect DEFERRABLE and INITIALLY options for foreign keys
Michael Gorven [Tue, 29 Nov 2022 23:36:19 +0000 (18:36 -0500)] 
[sqlite] Reflect DEFERRABLE and INITIALLY options for foreign keys

Added support for the SQLite backend to reflect the "DEFERRABLE" and
"INITIALLY" keywords which may be present on a foreign key construct. Pull
request courtesy Michael Gorven.

Fixes: #8903
Closes: #8904
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8904
Pull-request-sha: 52aa4cf77482c4051899e21bea75b9830e4c3efa

Change-Id: I713906db1a458d8f1be39625841ca3bbc03ec835

2 years agoMerge "Improve support for enum in mapped classes" into main
mike bayer [Wed, 30 Nov 2022 16:35:41 +0000 (16:35 +0000)] 
Merge "Improve support for enum in mapped classes" into main

2 years agoMerge "annotated / DC forms for association proxy" into main
mike bayer [Wed, 30 Nov 2022 14:04:34 +0000 (14:04 +0000)] 
Merge "annotated / DC forms for association proxy" into main

2 years agoannotated / DC forms for association proxy
Mike Bayer [Fri, 25 Nov 2022 19:29:30 +0000 (14:29 -0500)] 
annotated / DC forms for association proxy

Added support for the :func:`.association_proxy` extension function to
take part within Python ``dataclasses`` configuration, when using
the native dataclasses feature described at
:ref:`orm_declarative_native_dataclasses`.  Included are attribute-level
arguments including :paramref:`.association_proxy.init` and
:paramref:`.association_proxy.default_factory`.

Documentation for association proxy has also been updated to use
"Annotated Declarative Table" forms within examples, including type
annotations used for :class:`.AssocationProxy` itself.

Also modernized documentation examples in sqlalchemy.ext.mutable,
which was not up to date even for 1.4 style code.

Corrected typing for relationship(secondary) where "secondary"
accepts a callable (i.e. lambda) as well

Fixes: #8878
Fixes: #8876
Fixes: #8880
Change-Id: Ibd4f3591155a89f915713393e103e61cc072ed57

2 years agoMerge "Add value-level hooks for SQL type detection; apply to Range" into main
mike bayer [Tue, 29 Nov 2022 23:35:16 +0000 (23:35 +0000)] 
Merge "Add value-level hooks for SQL type detection; apply to Range" into main

2 years agoImprove support for enum in mapped classes
Federico Caselli [Sun, 27 Nov 2022 17:11:34 +0000 (18:11 +0100)] 
Improve support for enum in mapped classes

Add a new system by which TypeEngine objects have some
say in how the declarative type registry interprets them.
The Enum datatype is the primary target for this but it is
hoped the system may be useful for other types as well.

Fixes: #8859
Change-Id: I15ac3daee770408b5795746f47c1bbd931b7d26d

2 years agoAdd value-level hooks for SQL type detection; apply to Range
Lele Gaifax [Sun, 27 Nov 2022 16:28:51 +0000 (11:28 -0500)] 
Add value-level hooks for SQL type detection; apply to Range

Added additional type-detection for the new PostgreSQL
:class:`_postgresql.Range` type, where previous cases that allowed the
psycopg2-native range objects to be received directly by the DBAPI without
SQLAlchemy intercepting them stopped working, as we now have our own value
object. The :class:`_postgresql.Range` object has been enhanced such that
SQLAlchemy Core detects it in otherwise ambiguous situations (such as
comparison to dates) and applies appropriate bind handlers. Pull request
courtesy Lele Gaifax.

Fixes: #8884
Closes: #8886
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8886
Pull-request-sha: 6e95e08a30597d3735ab38f2f1a2ccabd968852c

Change-Id: I3ca277c826dcf4b5644f44eb251345b439a84ee4

2 years agoupdate for mypy 1.0 dev
Federico Caselli [Sun, 27 Nov 2022 17:11:34 +0000 (18:11 +0100)] 
update for mypy 1.0 dev

As I need dmypy to work without facing [1], I am
running the latest build of mypy which seems so far
to finally not have that issue.

update constructs that latest mypy is being more picky
about, including better typing for the _NONE_NAME
symbol used in constraints (porting those elements
from the Enum patch at
I15ac3daee770408b5795746f47c1bbd931b7d26d)

[1] https://github.com/python/mypy/issues/12744

Change-Id: Ib3f56787fa65ea9bb2e6a0bccc4d99f54c516dad

2 years agoAdd PyAthena Dialect (#8898)
Jason Myers [Tue, 29 Nov 2022 18:12:12 +0000 (12:12 -0600)] 
Add PyAthena Dialect (#8898)

* Add PyAthena Dialect

* Changing order

2 years agoMerge "add partial index predicate to SQLiteDialect.get_indexes() result" into main
mike bayer [Tue, 29 Nov 2022 16:17:47 +0000 (16:17 +0000)] 
Merge "add partial index predicate to SQLiteDialect.get_indexes() result" into main

2 years agoadd partial index predicate to SQLiteDialect.get_indexes() result
Tobias Pfeiffer [Mon, 28 Nov 2022 12:52:31 +0000 (07:52 -0500)] 
add partial index predicate to SQLiteDialect.get_indexes() result

Added support for reflection of expression-oriented WHERE criteria included
in indexes on the SQLite dialect, in a manner similar to that of the
PostgreSQL dialect. Pull request courtesy Tobias Pfeiffer.

Fixes: #8804
Closes: #8806
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8806
Pull-request-sha: 539dfcb372360911b69aed2a804698bb1a2220b1

Change-Id: I0e34d47dbe2b9c1da6fce531363084843e5127a3

2 years agoMerge "identify unresolvable Mapped types" into main
mike bayer [Mon, 28 Nov 2022 19:43:09 +0000 (19:43 +0000)] 
Merge "identify unresolvable Mapped types" into main

2 years agoidentify unresolvable Mapped types
Mike Bayer [Mon, 28 Nov 2022 15:58:49 +0000 (10:58 -0500)] 
identify unresolvable Mapped types

Fixed issue where use of an unknown datatype within a :class:`.Mapped`
annotation for a column-based attribute would silently fail to map the
attribute, rather than reporting an exception; an informative exception
message is now raised.

tighten up iteration of names on mapped classes to more fully
exclude a large number of underscored names, so that we can avoid trying
to look at annotations for them or anything else.  centralize the
"list of names we care about" more fully within _cls_attr_resolver
and base it on underscore conventions we should usually ignore,
with the exception of the few underscore names we want to see.

Fixes: #8888
Change-Id: I3c0a1666579fe67b3c40cc74fa443b6f1de354ce

2 years agoRectify PG Range.__bool__, inverting previous logic
Lele Gaifax [Sun, 27 Nov 2022 19:44:13 +0000 (14:44 -0500)] 
Rectify PG Range.__bool__, inverting previous logic

The boolness of the range was defined to be equal to its emptiness. As this has been identified as a typo rather than the intended, this inverts the logic, to match common Python behaviour as well as how other popular PG drivers do.

Closes: #8885
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8885
Pull-request-sha: 5670cdb920692a62f77b7b6ea312784033de83d9

Change-Id: I6f4a40168b2f037c578e84f7550370411bd42160

2 years agoMerge "improve column targeting issues with query_expression" into main
mike bayer [Sun, 27 Nov 2022 16:36:32 +0000 (16:36 +0000)] 
Merge "improve column targeting issues with query_expression" into main

2 years agoMerge "Add recommendation for URL.create() re: escaping" into main
mike bayer [Sun, 27 Nov 2022 16:32:53 +0000 (16:32 +0000)] 
Merge "Add recommendation for URL.create() re: escaping" into main

2 years agoAdd recommendation for URL.create() re: escaping
Gord Thompson [Thu, 24 Nov 2022 17:38:20 +0000 (10:38 -0700)] 
Add recommendation for URL.create() re: escaping

Let users know that URL.create() can build the
whole connection URL instead of making them
escape things like passwords ad-hoc.

includes some general cleanup of URL docstring
by mike

Change-Id: Ic71bb0201fecf30e1db11e006c269f2d041b5439

2 years agoImplement ScalarValue
Federico Caselli [Tue, 8 Nov 2022 21:12:47 +0000 (22:12 +0100)] 
Implement ScalarValue

Added :class:`_expression.ScalarValues` that can be used as a column
element allowing using :class:`_expression.Values` inside IN clauses
or in conjunction with ``ANY`` or ``ALL`` collection aggregates.
This new class is generated using the method
:meth:`_expression.Values.scalar_values`.
The :class:`_expression.Values` instance is now coerced to a
:class:`_expression.ScalarValues` when used in a ``IN`` or ``NOT IN``
operation.

Fixes: #6289
Change-Id: Iac22487ccb01553684b908e54d01c0687fa739f1

2 years agoadd new variation helper
Mike Bayer [Sat, 26 Nov 2022 16:03:45 +0000 (11:03 -0500)] 
add new variation helper

I'm using a lot of @testing.combinations with either
a boolean True/False, or a series of string names, each indicating
some case to switch on.  I want a descriptive name in the test
run (not True/False) and I don't want to compare strings.

So make a new helper around @combinations that provides an
object interface that has booleans inside of it, prints nicely
in the test output, raises an error if you name the case
incorrectly.

Before:

test/orm/declarative/test_typed_mapping.py::MappedColumnTest::test_separate_name[False-False-both] PASSED
test/orm/declarative/test_typed_mapping.py::MappedColumnTest::test_separate_name[False-False-key] PASSED
test/orm/declarative/test_typed_mapping.py::MappedColumnTest::test_separate_name[False-False-name] PASSED
test/orm/declarative/test_typed_mapping.py::MappedColumnTest::test_separate_name[False-True-both] PASSED
test/orm/declarative/test_typed_mapping.py::MappedColumnTest::test_separate_name[False-True-key] PASSED
test/orm/declarative/test_typed_mapping.py::MappedColumnTest::test_separate_name[False-True-name] PASSED
test/orm/declarative/test_typed_mapping.py::MappedColumnTest::test_separate_name[True-False-both] PASSED
test/orm/declarative/test_typed_mapping.py::MappedColumnTest::test_separate_name[True-False-key] PASSED
test/orm/declarative/test_typed_mapping.py::MappedColumnTest::test_separate_name[True-False-name] PASSED
test/orm/declarative/test_typed_mapping.py::MappedColumnTest::test_separate_name[True-True-both] PASSED
test/orm/declarative/test_typed_mapping.py::MappedColumnTest::test_separate_name[True-True-key] PASSED
test/orm/declarative/test_typed_mapping.py::MappedColumnTest::test_separate_name[True-True-name] PASSED

After:

test/orm/declarative/test_typed_mapping.py::MappedColumnTest::test_separate_name[not_use_add_property-deferred-both] PASSED
test/orm/declarative/test_typed_mapping.py::MappedColumnTest::test_separate_name[not_use_add_property-deferred-key] PASSED
test/orm/declarative/test_typed_mapping.py::MappedColumnTest::test_separate_name[not_use_add_property-deferred-name] PASSED
test/orm/declarative/test_typed_mapping.py::MappedColumnTest::test_separate_name[not_use_add_property-not_deferred-both] PASSED
test/orm/declarative/test_typed_mapping.py::MappedColumnTest::test_separate_name[not_use_add_property-not_deferred-key] PASSED
test/orm/declarative/test_typed_mapping.py::MappedColumnTest::test_separate_name[not_use_add_property-not_deferred-name] PASSED
test/orm/declarative/test_typed_mapping.py::MappedColumnTest::test_separate_name[use_add_property-deferred-both] PASSED
test/orm/declarative/test_typed_mapping.py::MappedColumnTest::test_separate_name[use_add_property-deferred-key] PASSED
test/orm/declarative/test_typed_mapping.py::MappedColumnTest::test_separate_name[use_add_property-deferred-name] PASSED
test/orm/declarative/test_typed_mapping.py::MappedColumnTest::test_separate_name[use_add_property-not_deferred-both] PASSED
test/orm/declarative/test_typed_mapping.py::MappedColumnTest::test_separate_name[use_add_property-not_deferred-key] PASSED
test/orm/declarative/test_typed_mapping.py::MappedColumnTest::test_separate_name[use_add_property-not_deferred-name] PASSED

Change-Id: Idde87632581ee69e0f47360966758583dfd8baab

2 years agoAdd new script to sync test files adding future annotation
Federico Caselli [Sat, 26 Nov 2022 18:24:49 +0000 (19:24 +0100)] 
Add new script to sync test files adding future annotation

Create a new test file test_tm_future_annotations_sync.py that's obtained
from test_tm_future_annotations.py by using the new script sync_test_files.
This files includes the ``from __future__ import annotations``

It also turns out we had some bugs in there and we can also support some
additional typing things

Change-Id: Iac005df206d45a55345d9d88d67a80ce799d449f

2 years agosort for addresess relationship in new merge test
Mike Bayer [Sat, 26 Nov 2022 15:14:02 +0000 (10:14 -0500)] 
sort for addresess relationship in new merge test

saw a random failure under py2 on 1.4, will backport

Change-Id: I3e2b037bf4211be44e28f85f5e51ffdc218eeb5a

2 years agoMerge "assert unique constraints received back" into main
mike bayer [Sat, 26 Nov 2022 02:32:20 +0000 (02:32 +0000)] 
Merge "assert unique constraints received back" into main

2 years agoimprove column targeting issues with query_expression
Mike Bayer [Fri, 25 Nov 2022 21:49:28 +0000 (16:49 -0500)] 
improve column targeting issues with query_expression

Fixed issues in :func:`_orm.with_expression` where expressions that were
composed of columns within a subquery being SELECTed from, or when using
``.from_statement()``, would not render correct SQL **if** the expression
had a label name that matched the attribute which used
:func:`_orm.query_expression`, even when :func:`_orm.query_expression` had
no default expression. For the moment, if the :func:`_orm.query_expression`
**does** have a default expression, that label name is still used for that
default, and an additional label with the same name will be ignored.
Overall, this case is pretty thorny so further adjustments might be
warranted.

Fixes: #8881
Change-Id: Ie939b1470cb2e824717384be65f4cd8edd619942

2 years agoadd "merge" to viewonly cascades; propagate NO_RAISE when merging
Mike Bayer [Wed, 23 Nov 2022 15:58:28 +0000 (10:58 -0500)] 
add "merge" to viewonly cascades; propagate NO_RAISE when merging

Fixed bug where :meth:`_orm.Session.merge` would fail to preserve the
current loaded contents of relationship attributes that were indicated with
the :paramref:`_orm.relationship.viewonly` parameter, thus defeating
strategies that use :meth:`_orm.Session.merge` to pull fully loaded objects
from caches and other similar techniques. In a related change, fixed issue
where an object that contains a loaded relationship that was nonetheless
configured as ``lazy='raise'`` on the mapping would fail when passed to
:meth:`_orm.Session.merge`; checks for "raise" are now suspended within
the merge process assuming the :paramref:`_orm.Session.merge.load`
parameter remains at its default of ``True``.

Overall, this is a behavioral adjustment to a change introduced in the 1.4
series as of :ticket:`4994`, which took "merge" out of the set of cascades
applied by default to "viewonly" relationships. As "viewonly" relationships
aren't persisted under any circumstances, allowing their contents to
transfer during "merge" does not impact the persistence behavior of the
target object. This allows :meth:`_orm.Session.merge` to correctly suit one
of its use cases, that of adding objects to a :class:`.Session` that were
loaded elsewhere, often for the purposes of restoring from a cache.

Fixes: #8862
Change-Id: I8731c7810460e6a71f8bf5e8ded59142b9b02956

2 years agoassert unique constraints received back
Mike Bayer [Thu, 24 Nov 2022 14:52:12 +0000 (09:52 -0500)] 
assert unique constraints received back

in #8867 we can see our existing uq reflection test is
broken, not detecting a failure to detect constraints

Change-Id: Icada02bc0547c5a3d8c471b80a78a2e72f02647d

2 years agoflake8 has very courteously referred us to another pyqca project and closed all comme...
Mike Bayer [Wed, 23 Nov 2022 22:44:30 +0000 (17:44 -0500)] 
flake8 has very courteously referred us to another pyqca project and closed all comments, thank you!  I'll get on that right away

pyqca/flake8-import-order does not seem to have a release or a commit
in the past two years, so while I have created an issue and PR [1] [2],
for now vendor our fork so we can get on with things.

Also fix one issue for flake8 6.0

[1] https://github.com/PyCQA/flake8-import-order/issues/189
[2] https://github.com/PyCQA/flake8-import-order/pull/190

Change-Id: I53045f65b8716cceaf2104fccc1d26f80b398fef
References: https://github.com/PyCQA/flake8/issues/1751

2 years agoimprove docs for event listening with asyncio
Mike Bayer [Wed, 23 Nov 2022 18:08:59 +0000 (13:08 -0500)] 
improve docs for event listening with asyncio

add examples, including how to listen on an async_sessionmaker

Change-Id: I1d68324458c23bc830508c8ebfd3224d434c16a5

2 years agoMerge "ensure implicit_returning is checked on a Table instance" into main
mike bayer [Tue, 22 Nov 2022 23:30:36 +0000 (23:30 +0000)] 
Merge "ensure implicit_returning is checked on a Table instance" into main

2 years agoensure implicit_returning is checked on a Table instance
Mike Bayer [Wed, 16 Nov 2022 17:45:54 +0000 (12:45 -0500)] 
ensure implicit_returning is checked on a Table instance

Fixed regression where flushing a mapped class that's mapped against a
subquery, such as a direct mapping or some forms of concrete table
inheritance, would fail if the :paramref:`_orm.Mapper.eager_defaults`
parameter were used.

mapper.local_table can still be a non-table instance.
correct the check first added in 466ed5b53a3.

Fixes: #8812
Change-Id: I1bb2b83c31b910fbd96fcd3ac43e789b657aebf7

2 years agoMerge "Type annotations for sqlalchemy.ext.mutable" into main
mike bayer [Tue, 22 Nov 2022 16:42:45 +0000 (16:42 +0000)] 
Merge "Type annotations for sqlalchemy.ext.mutable" into main

2 years agoMerge "fix optionalized forms for dict[]" into main
mike bayer [Tue, 22 Nov 2022 16:07:49 +0000 (16:07 +0000)] 
Merge "fix optionalized forms for dict[]" into main

2 years agoType annotations for sqlalchemy.ext.mutable
Gleb Kisenkov [Wed, 16 Nov 2022 15:23:06 +0000 (10:23 -0500)] 
Type annotations for sqlalchemy.ext.mutable

The ``sqlalchemy.ext.mutable`` extension is now fully pep-484 typed. Huge
thanks to Gleb Kisenkov for their efforts on this.

Fixes: #8667
Closes: #8775
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8775
Pull-request-sha: b907888ec67facc12dbdbccd6f2d9cd533b08a50

Change-Id: Id9224e03201e6970b1ec56eb546ece4b2f3e0edd

2 years agofix optionalized forms for dict[]
Mike Bayer [Mon, 21 Nov 2022 14:46:43 +0000 (09:46 -0500)] 
fix optionalized forms for dict[]

Fixed a suite of issues involving :class:`.Mapped` use with dictionary
types, such as ``Mapped[dict[str, str] | None]``, would not be correctly
interpreted in Declarative ORM mappings. Support to correctly
"de-optionalize" this type including for lookup in type_annotation_map has
been fixed.

Fixes: #8777
Change-Id: Iaba90791dea341d00eaff788d40b0a4e48dab02e

2 years agoAdd security warning to serializer extension
Federico Caselli [Mon, 21 Nov 2022 23:07:53 +0000 (00:07 +0100)] 
Add security warning to serializer extension

Change-Id: I5c7c076bc93fc250c05f7996e83359d19d1f3214

2 years agoMerge "Fix inferred type of async_sessionmaker" into main
mike bayer [Mon, 21 Nov 2022 21:24:11 +0000 (21:24 +0000)] 
Merge "Fix inferred type of async_sessionmaker" into main

2 years agoMerge "add common base class for all SQL col expression objects" into main
mike bayer [Mon, 21 Nov 2022 21:23:12 +0000 (21:23 +0000)] 
Merge "add common base class for all SQL col expression objects" into main

2 years agoFix inferred type of async_sessionmaker
Sam Bull [Sun, 20 Nov 2022 00:38:04 +0000 (19:38 -0500)] 
Fix inferred type of async_sessionmaker

Improved the typing for :class:`.sessionmaker` and
:class:`.asyncsessionmaker`, so that the default type of their return value
will be :class:`.Session` or :class:`.AsyncSession`, without the need to
type this explicitly. Previously, Mypy would not automaticaly infer these
return types from its generic base.

As part of this change, arguments for :class:`.Session`,
:class:`.AsyncSession`, :class:`.sessionmaker` and
:class:`.asyncsessionmaker` beyond the initial "bind" argument have been
made keyword-only, which includes parameters that have always been
documented as keyword arguments, such as :paramref:`.Session.autoflush`,
:paramref:`.Session.class_`, etc.

Pull request courtesy Sam Bull.

Closes: #8842
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8842
Pull-request-sha: fa6d1a8468e98b40e12f82ed7ddaddc1fde060ac

Change-Id: Iaaabc4572a87489d61617d970f62b9b50db4fac7

2 years agoadd common base class for all SQL col expression objects
Mike Bayer [Sat, 19 Nov 2022 21:42:22 +0000 (16:42 -0500)] 
add common base class for all SQL col expression objects

Added a new type :class:`.SQLColumnExpression` which may be indicated in
user code to represent any SQL column oriented expression, including both
those based on :class:`.ColumnElement` as well as on ORM
:class:`.QueryableAttribute`. This type is a real class, not an alias, so
can also be used as the foundation for other objects.

Fixes: #8847
Change-Id: I3161bdff1c9f447793fce87864e1774a90cd4146

2 years agofall back to eval() for names that have dots
Mike Bayer [Mon, 21 Nov 2022 13:51:34 +0000 (08:51 -0500)] 
fall back to eval() for names that have dots

Fixed regression in 2.0.0b3 caused by :ticket:`8759` where indicating the
:class:`.Mapped` name using a qualified name such as
``sqlalchemy.orm.Mapped`` would fail to be recognized by Declarative as
indicating the :class:`.Mapped` construct.

Fixes: #8853
Change-Id: Iddb6efaae864d4545e80c54658244670f81ef6cc

2 years agoclarify role of `__allow_unmapped__`
Mike Bayer [Sat, 19 Nov 2022 18:10:31 +0000 (13:10 -0500)] 
clarify role of `__allow_unmapped__`

A different note will be needed in the 1.4 version
of these docs.

Fixes: #8845
Change-Id: I48651c64d511684077c80a317349dd230424b575

2 years agoMerge "Issue #8765: implement missing methods on PG Range" into main
mike bayer [Thu, 17 Nov 2022 14:37:57 +0000 (14:37 +0000)] 
Merge "Issue #8765: implement missing methods on PG Range" into main

2 years agoMerge "Try running pyupgrade on the code" into main
mike bayer [Thu, 17 Nov 2022 14:35:10 +0000 (14:35 +0000)] 
Merge "Try running pyupgrade on the code" into main

2 years agoaccommodate NULL format_type()
Mike Bayer [Thu, 17 Nov 2022 01:11:18 +0000 (20:11 -0500)] 
accommodate NULL format_type()

Made an adjustment to how the PostgreSQL dialect considers column types
when it reflects columns from a table, to accommodate for alternative
backends which may return NULL from the PG ``format_type()`` function.

Fixes: #8748
Change-Id: I6178287aac567210a76afaa5805b825daa7fa4db

2 years agoTry running pyupgrade on the code
Federico Caselli [Thu, 3 Nov 2022 19:52:21 +0000 (20:52 +0100)] 
Try running pyupgrade on the code

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

2 years agoMerge "perf improvements related to corresponding_column (2)" into main
mike bayer [Wed, 16 Nov 2022 00:03:08 +0000 (00:03 +0000)] 
Merge "perf improvements related to corresponding_column (2)" into main

2 years agoMerge "don't invoke fromclause.c when creating an annotated" into main
mike bayer [Wed, 16 Nov 2022 00:01:33 +0000 (00:01 +0000)] 
Merge "don't invoke fromclause.c when creating an annotated" into main

2 years agoIssue #8765: implement missing methods on PG Range
Lele Gaifax [Tue, 15 Nov 2022 20:27:34 +0000 (15:27 -0500)] 
Issue #8765: implement missing methods on PG Range

### Description
This PR implements missing methods on the PG `Range` class, as described by issue #8765.

### Checklist
This pull request is:

- [ ] A documentation / typographical error fix
- [ ] A short code fix
- [x] A new feature implementation

Closes: #8766
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8766
Pull-request-sha: 21c0df86cc0d1502855527e29425fbffc3f45d64

Change-Id: I86fabd966ad1f14a3a86132be741df46965b9aa9

2 years agoperf improvements related to corresponding_column (2)
Mike Bayer [Mon, 14 Nov 2022 02:48:53 +0000 (21:48 -0500)] 
perf improvements related to corresponding_column (2)

commit two of two. this reorganizes ColumnCollection
to build a new index up front that's used to optimize
the corresponding_column() method.

Additional performance enhancements within ORM-enabled SQL statements,
specifically targeting callcounts within the construction of ORM
statements, using combinations of :func:`_orm.aliased` with
:func:`_sql.union` and similar "compound" constructs, in addition to direct
performance improvements to the ``corresponding_column()`` internal method
that is used heavily by the ORM by constructs like :func:`_orm.aliased` and
similar.

Fixes: #8796
Change-Id: I4a76788007d5a802b9a4081e6a0f6e4b52497b50

2 years agodon't invoke fromclause.c when creating an annotated
Mike Bayer [Sun, 13 Nov 2022 16:49:43 +0000 (11:49 -0500)] 
don't invoke fromclause.c when creating an annotated

The ``aliased()`` constructor calls upon ``__clause_element__()``,
which internally annotates a ``FromClause``, like a subquery.
This became expensive as ``AnnotatedFromClause`` has for
many years called upon ``element.c`` so that the full ``.c``
collection is transferred to the Annotated.

Taking this out proved to be challenging. A straight remove
seemed to not break any tests except for the one that
tested the exact condition.  Nevertheless this seemed
"spooky" so I instead moved the get of ``.c`` to be in a
memoized proxy method.   However, that then exposed
a recursion issue related to loader_criteria; so the
source of that behavior, which was an accidental behavioral
artifact, is now made into an explcicit option that
loader_criteria uses directly.

The accidental behavioral artifact in question is still
kind of strange since I was not able to fully trace out
how it works, but the end result is that fixing the
artifact to be "correct" causes loader_criteria, within
the particular test for #7491, creates a select/
subquery structure with a cycle in it, so compilation fails
with recursion overflow.
The "solution" is to cause the artifact to occur in this
case, which is that the ``AnnotatedFromClause`` will have a
different ``.c`` collection than its element, which is a
subquery.  It's not totally clear how a cycle is generated
when this is not done.

This is commit one of two, which goes through
some hoops to make essentially a one-line change.

The next commit will rework ColumnCollection to optimize
the corresponding_column() method significantly.

Fixes: #8796
Change-Id: Id58ae6554db62139462c11a8be7313a3677456ad

2 years agoMerge "Fix relationship.order_by typing" into main
mike bayer [Tue, 15 Nov 2022 18:14:24 +0000 (18:14 +0000)] 
Merge "Fix relationship.order_by typing" into main

2 years agoSmall tutorial rewording 8809/head
Andy Garfield [Tue, 15 Nov 2022 16:28:58 +0000 (11:28 -0500)] 
Small tutorial rewording

The language is this sentence took me a few reads to understand. This is just a rewording.

2 years agoFix relationship.order_by typing
Bryan Forbes [Tue, 15 Nov 2022 14:03:24 +0000 (09:03 -0500)] 
Fix relationship.order_by typing

Fixes: #8776
### Checklist

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.

Closes: #8779
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8779
Pull-request-sha: 2bc64555a1ab662881fdfd1caaabd9d21fbdf531

Change-Id: I52fe6db5ba954a6039836b45f0e89ad96049df03

2 years agoExplicitly state what happens if `order_by` is called more than once. (#8791)
Eitan Mosenkis [Mon, 14 Nov 2022 21:11:15 +0000 (23:11 +0200)] 
Explicitly state what happens if `order_by` is called more than once. (#8791)

* Explicitly state what happens if `order_by` is called more than once.

The existing docs cover how to clear existing `order_by` clauses but don't actually describe the behavior of calling `order_by` multiple times with different clauses.

* Also update Select.order_by.

2 years agoadd informative exception context for literal render
Mike Bayer [Mon, 14 Nov 2022 13:54:56 +0000 (08:54 -0500)] 
add informative exception context for literal render

An informative re-raise is now thrown in the case where any "literal
bindparam" render operation fails, indicating the value itself and
the datatype in use, to assist in debugging when literal params
are being rendered in a statement.

Fixes: #8800
Change-Id: Id658f8b03359312353ddbb0c7563026239579f7b

2 years agoRepair test in 32bit python builds.
Federico Caselli [Sat, 12 Nov 2022 19:15:26 +0000 (20:15 +0100)] 
Repair test in 32bit python builds.

Change-Id: I8287f3e1a975534c8a01a41c9dcc7e5e9f08bb52

2 years agocherry-pick changelog update for 1.4.45
Mike Bayer [Sat, 12 Nov 2022 14:13:38 +0000 (09:13 -0500)] 
cherry-pick changelog update for 1.4.45

2 years agocherry-pick changelog from 1.4.44
Mike Bayer [Sat, 12 Nov 2022 14:13:36 +0000 (09:13 -0500)] 
cherry-pick changelog from 1.4.44

2 years agoport mypy 0.990 fixes changelog from 1.4 to 2.0
Mike Bayer [Sat, 12 Nov 2022 02:13:06 +0000 (21:13 -0500)] 
port mypy 0.990 fixes changelog from 1.4 to 2.0

for 2.0, we fixed for mypy 0.990 in ebb54e80a5a52d0cce4cba1.
In 1.4, we did a smaller version specific to the
test runner in 910504b67c22bfc767e2e47e2.  Since people
run the tests sometimes, include that this was fixed
for the 1.4/2.0 series.

Change-Id: I18b2aa10bd8a128b5aa093af5e219bc987271139

2 years agoMerge "ensure anon_map is passed for most annotated traversals" into main
mike bayer [Fri, 11 Nov 2022 21:30:43 +0000 (21:30 +0000)] 
Merge "ensure anon_map is passed for most annotated traversals" into main

2 years agoMerge "establish consistency for RETURNING column labels" into main
mike bayer [Fri, 11 Nov 2022 21:00:21 +0000 (21:00 +0000)] 
Merge "establish consistency for RETURNING column labels" into main

2 years agoensure anon_map is passed for most annotated traversals
Mike Bayer [Thu, 10 Nov 2022 22:01:58 +0000 (17:01 -0500)] 
ensure anon_map is passed for most annotated traversals

We can cache the annotated cache key for Table, but
for selectables it's not safe, as it fails to pass the
anon_map along and creates many redudant structures in
observed test scenario.  It is likely safe for a
Column that's mapped to a Table also, however this is
not implemented here.   Will have to see if that part
needs adjusting.

Fixed critical memory issue identified in cache key generation, where for
very large and complex ORM statements that make use of lots of ORM aliases
with subqueries, cache key generation could produce excessively large keys
that were orders of magnitude bigger than the statement itself. Much thanks
to Rollo Konig Brock for their very patient, long term help in finally
identifying this issue.

Also within TypeEngine objects, when we generate elements
for instance variables, skip the None elements at least.
this also saves on tuple complexity.

Fixes: #8790
Change-Id: I448ddbfb45ae0a648815be8dad4faad7d1977427

2 years agorepair --disable-asyncio parameter
Mike Bayer [Fri, 11 Nov 2022 14:46:06 +0000 (09:46 -0500)] 
repair --disable-asyncio parameter

Fixed issue where the ``--disable-asyncio`` parameter to the test suite
would fail to not actually run greenlet tests and would also not prevent
the suite from using a "wrapping" greenlet for the whole suite. This
parameter now ensures that no greenlet or asyncio use will occur within the
entire run when set.

Fixes: #8793
Change-Id: I87b510846b2cc24413cd54e7b7136e91aad3c309

2 years agoestablish consistency for RETURNING column labels
Mike Bayer [Mon, 7 Nov 2022 23:40:03 +0000 (18:40 -0500)] 
establish consistency for RETURNING column labels

The RETURNING clause now renders columns using the routine as that of the
:class:`.Select` to generate labels, which will include disambiguating
labels, as well as that a SQL function surrounding a named column will be
labeled using the column name itself. This is a more comprehensive change
than a similar one made for the 1.4 series that adjusted the function label
issue only.

includes 1.4's changelog for the backported version which also
fixes an Oracle issue independently of the 2.0 series.

Fixes: #8770
Change-Id: I2ab078a214a778ffe1720dbd864ae4c105a0691d

2 years agowork around Python 3.11 IntEnum issue; update FastIntFlag
Mike Bayer [Wed, 9 Nov 2022 23:41:54 +0000 (18:41 -0500)] 
work around Python 3.11 IntEnum issue; update FastIntFlag

in [1], Python 3.11 seems to have changed the behavior of
IntEnum.  We didn't notice this because we have our own
workaround class already, but typing did.   Ensure we remain
compatible with IntFlag.

This change also modifies FastIntFlag to no longer use
global symbols; this is unnecessary as we assign FastIntFlag
members explicitly.  Use of ``symbol()`` should probably
be phased out.

[1] https://github.com/python/cpython/issues/99304
Fixes: #8783
Change-Id: I8ae2e871ff1467ae5ca1f63e66b5dae45d4a6c93

2 years agotry to support mypy 0.990
Mike Bayer [Wed, 9 Nov 2022 14:13:44 +0000 (09:13 -0500)] 
try to support mypy 0.990

mypy introduces a crash we need to work around, also
some new rules.  It also has either a behavioral change
regarding how output is rendered in relationship to
files being within sys.path or not, so work around
that for test_mypy_plugin_py3k.py

References: https://github.com/python/mypy/issues/14027
Change-Id: I689c7fe27dc52abee932de9e0fb23b2a2eba76fa

2 years agotest run w/ oracledb on pypi, disable mariadb-connector
Mike Bayer [Tue, 8 Nov 2022 23:29:13 +0000 (18:29 -0500)] 
test run w/ oracledb on pypi, disable mariadb-connector

mariadb is still failing:

https://jira.mariadb.org/projects/CONPY/issues/CONPY-236

Change-Id: I63a82ce8b33acb7f550d509cd6ed0b8e7a2bd56c