]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
3 years agotypo
Mike Bayer [Fri, 21 Jan 2022 01:30:24 +0000 (20:30 -0500)] 
typo

Change-Id: Id3f1a99813be14dbfa721e6b0a6081eca4a90c05

3 years agoMerge "Added support for ``FILESTREAM`` in MSSQL." into main
mike bayer [Fri, 21 Jan 2022 01:26:14 +0000 (01:26 +0000)] 
Merge "Added support for ``FILESTREAM`` in MSSQL." into main

3 years agoMerge "re-enable tests for asyncmy; fix Binary" into main
mike bayer [Fri, 21 Jan 2022 01:26:02 +0000 (01:26 +0000)] 
Merge "re-enable tests for asyncmy; fix Binary" into main

3 years agoMerge "The parameter `as_uuid` of `UUID` now defaults to `True`." into main
mike bayer [Thu, 20 Jan 2022 23:06:00 +0000 (23:06 +0000)] 
Merge "The parameter `as_uuid` of `UUID` now defaults to `True`." into main

3 years agoMerge "repair broken truediv test suite; memusage" into main
mike bayer [Thu, 20 Jan 2022 23:04:24 +0000 (23:04 +0000)] 
Merge "repair broken truediv test suite; memusage" into main

3 years agore-enable tests for asyncmy; fix Binary
Mike Bayer [Thu, 20 Jan 2022 20:21:17 +0000 (15:21 -0500)] 
re-enable tests for asyncmy; fix Binary

Fixed regression in asyncmy dialect caused by :ticket:`7567` where removal
of the PyMySQL dependency broke binary columns, due to the asyncmy dialect
not being properly included within CI tests.

Also repairs mariadbconnector isolation level for 2.0.

basically tox config was failing to include additional
drivers.

Fixes: #7593
Change-Id: Iefc1061c24c75fcb9ca1a02d0b5e5f43970ade17

3 years agoAdded support for ``FILESTREAM`` in MSSQL.
Federico Caselli [Wed, 19 Jan 2022 22:31:13 +0000 (23:31 +0100)] 
Added support for ``FILESTREAM`` in MSSQL.

Fixes: #7243
Change-Id: I99880f429dbaac525bdf7d44438aaab6bc8d0ca6

3 years agoMerge "repair mapper sort" into main
mike bayer [Thu, 20 Jan 2022 22:44:00 +0000 (22:44 +0000)] 
Merge "repair mapper sort" into main

3 years agorestore empty list logic to ARRAY of ENUM parsing
Mike Bayer [Thu, 20 Jan 2022 20:01:47 +0000 (15:01 -0500)] 
restore empty list logic to ARRAY of ENUM parsing

Fixed regression where the change in :ticket:`7148` to repair ENUM handling
in PostgreSQL broke the use case of an empty ARRAY of ENUM, preventing rows
that contained an empty array from being handled correctly when fetching
results.

Fixes: #7590
Change-Id: I43a35ef25281a6e0a26b698efebef6ba12a63e8c

3 years agorepair mapper sort
Mike Bayer [Thu, 20 Jan 2022 14:31:42 +0000 (09:31 -0500)] 
repair mapper sort

Fixed issue in :meth:`_orm.Session.bulk_save_mappings` where the sorting
that takes place when the ``preserve_order`` parameter is set to False
would sort partially on ``Mapper`` objects, which is rejected in Python
3.11.

Also uses typing_extensions for NotRequired as this symbol
does not seem to be in Python 3.11.0a4 yet.

For interim 3.11 support, adds the git main build of greenlet
for Python 3.11

Fixes: #7591
Change-Id: I24a62f2322ad7dac5d8e4a00853f8a9408877c9c

3 years agorepair broken truediv test suite; memusage
Mike Bayer [Thu, 20 Jan 2022 17:26:36 +0000 (12:26 -0500)] 
repair broken truediv test suite; memusage

the truediv test suite didn't have __backend__ so wasn't running
for every DB except in the main build.  Repaired this as well
as truediv support to preserve the right-hand side type
when casting to numeric, if the right type is already a
numeric type.

also fixed a memusage test that relies on savepoints so was
not running under gerrit runs.

Change-Id: I3be223fdf697af9c1ed61b70d621f57cbbb7a92b

3 years agoMerge "Added missing method ``invalidate` in the `AsyncSession`" into main
mike bayer [Thu, 20 Jan 2022 14:45:39 +0000 (14:45 +0000)] 
Merge "Added missing method ``invalidate` in the `AsyncSession`" into main

3 years agocherry-pick changelog update for 1.4.31
Mike Bayer [Wed, 19 Jan 2022 23:18:13 +0000 (18:18 -0500)] 
cherry-pick changelog update for 1.4.31

3 years agocherry-pick changelog from 1.4.30
Mike Bayer [Wed, 19 Jan 2022 23:18:12 +0000 (18:18 -0500)] 
cherry-pick changelog from 1.4.30

3 years agoAdded missing method ``invalidate` in the `AsyncSession`
Federico Caselli [Wed, 19 Jan 2022 21:10:09 +0000 (22:10 +0100)] 
Added missing method ``invalidate` in the `AsyncSession`

Fixes: #7524
Change-Id: I20387e6700015c44f23bd2d05347bdce802196c0

3 years agoMerge "Add AdaptedConnection.run_async" into main
mike bayer [Wed, 19 Jan 2022 21:58:46 +0000 (21:58 +0000)] 
Merge "Add AdaptedConnection.run_async" into main

3 years agoThe parameter `as_uuid` of `UUID` now defaults to `True`.
Federico Caselli [Wed, 19 Jan 2022 21:29:03 +0000 (22:29 +0100)] 
The parameter `as_uuid` of `UUID` now defaults to `True`.

Fixes: #7225
Change-Id: Iddb78bf47ac733300bd12db50e16199cc22e9476

3 years agoAdd AdaptedConnection.run_async
Mike Bayer [Wed, 19 Jan 2022 19:31:52 +0000 (14:31 -0500)] 
Add AdaptedConnection.run_async

Added new method :meth:`.AdaptedConnection.run_async` to the DBAPI
connection interface used by asyncio drivers, which allows methods to be
called against the underlying "driver" connection directly within a
sync-style function where the ``await`` keyword can't be used, such as
within SQLAlchemy event handler functions. The method is analogous to the
:meth:`_asyncio.AsyncConnection.run_sync` method which translates
async-style calls to sync-style. The method is useful for things like
connection-pool on-connect handlers that need to invoke awaitable methods
on the driver connection when it's first created.

Fixes: #7580
Change-Id: I03c98a72bda0234deb19c00095b31a36f19bf36d

3 years agotypo
Mike Bayer [Wed, 19 Jan 2022 19:48:51 +0000 (14:48 -0500)] 
typo

Change-Id: I65cdd4cefdfacb1506c8e32a11c44ff650cd15b6

3 years agoMerge "reject methods as lambda SQL callables" into main
mike bayer [Wed, 19 Jan 2022 02:41:07 +0000 (02:41 +0000)] 
Merge "reject methods as lambda SQL callables" into main

3 years agoMerge "enhance double-aliased table logic to handle more cases" into main
mike bayer [Wed, 19 Jan 2022 02:39:05 +0000 (02:39 +0000)] 
Merge "enhance double-aliased table logic to handle more cases" into main

3 years agoreject methods as lambda SQL callables
Mike Bayer [Tue, 18 Jan 2022 22:19:24 +0000 (17:19 -0500)] 
reject methods as lambda SQL callables

Added an informative error message when a method object is passed to a SQL
construct. Previously, when such a callable were passed, as is a common
typographical error when dealing with method-chained SQL constructs, they
were interpreted as "lambda SQL" targets to be invoked at compilation time,
which would lead to silent failures. As this feature was not intended to be
used with methods, method objects are now rejected.

Fixes: #7032
Change-Id: If714715bd8c11557ab769ee3b1a24264b0b06acc

3 years agoenhance double-aliased table logic to handle more cases
Mike Bayer [Sun, 16 Jan 2022 15:21:45 +0000 (10:21 -0500)] 
enhance double-aliased table logic to handle more cases

Fixed ORM regression where calling the :func:`_orm.aliased` function
against an existing :func:`_orm.aliased` construct would fail to produce
correct SQL if the existing construct were against a fixed table. The fix
allows that the original :func:`_orm.aliased` construct is disregarded if
it were only against a table that's now being replaced. It also allows for
correct behavior when constructing a :func:`_orm.aliased` without a
selectable argument against a :func:`_orm.aliased` that's against a
subuquery, to create an alias of that subquery (i.e. to change its name).

The nesting behavior of :func:`_orm.aliased` remains in place for the case
where the outer :func:`_orm.aliased` object is against a subquery which in
turn refers to the inner :func:`_orm.aliased` object. This is a relatively
new 1.4 feature that helps to suit use cases that were previously served by
the deprecated ``Query.from_self()`` method.

Fixes: #7576
Change-Id: Ia9ca606f6300e38b6040eb6fc7facfe97c8cf057

3 years agodetect map_imperatively() called twice
Mike Bayer [Tue, 18 Jan 2022 16:02:57 +0000 (11:02 -0500)] 
detect map_imperatively() called twice

Fixed issue where calling upon :meth:`_orm.regsitry.map_imperatively` more
than once for the same class would produce an unexpected error, rather than
an informative error that the target class is already mapped. This behavior
differed from that of the :func:`_orm.mapper` function which does report an
informative message already.

For 2.0, this change also cleans up the logic that detects against
`Mapper()` or `_mapper()` being invoked directly.  1.4's backport will
take on a different format as `mapper()` is still public API in that
release.

Fixes: #7579
Change-Id: Ie74a1a2e97f8b6a81ac1942040edd8cae82f4bd8

3 years agoupdate zimports to 0.4.2
Mike Bayer [Sat, 15 Jan 2022 16:38:32 +0000 (11:38 -0500)] 
update zimports to 0.4.2

Will handle imports with "# type: ignore" comments
as well as specific noqa codes.  also works in python 3.10

Change-Id: I8937aeb109c29e003dd32a4251dbd786534681bf

3 years agoMerge "fix(mypy): Placeholder vars should have fullname set." into main
mike bayer [Sat, 15 Jan 2022 14:08:38 +0000 (14:08 +0000)] 
Merge "fix(mypy): Placeholder vars should have fullname set." into main

3 years agoMerge "Fixes(#7561) Add support for postgres.UUID literal_binds compilation" into...
mike bayer [Sat, 15 Jan 2022 14:07:56 +0000 (14:07 +0000)] 
Merge "Fixes(#7561) Add support for postgres.UUID literal_binds compilation" into main

3 years agofix(mypy): Placeholder vars should have fullname set.
Jaen Saul [Fri, 19 Nov 2021 20:12:44 +0000 (22:12 +0200)] 
fix(mypy): Placeholder vars should have fullname set.

Otherwise the dmypy daemon will crash on an incremental re-run.

Fixes: #7347
Closes: #7348
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7348
Pull-request-sha: 79eefa3417e09a8f9defaeafdb9f76d323385238

Change-Id: Id2133e837ee5dcf43461af51458e296353bdad6c

3 years agoMerge "remove dbapi_proxy module" into main
mike bayer [Sat, 15 Jan 2022 00:13:34 +0000 (00:13 +0000)] 
Merge "remove dbapi_proxy module" into main

3 years agoMerge "track item schema names to identify name collisions w/ default schema" into...
mike bayer [Fri, 14 Jan 2022 23:00:59 +0000 (23:00 +0000)] 
Merge "track item schema names to identify name collisions w/ default schema" into main

3 years agoMerge "Initial ORM typing layout" into main
mike bayer [Fri, 14 Jan 2022 22:54:54 +0000 (22:54 +0000)] 
Merge "Initial ORM typing layout" into main

3 years agoremove dbapi_proxy module
Mike Bayer [Fri, 14 Jan 2022 22:42:44 +0000 (17:42 -0500)] 
remove dbapi_proxy module

This module was not documented nor part of any test suite,
and it's unlikely it was working correctly.   It's not likely
that this module was ever used after the first year or so
of SQLAlchemy, and it's stayed around because it is so
obscure that I never remembered to remove it.

Change-Id: I0ed9030438982e935add87c51abbfff50e7382be
References: #7257

3 years agoMerge "initial reorganize for static typing" into main
mike bayer [Fri, 14 Jan 2022 22:00:11 +0000 (22:00 +0000)] 
Merge "initial reorganize for static typing" into main

3 years agotrack item schema names to identify name collisions w/ default schema
Mike Bayer [Fri, 17 Dec 2021 23:04:47 +0000 (18:04 -0500)] 
track item schema names to identify name collisions w/ default schema

Added an additional lookup step to the compiler which will track all FROM
clauses which are tables, that may have the same name shared in multiple
schemas where one of the schemas is the implicit "default" schema; in this
case, the table name when referring to that name without a schema
qualification will be rendered with an anonymous alias name at the compiler
level in order to disambiguate the two (or more) names. The approach of
schema-qualifying the normally unqualified name with the server-detected
"default schema name" value was also considered, however this approach
doesn't apply to Oracle nor is it accepted by SQL Server, nor would it work
with multiple entries in the PostgreSQL search path. The name collision
issue resolved here has been identified as affecting at least Oracle,
PostgreSQL, SQL Server, MySQL and MariaDB.

Fixes: #7471
Change-Id: Id65e7ca8c43fe8d95777084e8d5ec140ebcd784d

3 years agoFixes(#7561) Add support for postgres.UUID literal_binds compilation
José Duarte [Thu, 13 Jan 2022 22:20:06 +0000 (17:20 -0500)] 
Fixes(#7561) Add support for postgres.UUID literal_binds compilation

Added string rendering to the :class:`.postgresql.UUID` datatype, so that
stringifying a statement with "literal_binds" that uses this type will
render an appropriate string value for the PostgreSQL backend. Pull request
courtesy José Duarte.

Fixes: #7561
Closes: #7563
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7563
Pull-request-sha: cf6fe73265342d7884a940c4b3a34c9552113ec3

Change-Id: I4b162bdcdce2293a90683e36da54e4a891a3c684

3 years agoInitial ORM typing layout
Mike Bayer [Sun, 9 Jan 2022 16:49:02 +0000 (11:49 -0500)] 
Initial ORM typing layout

introduces:

1. new mapped_column() helper
2. DeclarativeBase helper
3. declared_attr has been re-typed
4. rework of Mapped[] to return InstrumentedAtribute for
   class get, so works without Mapped itself having expression
   methods
5. ORM constructs now generic on [_T]

also includes some early typing work, most of which will
be in later commits:

1. URL and History become typing.NamedTuple
2. come up with type-checking friendly way of type
   checking cy extensions, where type checking will be applied
   to the py versions, just needed to come up with a succinct
   conditional pattern for the imports

References: #6810
References: #7535
References: #7562
Change-Id: Ie5d9a44631626c021d130ca4ce395aba623c71fb

3 years agoRemove pymysql in asyncmy
long2ice [Fri, 14 Jan 2022 08:50:26 +0000 (03:50 -0500)] 
Remove pymysql in asyncmy

Removed unnecessary dependency on PyMySQL from the asyncmy dialect. Pull
request courtesy long2ice.

Fixes: #7567
Closes: #7568
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7568
Pull-request-sha: 48cbb3e3c249e431dfd91e88fcb3284af83671e5

Change-Id: Iad5048eaa5de6ad6666b2120df6608fd1bf50e02

3 years agoinitial reorganize for static typing
Mike Bayer [Sun, 2 Jan 2022 22:35:43 +0000 (17:35 -0500)] 
initial reorganize for static typing

start applying foundational annotations to key
elements.

two main elements addressed here:

1. removal of public_factory() and replacement with
   explicit functions.  this just works much better with
   typing.

2. typing support for column expressions and operators.
   The biggest part of this involves stubbing out all the
   ColumnOperators methods under ColumnElement in a
   TYPE_CHECKING section.  Took me a while to see this
   method vs. much more complicated things I thought
   I needed.

Also for this version implementing #7519, ColumnElement
types against the Python type and not TypeEngine.  it is
hoped this leads to easier transferrence between ORM/Core
as well as eventual support for result set typing.
Not clear yet how well this approach will work and what
new issues it may introduce.

given the current approach we now get full, rich typing for
scenarios like this:

from sqlalchemy import column, Integer, String, Boolean

c1 = column('a', String)

c2 = column('a', Integer)

expr1 = c2.in_([1, 2, 3])

expr2 = c2 / 5

expr3 = -c2

expr4_a = ~(c2 == 5)

expr4_b = ~column('q', Boolean)

expr5 = c1 + 'x'

expr6 = c2 + 10

Fixes: #7519
Fixes: #6810
Change-Id: I078d9f57955549f6f7868314287175f6c61c44cb

3 years agoMerge "remove internal use of metaclasses" into main
mike bayer [Tue, 11 Jan 2022 19:02:22 +0000 (19:02 +0000)] 
Merge "remove internal use of metaclasses" into main

3 years agoMerge "implement second-level type resolution for literals" into main
mike bayer [Tue, 11 Jan 2022 18:11:13 +0000 (18:11 +0000)] 
Merge "implement second-level type resolution for literals" into main

3 years agoMerge "change state.load_options to a tuple" into main
mike bayer [Tue, 11 Jan 2022 18:08:00 +0000 (18:08 +0000)] 
Merge "change state.load_options to a tuple" into main

3 years agoremove internal use of metaclasses
Mike Bayer [Mon, 10 Jan 2022 21:48:05 +0000 (16:48 -0500)] 
remove internal use of metaclasses

All but one metaclass used internally can now
be replaced using __init_subclass__().  Within this
patch we remove:

* events._EventMeta
* sql.visitors.TraversibleType
* sql.visitors.InternalTraversibleType
* testing.fixtures.FindFixture
* testing.fixtures.FindFixtureDeclarative
* langhelpers.EnsureKWArgType
* sql.functions._GenericMeta
* sql.type_api.VisitableCheckKWArg (was a mixture of TraversibleType
  and EnsureKWArgType)

The remaining internal class is MetaOptions used by the
sql.Options object which is in turn currently mostly for
ORM internal use, as this type implements class level overrides
for the ``+`` operator.

For declarative, removing DeclarativeMeta in place of
an `__init_subclass__()` class would not be fully feasible as
it would break backwards compatibility with applications that
refer to this class explicitly, but also DeclarativeMeta intercepts
class-level attribute set and delete operations which is a widely
used pattern.   An option for declarative base to use
`__init_subclass__()` should be provided but this is out of
scope for this particular change.

Change-Id: I8aa898c7ab59d887739037d34b1cbab36521ab78
References: #6810

3 years agoremove non-working mssql description_encoding param
Mike Bayer [Tue, 11 Jan 2022 14:46:19 +0000 (09:46 -0500)] 
remove non-working mssql description_encoding param

the description_encoding concept has been fully
removed in 2.0, but this logic was plainly broken
in any case.   The same non-working logic exists in
1.4 as well, where description_encoding as a concept
is not removed, though it is likely that there are no
real-world use cases for it.

Change-Id: Icaf47f4740e3f57063b614a1d4136e0d89f40621

3 years agochange state.load_options to a tuple
Mike Bayer [Tue, 11 Jan 2022 03:11:50 +0000 (22:11 -0500)] 
change state.load_options to a tuple

having this be an immutable sequence is safer
and possibly lower overhead.

The change here went in with no issues save
for tests that asserted it was a set.
InstanceState.load_options is only referred
towards when the object is first loaded, and then
within the logic that emits an object refresh
as well as within a lazy loader.   it's only
accessed as a whole collection.

Fixes: #7558
Change-Id: Id1adbec0f93bcfbfc934ec9cd39e71e74727845d

3 years agoimplement second-level type resolution for literals
Mike Bayer [Wed, 5 Jan 2022 17:20:46 +0000 (12:20 -0500)] 
implement second-level type resolution for literals

Added additional rule to the system that determines ``TypeEngine``
implementations from Python literals to apply a second level of adjustment
to the type, so that a Python datetime with or without tzinfo can set the
``timezone=True`` parameter on the returned :class:`.DateTime` object, as
well as :class:`.Time`. This helps with some round-trip scenarios on
type-sensitive PostgreSQL dialects such as asyncpg, psycopg3 (2.0 only).

For 1.4 specifically, the backport improves support for asyncpg handling of
TIME WITH TIMEZONE, which was not fully implemented. 2.0's reworked
PostgreSQL architecture had this handled already.

Fixes: #7537
Change-Id: Icdb07db85af5f7f39f1c1ef855fe27609770094b

3 years agoensure with_options not switched to a list
Mike Bayer [Mon, 10 Jan 2022 19:59:59 +0000 (14:59 -0500)] 
ensure with_options not switched to a list

Fixed regression which appeared in 1.4.23 which could cause loader options
to be mis-handled in some cases, in particular when using joined table
inheritance in combination with the ``polymorphic_load="selectin"`` option
as well as relationship lazy loading, leading to a ``TypeError``.

Fixes: #7557
Change-Id: Id38619692f94308fd5f567a02337efef7a3a7544

3 years agoMerge "Fix various source comment/doc typos" into main
mike bayer [Fri, 7 Jan 2022 16:42:18 +0000 (16:42 +0000)] 
Merge "Fix various source comment/doc typos" into main

3 years agohappy new year 2022
Mike Bayer [Thu, 6 Jan 2022 19:18:36 +0000 (14:18 -0500)] 
happy new year 2022

Change-Id: I49abf2607e0eb0623650efdf0091b1fb3db737ea

3 years agoMerge "Add oracle docker instructions to readme unittest" into main
mike bayer [Thu, 6 Jan 2022 19:15:42 +0000 (19:15 +0000)] 
Merge "Add oracle docker instructions to readme unittest" into main

3 years agoMerge "Remove all remaining removed_in_20 warnings slated for removal" into main
mike bayer [Thu, 6 Jan 2022 19:15:06 +0000 (19:15 +0000)] 
Merge "Remove all remaining removed_in_20 warnings slated for removal" into main

3 years agoMerge "Remove redundant code for EOL Python <= 3.6" into main
Federico Caselli [Thu, 6 Jan 2022 19:06:23 +0000 (19:06 +0000)] 
Merge "Remove redundant code for EOL Python <= 3.6" into main

3 years agofix(dialects.mysql): repeatedly exported DECIMAL
sudoii [Thu, 6 Jan 2022 17:20:31 +0000 (12:20 -0500)] 
fix(dialects.mysql): repeatedly exported DECIMAL

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

### Description
<!-- Describe your changes in detail -->

This is a typo, DECIMAL has been exported repeatedly, so this fix does not need to be tested.

https://github.com/sqlalchemy/sqlalchemy/blob/21ee595ba9ef3e7abc8982fac7bf488c904cf9c9/lib/sqlalchemy/dialects/mysql/__init__.py#L68
https://github.com/sqlalchemy/sqlalchemy/blob/21ee595ba9ef3e7abc8982fac7bf488c904cf9c9/lib/sqlalchemy/dialects/mysql/__init__.py#L71

```
# Intercepted code block
# sqlalchemy/lib/sqlalchemy/dialects/mysql/__init__.py

__all__ = (
    "BIGINT",
    "BINARY",
    "BIT",
    "BLOB",
    "BOOLEAN",
    "CHAR",
    "DATE",
    "DATETIME",
    "DECIMAL",   # Line 68
    "DOUBLE",
    "ENUM",
    "DECIMAL",   # Line 71
```

### 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: #7543
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7543
Pull-request-sha: 889d05c444264bf1b6d11386459d3360cc529d27

Change-Id: I0898af68548b3131388e50d906f216a2c4af4486

3 years agoRemove redundant code for EOL Python <= 3.6
Hugo van Kemenade [Thu, 6 Jan 2022 17:14:33 +0000 (12:14 -0500)] 
Remove redundant code for EOL Python <= 3.6

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

### Description
<!-- Describe your changes in detail -->

There's a few bits and pieces of code to support Python <= 3.6 which are no longer needed and can be removed, to slightly simplify the codebase.

### 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: #7544
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7544
Pull-request-sha: 282b4a91282902a57807aa2541b75b272b547127

Change-Id: I9ddf15fcf72551d52e3f027f337c7fee4aa9083b

3 years agofix incorrect with_parent() example
Mike Bayer [Thu, 6 Jan 2022 14:24:08 +0000 (09:24 -0500)] 
fix incorrect with_parent() example

The lead example for the with_parent() function
docstring was backwards, based on the standard User/Address
mapping used in the documentation.

Fixes: #7540
Change-Id: Iaff7dc6fdd0c323509231ae5f3122ed76a420915

3 years agoAdd oracle docker instructions to readme unittest
Federico Caselli [Thu, 6 Jan 2022 11:32:55 +0000 (12:32 +0100)] 
Add oracle docker instructions to readme unittest

Change-Id: I6538171b0fa73b25aeb2b1acaca4867cde56c537

3 years agoRemove all remaining removed_in_20 warnings slated for removal
Mike Bayer [Mon, 3 Jan 2022 18:49:26 +0000 (13:49 -0500)] 
Remove all remaining removed_in_20 warnings slated for removal

Finalize all remaining removed-in-2.0 changes so that we
can begin doing pep-484 typing without old things
getting in the way (we will also have to do public_factory).

note there are a few "moved_in_20()" and "became_legacy_in_20()"
warnings still in place.  The SQLALCHEMY_WARN_20 variable
is now removed.

Also removed here are the legacy "in place mutators" for Select
statements, and some keyword-only argument signatures in Core
have been added.

Also in the big change department, the ORM mapper() function
is removed entirely; the Mapper class is otherwise unchanged,
just the public-facing API function.  Mappers are now always
given a registry in which to participate, however the
argument signature of Mapper is not changed. ideally "registry"
would be the first positional argument.

Fixes: #7257
Change-Id: Ic70c57b9f1cf7eb996338af5183b11bdeb3e1623

3 years agoMerge "Fix AttributeError typo in setup.py that prevented fallback pure python build...
Federico Caselli [Wed, 5 Jan 2022 21:59:52 +0000 (21:59 +0000)] 
Merge "Fix AttributeError typo in setup.py that prevented fallback pure python build if the compilation fails" into main

3 years agoFix AttributeError typo in setup.py that prevented fallback
Federico Caselli [Wed, 5 Jan 2022 20:31:31 +0000 (21:31 +0100)] 
Fix AttributeError typo in setup.py that prevented fallback
pure python build if the compilation fails

Fixes: #7539
Change-Id: I4bf7905eb7a5337213ce922d005d2fffb8b9079c

3 years agoUpdate Black's target-version to py37
Hugo van Kemenade [Wed, 5 Jan 2022 17:41:32 +0000 (12:41 -0500)] 
Update Black's target-version to py37

<!-- 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

3 years agoMerge "implement python_impl to custom_op for basic ORM evaluator extensibility"...
mike bayer [Tue, 4 Jan 2022 22:32:48 +0000 (22:32 +0000)] 
Merge "implement python_impl to custom_op for basic ORM evaluator extensibility" into main

3 years agoimplement python_impl to custom_op for basic ORM evaluator extensibility
Mike Bayer [Tue, 4 Jan 2022 19:04:15 +0000 (14:04 -0500)] 
implement python_impl to custom_op for basic ORM evaluator extensibility

Added new parameter :paramref:`_sql.Operators.op.python_impl`, available
from :meth:`_sql.Operators.op` and also when using the
:class:`_sql.Operators.custom_op` constructor directly, which allows an
in-Python evaluation function to be provided along with the custom SQL
operator. This evaluation function becomes the implementation used when the
operator object is used given plain Python objects as operands on both
sides, and in particular is compatible with the
``synchronize_session='evaluate'`` option used with
:ref:`orm_expression_update_delete`.

Fixes: #3162
Change-Id: If46ba6a0e303e2180a177ba418a8cafe9b42608e

3 years agoupdate stale documentation on Mapper class
Mike Bayer [Tue, 4 Jan 2022 20:38:15 +0000 (15:38 -0500)] 
update stale documentation on Mapper class

don't get into details here that have changed,
point to the main narrative documentation instead.

Change-Id: I5bc0829f6ff282ca104f18deb9ec9857b6e1c8ac

3 years agoMerge "Imrpove MySQL/MariaDB dialect initialization." into main
Federico Caselli [Tue, 4 Jan 2022 20:30:16 +0000 (20:30 +0000)] 
Merge "Imrpove MySQL/MariaDB dialect initialization." into main

3 years agoMerge "Improve array of enum handling." into main
Federico Caselli [Tue, 4 Jan 2022 20:28:41 +0000 (20:28 +0000)] 
Merge "Improve array of enum handling." into main

3 years agoMerge "ensure correlate_except is checked for empty tuple" into main
mike bayer [Tue, 4 Jan 2022 19:36:30 +0000 (19:36 +0000)] 
Merge "ensure correlate_except is checked for empty tuple" into main

3 years agoImprove array of enum handling.
Federico Caselli [Fri, 10 Dec 2021 13:18:34 +0000 (14:18 +0100)] 
Improve array of enum handling.

Fixed handling of array of enum values which require escape characters.

Fixes: #7418
Change-Id: I50525846f6029dfea9a8ad1cb913424d168d5f62

3 years agoimprove custom operator for SQL types docs
Mike Bayer [Tue, 4 Jan 2022 19:08:10 +0000 (14:08 -0500)] 
improve custom operator for SQL types docs

introduce here that "custom ops" first come from
the .op() method in the usual case.  then only if one wants
such an op to be pre-assocaited with particular types,
then the comparator may be used.  Also clarify the individual
points regarding the comparator.

Change-Id: Id6046448eb2c17fa6e3f2ef6d9343b156ddec96f

3 years agoensure correlate_except is checked for empty tuple
Mike Bayer [Mon, 3 Jan 2022 22:28:52 +0000 (17:28 -0500)] 
ensure correlate_except is checked for empty tuple

Fixed issue where :meth:`_sql.Select.correlate_except` method, when passed
either the ``None`` value or no arguments, would not correlate any elements
when used in an ORM context (that is, passing ORM entities as FROM
clauses), rather than causing all FROM elements to be considered as
"correlated" in the same way which occurs when using Core-only constructs.

Fixes: #7514
Change-Id: Ic4a5252c8f3c1140aba6c308264948f3a91f33f5

3 years agoImrpove MySQL/MariaDB dialect initialization.
Federico Caselli [Thu, 30 Dec 2021 22:29:55 +0000 (23:29 +0100)] 
Imrpove MySQL/MariaDB dialect initialization.

Replace ``SHOW VARIABLES LIKE`` statement with equivalent
``SELECT @@variable`` in MySQL and MariaDB dialect initialization.
This should avoid mutex contention caused by ``SHOW VARIABLES``,
improving initialization performance.

Change-Id: Id836ef534fcc1473c7aaf9270d08a4da9b8f62cf
closes: #7518

3 years agoadjust TypeError message yet again
Mike Bayer [Sat, 1 Jan 2022 21:50:41 +0000 (16:50 -0500)] 
adjust TypeError message yet again

in 924d38e660981ae2a7d55355603 we got it almost right in
all cases, Pypy seems to have an entirely different kind of message
so make this much more open ended.

Change-Id: I661a9ee0cf8247d715e35f8b9188cd1ac46abdfb

3 years agoadjust error message assertion for TypeError
Mike Bayer [Sat, 1 Jan 2022 20:30:15 +0000 (15:30 -0500)] 
adjust error message assertion for TypeError

in eee7a3add99df2865e6d907f2 I added a few TypeError
tests, and some python interpreters produce a message like
"join() got an unexpected...", others seem to produce
"Query.join() got an unexpected..."

the pattern is strange, all Python 3.10's seem to return the
class name.  For Python 3.8 and 3.9, my local intepreters
are doing the Python 3.10 behavior but github actions are doing
the older behavior.  Python 3.7 both here and on github actions
are doing the older behavior.

In any case, adjust the regexps to match both.

Change-Id: I3ab13e2be51ab243f8f6bcecf26fd03070cec17f

3 years agoremove 2.0-removed Query elements
Mike Bayer [Thu, 30 Dec 2021 00:26:08 +0000 (19:26 -0500)] 
remove 2.0-removed Query elements

* :meth:`_orm.Query.join` no longer accepts the "aliased" and
"from_joinpoint" arguments

* :meth:`_orm.Query.join` no longer accepts chains of multiple join
targets in one method call.

* ``Query.from_self()`` and ``Query.with_polymorphic()``
are removed.

Change-Id: I534d04b53a538a4fc374966eb2bc8eb98a16497d
References: #7257

3 years agoProperly type _generative, decorator, public_factory
Federico Caselli [Wed, 22 Dec 2021 20:45:45 +0000 (21:45 +0100)] 
Properly type _generative, decorator, public_factory

Good new is that pylance likes it and copies over the
singature and everything.
Bad news is that mypy does not support this yet https://github.com/python/mypy/issues/8645
Other minor bad news is that non_generative is not typed. I've tried using a protocol
like the one in the comment but the signature is not ported over by pylance, so it's
probably best to just live without it to have the correct signature.

notes from mike:  these three decorators are at the core of getting
the library to be typed, more good news is that pylance will
do all the things we like re: public_factory, see
https://github.com/microsoft/pyright/issues/2758#issuecomment-1002788656
.

For @_generative, we will likely move to using pep 673 once mypy
supports it which may be soon.  but overall having the explicit
"return self" in the methods, while a little inconvenient, makes
the typing more straightforward and locally present in the files
rather than being decided at a distance.   having "return self"
present, or not, both have problems, so maybe we will be able
to change it again if things change as far as decorator support.
As it is, I feel like we are barely squeaking by with our decorators,
the typing is already pretty out there.

Change-Id: Ic77e13fc861def76a5925331df85c0aa48d77807
References: #6810

3 years agoFix various source comment/doc typos
luz paz [Fri, 10 Dec 2021 14:10:29 +0000 (09:10 -0500)] 
Fix various source comment/doc typos

### Description
Found via `codespell -q 3 -L ba,crate,datas,froms,gord,hist,inh,nd,selectin,strat,ue`
Also added codespell to the pep8 tox env

### Checklist

This pull request is:

- [x] A documentation / typographical error fix
- Good to go, no issue or tests are needed

Closes: #7338
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7338
Pull-request-sha: 0deac2219396bc0eba7da53eb3a80932edbf2dd7

Change-Id: Icd61db31c8dc655d4a39d8a304194804d08555fe

3 years agoMerge "remove legacy select patterns" into main
mike bayer [Wed, 29 Dec 2021 19:19:42 +0000 (19:19 +0000)] 
Merge "remove legacy select patterns" into main

3 years agoremove legacy select patterns
Mike Bayer [Wed, 29 Dec 2021 17:10:23 +0000 (12:10 -0500)] 
remove legacy select patterns

Change-Id: If6e521a1eb461e08748a0432943b938528a2619e
References: #7257

3 years agoreplace Variant with direct feature inside of TypeEngine
Mike Bayer [Sat, 23 Oct 2021 15:26:45 +0000 (11:26 -0400)] 
replace Variant with direct feature inside of TypeEngine

The :meth:`_sqltypes.TypeEngine.with_variant` method now returns a copy of
the original :class:`_sqltypes.TypeEngine` object, rather than wrapping it
inside the ``Variant`` class, which is effectively removed (the import
symbol remains for backwards compatibility with code that may be testing
for this symbol). While the previous approach maintained in-Python
behaviors, maintaining the original type allows for clearer type checking
and debugging.

Fixes: #6980
Change-Id: I158c7e56306b886b5b82b040205c428a5c4a242c

3 years agouse long long for id() result
Mike Bayer [Tue, 28 Dec 2021 15:54:18 +0000 (10:54 -0500)] 
use long long for id() result

per https://stackoverflow.com/a/27055236/34549 apparently there
is "long long" in cython.

Change-Id: I08bfaaccbf87ec9a2dc0d4b154f9c9d454171342

3 years agoMerge "Reflect included columns as dialect_options" into main
mike bayer [Mon, 27 Dec 2021 22:07:10 +0000 (22:07 +0000)] 
Merge "Reflect included columns as dialect_options" into main

3 years agoMerge "Replace raise_ with raise from" into main
Federico Caselli [Mon, 27 Dec 2021 21:04:54 +0000 (21:04 +0000)] 
Merge "Replace raise_ with raise from" into main

3 years agoReplace raise_ with raise from
Federico Caselli [Sat, 18 Dec 2021 10:11:49 +0000 (11:11 +0100)] 
Replace raise_ with raise from

Change-Id: I7aaeb5bc130271624335b79cf586581d6c6c34c7
References: #4600

3 years agoReflect included columns as dialect_options
Gord Thompson [Mon, 20 Dec 2021 21:37:13 +0000 (14:37 -0700)] 
Reflect included columns as dialect_options

Fixed reflection of covering indexes to report ``include_columns`` as part
of the ``dialect_options`` entry in the reflected index dictionary, thereby
enabling round trips from reflection->create to be complete. Included
columns continue to also be present under the ``include_columns`` key for
backwards compatibility.

Fixes: #7382
Change-Id: I4f16b65caed3a36d405481690a3a92432b5efd62

3 years agoMerge "propose concurrency check for SessionTransaction" into main
mike bayer [Mon, 27 Dec 2021 19:20:10 +0000 (19:20 +0000)] 
Merge "propose concurrency check for SessionTransaction" into main

3 years agoMerge "cursor tweaks" into main
mike bayer [Mon, 27 Dec 2021 19:15:40 +0000 (19:15 +0000)] 
Merge "cursor tweaks" into main

3 years agoMerge "factor out UnboundLoad and rearchitect strategy_options.py" into main
mike bayer [Mon, 27 Dec 2021 18:14:31 +0000 (18:14 +0000)] 
Merge "factor out UnboundLoad and rearchitect strategy_options.py" into main

3 years agopropose concurrency check for SessionTransaction
Mike Bayer [Thu, 2 Dec 2021 14:18:11 +0000 (09:18 -0500)] 
propose concurrency check for SessionTransaction

the discussion at #7387 refers to a condition that seems
to happen in the wild also, such as [1] [2] [3], it's not
entirely clear why this specific spot is how this occurs,
however it's maybe that when the connection is being acquired
from the pool, under load there might be a wait on the connection
pool, leading to more time for another errant thread to be
calling .close(), just a theory.

in this patch we propose using decorators and context managers
along with declarative state declarations to block reentrant
or concurrent calls to methods that conflict with expected
state changes.

The :class:`_orm.Session` (and by extension :class:`.AsyncSession`) now has
new state-tracking functionality that will proactively trap any unexpected
state changes which occur as a particular transactional method proceeds.
This is to allow situations where the :class:`_orm.Session` is being used
in a thread-unsafe manner, where event hooks or similar may be calling
unexpected methods within operations, as well as potentially under other
concurrency situations such as asyncio or gevent to raise an informative
message when the illegal access first occurs, rather than passing silently
leading to secondary failures due to the :class:`_orm.Session` being in an
invalid state.

[1] https://stackoverflow.com/questions/25768428/sqlalchemy-connection-errors
[2] https://groups.google.com/g/sqlalchemy/c/n5oVX3v4WOw
[3] https://github.com/cosmicpython/code/issues/23

Fixes: #7433
Change-Id: I699b935c0ec4e5a63f12cf878af6f7a92a30a3aa

3 years agofactor out UnboundLoad and rearchitect strategy_options.py
Mike Bayer [Thu, 9 Dec 2021 01:27:16 +0000 (20:27 -0500)] 
factor out UnboundLoad and rearchitect strategy_options.py

The architecture of Load is mostly rewritten here.

The change includes removal of the "pluggable" aspect
of the loader options, which would patch new methods onto
Load.  This has been replaced by normal methods that
respond normally to typing annotations.  As part of this
change, the bake_loaders() and unbake_loaders() options,
which have no effect since 1.4 and were unlikely to be
in any common use, have been removed.

Additionally, to support annotations for methods that
make use of @decorator, @generative etc., modified
format_argspec_plus to no longer return "args", instead
returns "grouped_args" which is always grouped and
allows return annotations to format correctly.

Fixes: #6986
Change-Id: I6117c642345cdde65a64389bba6057ddd5374427

3 years agocursor tweaks
Mike Bayer [Sat, 25 Dec 2021 04:11:23 +0000 (23:11 -0500)] 
cursor tweaks

tighten up creation of dictionaries and conditional logic
within the creation of CursorResultMetaData objects

Change-Id: I5538ecc343ab0cabcf58d7c92ae0a552d5ac1d8a

3 years agoMerge "consider truediv as truediv; support floordiv operator" into main
mike bayer [Mon, 27 Dec 2021 16:29:23 +0000 (16:29 +0000)] 
Merge "consider truediv as truediv; support floordiv operator" into main

3 years agoMerge "implement cython for cache_anon_map, prefix_anon_map" into main
mike bayer [Mon, 27 Dec 2021 15:26:31 +0000 (15:26 +0000)] 
Merge "implement cython for cache_anon_map, prefix_anon_map" into main

3 years agoconsider truediv as truediv; support floordiv operator
Mike Bayer [Wed, 8 Dec 2021 13:57:44 +0000 (08:57 -0500)] 
consider truediv as truediv; support floordiv operator

Implemented full support for "truediv" and "floordiv" using the
"/" and "//" operators.  A "truediv" operation between two expressions
using :class:`_types.Integer` now considers the result to be
:class:`_types.Numeric`, and the dialect-level compilation will cast
the right operand to a numeric type on a dialect-specific basis to ensure
truediv is achieved.  For floordiv, conversion is also added for those
databases that don't already do floordiv by default (MySQL, Oracle) and
the ``FLOOR()`` function is rendered in this case, as well as for
cases where the right operand is not an integer (needed for PostgreSQL,
others).

The change resolves issues both with inconsistent behavior of the
division operator on different backends and also fixes an issue where
integer division on Oracle would fail to be able to fetch a result due
to inappropriate outputtypehandlers.

Fixes: #4926
Change-Id: Id54cc018c1fb7a49dd3ce1216d68d40f43fe2659

3 years agoMerge "include empty intermediary tables in optimized get" into main
mike bayer [Mon, 27 Dec 2021 00:24:24 +0000 (00:24 +0000)] 
Merge "include empty intermediary tables in optimized get" into main

3 years agoinclude empty intermediary tables in optimized get
Mike Bayer [Sun, 26 Dec 2021 17:13:19 +0000 (12:13 -0500)] 
include empty intermediary tables in optimized get

Fixed issue in joined-inheritance load of additional attributes
functionality in deep multi-level inheritance where an intermediary table
that contained no columns would not be included in the tables joined,
instead linking those tables to their primary key identifiers. While this
works fine, it nonetheless in 1.4 began producing the cartesian product
compiler warning. The logic has been changed so that these intermediary
tables are included regardless. While this does include additional tables
in the query that are not technically necessary, this only occurs for the
highly unusual case of deep 3+ level inheritance with intermediary tables
that have no non primary key columns, potential performance impact is
therefore expected to be negligible.

Fixes: #7507
Change-Id: Id2073773e97a0853b744b51feeb2bc4437032e51

3 years agorestore graceful degrade of subqueryload w from_statement
Mike Bayer [Sun, 26 Dec 2021 16:25:00 +0000 (11:25 -0500)] 
restore graceful degrade of subqueryload w from_statement

Fixed regression from 1.3 where the "subqueryload" loader strategy would
fail with a stack trace if used against a query that made use of
:meth:`_orm.Query.from_statement` or :meth:`_sql.Select.from_statement`. As
subqueryload requires modifying the original statement, it's not compatible
with the "from_statement" use case, especially for statements made against
the :func:`_sql.text` construct. The behavior now is equivalent to that of
1.3 and previously, which is that the loader strategy silently degrades to
not be used for such statements, typically falling back to using the
lazyload strategy.

Fixes: #7505
Change-Id: I950800dc86a77f8320a5e696edce1ff2c84b1eb9

3 years agocherry-pick changelog update for 1.4.30
Mike Bayer [Thu, 23 Dec 2021 02:19:30 +0000 (21:19 -0500)] 
cherry-pick changelog update for 1.4.30

3 years agocherry-pick changelog from 1.4.29
Mike Bayer [Thu, 23 Dec 2021 02:19:29 +0000 (21:19 -0500)] 
cherry-pick changelog from 1.4.29

3 years agoadd mariadb conf section
Mike Bayer [Thu, 23 Dec 2021 02:07:33 +0000 (21:07 -0500)] 
add mariadb conf section

Change-Id: I7686ab7a877895de33e9ca19217ae38cb5729238

3 years agoMerge "add recursion check for with_loader_criteria() option" into main
mike bayer [Thu, 23 Dec 2021 00:38:36 +0000 (00:38 +0000)] 
Merge "add recursion check for with_loader_criteria() option" into main

3 years agoFix missing class attributes when using __class_getitem__
Kai Mueller [Tue, 21 Dec 2021 20:00:30 +0000 (15:00 -0500)] 
Fix missing class attributes when using __class_getitem__

Fixed issue where the ``__class_getitem__()`` method of the generated
declarative base class by :func:`_orm.as_declarative` would lead to
inaccessible class attributes such as ``__table__``, for cases where a
``Generic[T]`` style typing declaration were used in the class hierarchy.
This is in continuation from the basic addition of ``__class_getitem__()``
in :ticket:`7368`. Pull request courtesy Kai Mueller.

Fixes: #7462
Closes: #7470
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7470
Pull-request-sha: d5e5765e0e5542149f116ed9ccff1b3e2e32dee5

Change-Id: I6418af6d34532ff181343884bd419d9c2684e617

3 years agouse fully qualified, locatable names for all use of api.named_type()
Mike Bayer [Wed, 22 Dec 2021 21:21:33 +0000 (16:21 -0500)] 
use fully qualified, locatable names for all use of api.named_type()

Fixed mypy regression where the release of mypy 0.930 added additional
internal checks to the format of "named types", requiring that they be
fully qualified and locatable. This broke the mypy plugin for SQLAlchemy,
raising an assertion error, as there was use of symbols such as
``__builtins__`` and other un-locatable or unqualified names that
previously had not raised any assertions.

Fixes: #7496
Change-Id: I037680606a1d51158ef6503508ec76c5d5adc946