]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
3 years agocherry-pick changelog update for 1.4.33
Mike Bayer [Sun, 6 Mar 2022 22:43:27 +0000 (17:43 -0500)] 
cherry-pick changelog update for 1.4.33

3 years agocherry-pick changelog from 1.4.32
Mike Bayer [Sun, 6 Mar 2022 22:43:26 +0000 (17:43 -0500)] 
cherry-pick changelog from 1.4.32

3 years ago1.4.32 changelog edits
Mike Bayer [Sun, 6 Mar 2022 18:18:59 +0000 (13:18 -0500)] 
1.4.32 changelog edits

Change-Id: I3f62ba9c8ff35c8ae1d0bd611db92521da38dff0
(cherry picked from commit 03e17631cc6e6e521668ef9deec908d8c7265a0a)

3 years agoMerge "warn for enum length silently ignored" into main
mike bayer [Fri, 4 Mar 2022 23:58:07 +0000 (23:58 +0000)] 
Merge "warn for enum length silently ignored" into main

3 years agoMerge "fix type string formatting calls" into main
mike bayer [Fri, 4 Mar 2022 23:31:49 +0000 (23:31 +0000)] 
Merge "fix type string formatting calls" into main

3 years agoadd missing changelog for #7045
Mike Bayer [Fri, 4 Mar 2022 23:30:40 +0000 (18:30 -0500)] 
add missing changelog for #7045

was missed in d2815b4ac39b42a38dff4cc21ec100c72b9f3cae

Fixes: #7045
Change-Id: Id4836690daabf7e547c278a4e538d39579e5f2a2

3 years agowarn for enum length silently ignored
Mike Bayer [Fri, 4 Mar 2022 23:27:24 +0000 (18:27 -0500)] 
warn for enum length silently ignored

the "length" parameter is silently ignored when native_enum
is not passed as False.  if native_enum is True, a non-native
VARCHAR can still be generated.   Warn for this silent ignore
right now, consider having "length" used in all cases where
non-native enum is rendered likely in 2.0.

Change-Id: Ibceedd4e3aa3926f3268c0c39d94ab73d17a9bdc

3 years agoadd length to enum repr params
Mike Bayer [Fri, 4 Mar 2022 22:30:21 +0000 (17:30 -0500)] 
add length to enum repr params

This amends the fix for #7789.

Fixes: #7598
Change-Id: I067a081d743f1efaf8288601bec0400712012265

3 years agofix type string formatting calls
Mike Bayer [Fri, 4 Mar 2022 22:17:53 +0000 (17:17 -0500)] 
fix type string formatting calls

Fixed type-related error messages that would fail for values that were
tuples, due to string formatting syntax, including compile of unsupported
literal values and invalid boolean values.

Fixes: #7721
Change-Id: I6775721486ef2db2d0738b9aa08b9f2570f55659

3 years agocorrect for pytest discovery
Mike Bayer [Fri, 4 Mar 2022 21:28:31 +0000 (16:28 -0500)] 
correct for pytest discovery

Made corrections to the default pytest configuration so that test discovery
runs correctly; previously, a configuration error had the effect of
discovery locating the wrong files if a super-directory of the current
directory were named "test".

Fixes: #7045
Change-Id: I2e1f63a35f80ae3f53008f327d83c8342fa7f2f6

3 years agoMerge "Fix repr for MySQL SET, generic Enum" into main
mike bayer [Fri, 4 Mar 2022 20:50:48 +0000 (20:50 +0000)] 
Merge "Fix repr for MySQL SET, generic Enum" into main

3 years agoAdd LongAsMax note to mssql+pyodbc dialect docs
Gord Thompson [Fri, 4 Mar 2022 18:13:14 +0000 (11:13 -0700)] 
Add LongAsMax note to mssql+pyodbc dialect docs

Change-Id: I4491b188bae49ac615f8691dd9b7a8a341428ce7

3 years agoFix repr for MySQL SET, generic Enum
petit87 [Sat, 26 Feb 2022 21:46:32 +0000 (16:46 -0500)] 
Fix repr for MySQL SET, generic Enum

Fixed issues in :class:`_mysql.SET` datatype as well as :class:`.Enum`
where the ``__repr__()`` method would not render all optional parameters in
the string output, impacting the use of these types in Alembic
autogenerate. Pull request for MySQL courtesy Yuki Nishimine.

Fixes: #7720
Fixes: #7789
Closes: #7772
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7772
Pull-request-sha: d58845479f497f6b2e12d7df2e9eb2d6ac22109b
Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Change-Id: Idcec23eab4258511d9f32f4e3d78e511ea6021f1

3 years agoMerge "improve error raise for dialect/pool events w/ async engine" into main
mike bayer [Fri, 4 Mar 2022 17:43:17 +0000 (17:43 +0000)] 
Merge "improve error raise for dialect/pool events w/ async engine" into main

3 years agomore corrections to 1.4.31 release
Mike Bayer [Fri, 21 Jan 2022 01:33:00 +0000 (20:33 -0500)] 
more corrections to 1.4.31 release

(cherry picked from commit ab42b0e3d98386c8a13edea3206ef43f018de3b6)

Change-Id: I66414da6689d1f7fdd52056176ba9b04a415e532

3 years agocherry-pick changelog update for 1.4.32
Mike Bayer [Fri, 4 Mar 2022 16:29:54 +0000 (11:29 -0500)] 
cherry-pick changelog update for 1.4.32

(cherry picked from commit 19e6d4ffaba8cd8db5c6abfdf9e632c80c398507)

3 years agoUpdate __init__.py (#7778)
Jostein Leira [Thu, 3 Mar 2022 21:40:22 +0000 (22:40 +0100)] 
Update __init__.py (#7778)

Missing parenthesis in example code.

3 years agoquick doc adjustments
Mike Bayer [Thu, 3 Mar 2022 15:33:14 +0000 (10:33 -0500)] 
quick doc adjustments

tweet thread:  https://twitter.com/zzzeek/status/1499397255089909762

Change-Id: I5556ef707c2285e7b64c91ae5c58af52efcf4770

3 years agoremove errant comment
Mike Bayer [Thu, 3 Mar 2022 03:22:03 +0000 (22:22 -0500)] 
remove errant comment

Change-Id: I61e5a17ed079cf9c86419c7f480b651872248f6e

3 years agoimprove error raise for dialect/pool events w/ async engine
Mike Bayer [Thu, 3 Mar 2022 02:43:53 +0000 (21:43 -0500)] 
improve error raise for dialect/pool events w/ async engine

Fixed issues where a descriptive error message was not raised for some
classes of event listening with an async engine, which should instead be a
sync engine instance.

Change-Id: I00b9f4fe9373ef5fd5464fac10651cc4024f648e

3 years agoprevent Mapped[] auto-column logic w/ fixed table
Mike Bayer [Wed, 2 Mar 2022 16:51:57 +0000 (11:51 -0500)] 
prevent Mapped[] auto-column logic w/ fixed table

When a class has __table__, people will still want to
annotate the attributes on classes, so make sure a
Mapped annotation without a right side is only interpreted
as a column if there is no __table__

Change-Id: I7da4b4c43c4d2c8b6834b781569cb551e75b57b1

3 years agopep484 + abc bases for assocaitionproxy
Mike Bayer [Mon, 28 Feb 2022 04:05:46 +0000 (23:05 -0500)] 
pep484 + abc bases for assocaitionproxy

went to this one next as it was going to be hard,
and also exercises the ORM expression hierarchy a bit.
made some adjustments to SQLCoreOperations etc.

Change-Id: Ie5dde9218dc1318252826b766d3e70b17dd24ea7
References: #6810
References: #7774

3 years agoMerge "pep-484 for engine" into main
mike bayer [Wed, 2 Mar 2022 01:45:40 +0000 (01:45 +0000)] 
Merge "pep-484 for engine" into main

3 years agopep-484 for engine
Mike Bayer [Thu, 17 Feb 2022 18:43:04 +0000 (13:43 -0500)] 
pep-484 for engine

All modules in sqlalchemy.engine are strictly
typed with the exception of cursor, default, and
reflection.  cursor and default pass with non-strict
typing, reflection is waiting on the multi-reflection
refactor.

Behavioral changes:

* create_connect_args() methods return a tuple of list,
  dict, rather than a list of list, dict
* removed allow_chars parameter from
  pyodbc connector ._get_server_version_info()
  method
* the parameter list passed to do_executemany is now
  a list in all cases. previously, this was being run
  through dialect.execute_sequence_format, which
  defaults to tuple and was only intended for individual
  tuple params.
* broke up dialect.dbapi into dialect.import_dbapi
  class method and dialect.dbapi module object.  added
  a deprecation path for legacy dialects.  it's not
  really feasible to type a single attr as a classmethod
  vs. module type.  The "type_compiler" attribute also
  has this problem with greater ability to work around,
  left that one for now.
* lots of constants changing to be Enum, so that we can
  type them.  for fixed tuple-position constants in
  cursor.py / compiler.py (which are used to avoid the
  speed overhead of namedtuple), using Literal[value]
  which seems to work well
* some tightening up in Row regarding __getitem__, which
  we can do since we are on full 2.0 style result use
* altered the set_connection_execution_options and
  set_engine_execution_options event flows so that the
  dictionary of options may be mutated within the event
  hook, where it will then take effect as the actual
  options used.  Previously, changing the dict would
  be silently ignored which seems counter-intuitive
  and not very useful.
* A lot of DefaultDialect/DefaultExecutionContext
  methods and attributes, including underscored ones, move
  to interfaces.  This is not fully ideal as it means
  the Dialect/ExecutionContext interfaces aren't publicly
  subclassable directly, but their current purpose
  is more of documentation for dialect authors who should
  (and certainly are) still be subclassing the DefaultXYZ
  versions in all cases

Overall, Result was the most extremely difficult class
hierarchy to type here as this hierarchy passes through
largely amorphous "row" datatypes throughout, which
can in fact by all kinds of different things, like
raw DBAPI rows, or Row objects, or "scalar"/Any, but
at the same time these types have meaning so I tried still
maintaining some level of semantic markings for these,
it highlights how complex Result is now, as it's trying
to be extremely efficient and inlined while also being
very open-ended and extensible.

Change-Id: I98b75c0c09eab5355fc7a33ba41dd9874274f12a

3 years agotry fixing github actions again
Federico Caselli [Fri, 25 Feb 2022 21:08:09 +0000 (22:08 +0100)] 
try fixing github actions again

Change-Id: Iaf801a028510f276cf94b4999f129de8f4eb590c

3 years agorepair GH actions syntax
Mike Bayer [Fri, 25 Feb 2022 18:26:02 +0000 (13:26 -0500)] 
repair GH actions syntax

the commit in 51e6a62ab371897d646a5
included a comment that appears to not be accepted

Change-Id: I1e56293e0e75c0440073bff7190b4961cfebc353

3 years agoMerge "Add more nesting features to add_cte()" into main
mike bayer [Fri, 25 Feb 2022 17:48:30 +0000 (17:48 +0000)] 
Merge "Add more nesting features to add_cte()" into main

3 years agoMerge "Implement generic Double and related fixed types" into main
mike bayer [Fri, 25 Feb 2022 17:47:44 +0000 (17:47 +0000)] 
Merge "Implement generic Double and related fixed types" into main

3 years agoblock pypy for now
Mike Bayer [Fri, 25 Feb 2022 17:40:21 +0000 (12:40 -0500)] 
block pypy for now

the most recent pypy 7.3.8 series (3.7 and 3.9 included, likely
3.8 as well) have installed a 9 year old version of SQLite,
and additionally seem to have some other behavioral changes
like formatting of exception messages that is breaking
some tests.  as we are waiting on a response at [1]
remove pypy testing for now.

[1] https://foss.heptapod.net/pypy/pypy/-/issues/3690

Change-Id: I66650635111e71241b5c45a778954544c8d2490e

3 years agoImplement generic Double and related fixed types
zeeeeeb [Sat, 12 Feb 2022 19:00:02 +0000 (14:00 -0500)] 
Implement generic Double and related fixed types

Added :class:`.Double`, :class:`.DOUBLE`, :class:`.DOUBLE_PRECISION`
datatypes to the base ``sqlalchemy.`` module namespace, for explicit use of
double/double precision as well as generic "double" datatypes. Use
:class:`.Double` for generic support that will resolve to DOUBLE/DOUBLE
PRECISION/FLOAT as needed for different backends.

Implemented DDL and reflection support for ``FLOAT`` datatypes which
include an explicit "binary_precision" value. Using the Oracle-specific
:class:`_oracle.FLOAT` datatype, the new parameter
:paramref:`_oracle.FLOAT.binary_precision` may be specified which will
render Oracle's precision for floating point types directly. This value is
interpreted during reflection. Upon reflecting back a ``FLOAT`` datatype,
the datatype returned is one of :class:`_types.DOUBLE_PRECISION` for a
``FLOAT`` for a precision of 126 (this is also Oracle's default precision
for ``FLOAT``), :class:`_types.REAL` for a precision of 63, and
:class:`_oracle.FLOAT` for a custom precision, as per Oracle documentation.

As part of this change, the generic :paramref:`_sqltypes.Float.precision`
value is explicitly rejected when generating DDL for Oracle, as this
precision cannot be accurately converted to "binary precision"; instead, an
error message encourages the use of
:meth:`_sqltypes.TypeEngine.with_variant` so that Oracle's specific form of
precision may be chosen exactly. This is a backwards-incompatible change in
behavior, as the previous "precision" value was silently ignored for
Oracle.

Fixes: #5465
Closes: #7674
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7674
Pull-request-sha: 5c68419e5aee2e27bf21a8ac9eb5950d196c77e5

Change-Id: I831f4af3ee3b23fde02e8f6393c83e23dd7cd34d

3 years agoAdd more nesting features to add_cte()
Mike Bayer [Wed, 23 Feb 2022 17:24:31 +0000 (12:24 -0500)] 
Add more nesting features to add_cte()

Added new parameter :paramref:`.HasCTE.add_cte.nest_here` to
:meth:`.HasCTE.add_cte` which will "nest" a given :class:`.CTE` at the
level of the parent statement. This parameter is equivalent to using the
:paramref:`.HasCTE.cte.nesting` parameter, but may be more intuitive in
some scenarios as it allows the nesting attribute to be set simultaneously
along with the explicit level of the CTE.

The :meth:`.HasCTE.add_cte` method also accepts multiple CTE objects.

Fixes: #7759
Change-Id: I263c015f5a3f452cb54819aee12bc9bf2953a7bb

3 years agoFix invalid escape sequence in docs
Gord Thompson [Thu, 24 Feb 2022 19:07:26 +0000 (12:07 -0700)] 
Fix invalid escape sequence in docs

Current version of this code example will emit an
"invalid escape sequence" DeprecationWarning

Change-Id: Id753139b1661f78d6b3ba86b7ada181b693a562e

3 years agoMerge "support cx_Oracle DPI disconnect codes" into main
mike bayer [Thu, 24 Feb 2022 14:44:44 +0000 (14:44 +0000)] 
Merge "support cx_Oracle DPI disconnect codes" into main

3 years agoMerge "support add_cte() for TextualSelect" into main
mike bayer [Thu, 24 Feb 2022 14:42:20 +0000 (14:42 +0000)] 
Merge "support add_cte() for TextualSelect" into main

3 years agosupport cx_Oracle DPI disconnect codes
Mike Bayer [Wed, 23 Feb 2022 18:43:03 +0000 (13:43 -0500)] 
support cx_Oracle DPI disconnect codes

Added support to parse "DPI" error codes from cx_Oracle exception objects
such as ``DPI-1080`` and ``DPI-1010``, both of which now indicate a
disconnect scenario as of cx_Oracle 8.3.

Fixes: #7748
Change-Id: I4a10d606d512c0d7f9b4653c47ea5734afffb8a5

3 years agoAdd missing query before trying to print (#7665)
Mike Knudson [Wed, 23 Feb 2022 20:51:50 +0000 (13:51 -0700)] 
Add missing query before trying to print (#7665)

The documentation had a print before a query was run.

3 years agoFix signature for modified_json example (#7709)
Arthur Rio [Wed, 23 Feb 2022 20:50:25 +0000 (13:50 -0700)] 
Fix signature for modified_json example (#7709)

3 years agofix typo (#7747)
Yuki Nishimine [Wed, 23 Feb 2022 20:49:13 +0000 (05:49 +0900)] 
fix typo (#7747)

3 years agosupport add_cte() for TextualSelect
Mike Bayer [Wed, 23 Feb 2022 17:50:36 +0000 (12:50 -0500)] 
support add_cte() for TextualSelect

Fixed issue where the :meth:`.HasCTE.add_cte` method as called upon a
:class:`.TextualSelect` instance was not being accommodated by the SQL
compiler. The fix additionally adds more "SELECT"-like compiler behavior to
:class:`.TextualSelect` including that DML CTEs such as UPDATE and INSERT
may be accommodated.

Fixes: #7760
Change-Id: Id97062d882e9b2a81b8e31c2bfaa9cfc5f77d5c1

3 years agodisable pyright from pep 484
Mike Bayer [Wed, 23 Feb 2022 19:02:07 +0000 (14:02 -0500)] 
disable pyright from pep 484

new version of pyright is suddenly emitting an
error that makes no sense for a particular line of code,
breaking builds.  As we already have mypy which is generally
more conservative in its checking, disable pyright from CI
for now until it changes its behaviors less often.

Change-Id: I862de1b2c8a180df95c74c1c6dafa96d86c36ef1

3 years agoA small step toward modernizing ORM docs
Gord Thompson [Sun, 20 Feb 2022 22:02:53 +0000 (15:02 -0700)] 
A small step toward modernizing ORM docs

(as described in issue 7659)

Change-Id: I37cf4899721092c5714ed5af4cb8617b06dcd236

3 years agolimit new constructor scan thing for composites to dataclasses only
Mike Bayer [Tue, 22 Feb 2022 02:26:42 +0000 (21:26 -0500)] 
limit new constructor scan thing for composites to dataclasses only

Fixes: #7753
Change-Id: Ibf92fa34097a7d6b39dc71c72253034e314bd6a1

3 years agoundefer column name sooner to accommodate composites
Mike Bayer [Mon, 21 Feb 2022 21:56:16 +0000 (16:56 -0500)] 
undefer column name sooner to accommodate composites

This was from adding composite class introspection as a
means of determining column name, cols need to have their
normal attribute name set up already.

Fixes: #7751
Change-Id: I1fe61c135af9b1bf9bc289f683640e63bcc69045

3 years agoMerge "Revert SQLAlchemy warnings to warnings.py" into main
mike bayer [Mon, 21 Feb 2022 16:06:41 +0000 (16:06 +0000)] 
Merge "Revert SQLAlchemy warnings to warnings.py" into main

3 years agoRevert SQLAlchemy warnings to warnings.py
Federico Caselli [Sun, 20 Feb 2022 11:03:19 +0000 (12:03 +0100)] 
Revert SQLAlchemy warnings to warnings.py

Configuring the warning filters in pyproject breaks tests if
no sqlalchemy is installed in the env, since the filters are
processed before loading conftest.  It also may interfere
with coverage.

Revises Ia9715533b01f72aa5fdcf6a27ce75b76f829fa43
aba3ab247da4628e4e7baf993702e2efaccbc547

Change-Id: I51448a6a014f31d3088dce54cd20d1e683500f8c

3 years agoMerge "improve reflection of inline UNIQUE constraints" into main
mike bayer [Mon, 21 Feb 2022 02:28:57 +0000 (02:28 +0000)] 
Merge "improve reflection of inline UNIQUE constraints" into main

3 years agoimprove reflection of inline UNIQUE constraints
Mike Bayer [Sun, 20 Feb 2022 14:51:22 +0000 (09:51 -0500)] 
improve reflection of inline UNIQUE constraints

Fixed issue where SQLite unique constraint reflection would not work
for an inline UNIQUE constraint where the column name had an underscore
in its name.

Added support for reflecting SQLite inline unique constraints where
the column names are formatted with SQLite "escape quotes" ``[]``
or `` ` ``, which are discarded by the database when producing the
column name.

Fixes: #7736
Change-Id: I635003478dc27193995f7d7a6448f9333a498706

3 years agoremove never-used get_result_cursor_strategy() method
Mike Bayer [Sat, 19 Feb 2022 18:51:22 +0000 (13:51 -0500)] 
remove never-used get_result_cursor_strategy() method

This method I would assume got committed during the
1.4 engine refactor, where we moved from different kinds of
ResultProxy implementations to different strategy
classes instead.   These strategies are set up by
dialects by setting "self.cursor_fetch_strategy"
in the execution context.   The method here was
likely a previous iteration of that which got merged
but was never used.

Change-Id: Iec292428f41c2c245bf7ae78beaa14786c28846c

3 years agoupdates for mariadb connector 1.0.10
Mike Bayer [Sat, 19 Feb 2022 19:11:19 +0000 (14:11 -0500)] 
updates for mariadb connector 1.0.10

Fixed regression in mariadbconnector dialect as of mariadb connector 1.0.10
where the DBAPI no longer pre-buffers cursor.lastrowid. The dialect now
fetches this value proactively for situations where it applies.

test_invalidate_on_results seems to pass for mariadbconnector now.
the driver has likely changed how it buffers result sets.  This is
a major change for them to make in a point release so we might
want to watch this in case they reverse course again.

Fixes: #7738
Change-Id: I9610aae01d1ae42fa92ffbc7123a6948e40ec9dd

3 years agoMerge "pep-484 for pool" into main
mike bayer [Thu, 17 Feb 2022 21:40:58 +0000 (21:40 +0000)] 
Merge "pep-484 for pool" into main

3 years agoclarify SQLAlchemy version 2.0 constructs are not yet available
Mike Bayer [Thu, 17 Feb 2022 20:13:41 +0000 (15:13 -0500)] 
clarify SQLAlchemy version 2.0 constructs are not yet available

Fixes: #7726
Change-Id: I30646b9da5d4de6a075dedb4b42fd00b3ed7d969
(cherry picked from commit 86e42fbc83c78a577c1b7079f0aae7cbac5b29d5)

3 years agopep-484 for pool
Mike Bayer [Wed, 16 Feb 2022 04:43:51 +0000 (23:43 -0500)] 
pep-484 for pool

also extends into some areas of utils, events and others
as needed.

Formalizes a public hierarchy for pool API,
with ManagesConnection -> PoolProxiedConnection /
ConnectionPoolEntry for connectionfairy / connectionrecord,
which are now what's exposed in the event API and other
APIs.  all public API docs moved to the new objects.

Corrects the mypy plugin's check for sqlalchemy-stubs
not being insatlled, which has to be imported using the
dash in the name to be effective.

Change-Id: I16c2cb43b2e840d28e70a015f370a768e70f3581

3 years agoMerge "pep-484 for sqlalchemy.event; use future annotations" into main
mike bayer [Wed, 16 Feb 2022 00:15:54 +0000 (00:15 +0000)] 
Merge "pep-484 for sqlalchemy.event; use future annotations" into main

3 years agopep-484 for sqlalchemy.event; use future annotations
Mike Bayer [Sun, 13 Feb 2022 21:45:18 +0000 (16:45 -0500)] 
pep-484 for sqlalchemy.event; use future annotations

__future__.annotations mode allows us to use non-string
annotations for argument and return types in most cases,
but more importantly it removes a large amount of runtime
overhead that would be spent in evaluating the annotations.

Change-Id: I2f5b6126fe0019713fc50001be3627b664019ede
References: #6810

3 years agocorrect for non-deterministic gc artifacts
Mike Bayer [Tue, 15 Feb 2022 15:53:07 +0000 (10:53 -0500)] 
correct for non-deterministic gc artifacts

Observed the tests here have different profiling
counts when run individually vs. as a group, and
this seems to be due to whether or not results of
each query are garbage collected or not.  for
all but one test, ensuring results stay between
query runs seems to meet the current profiling
counts.

Change-Id: I5aca5db08936757ad2a6055c5fc077cc58979bdd

3 years agoadd note reiterating do_orm_execute() is for ORM statements only
Mike Bayer [Tue, 15 Feb 2022 13:37:44 +0000 (08:37 -0500)] 
add note reiterating do_orm_execute() is for ORM statements only

Fixes: #7707
Change-Id: I7216f63d9f4269059438e41ad8dd3dffc25a5d03

3 years agofix memusage test for 2.0
Mike Bayer [Mon, 14 Feb 2022 20:51:45 +0000 (15:51 -0500)] 
fix memusage test for 2.0

also drop 3.7, 3.8 from mypy GH action

Change-Id: Ib273219edf88ad66f591e044f0984bd364b395f5

3 years agoremove **kw from AsyncSession.begin() / AsyncSession.begin_nested()
Mike Bayer [Mon, 14 Feb 2022 14:01:56 +0000 (09:01 -0500)] 
remove **kw from AsyncSession.begin() / AsyncSession.begin_nested()

Removed the unused ``**kw`` arguments from
:class:`_asyncio.AsyncSession.begin` and
:class:`_asyncio.AsyncSession.begin_nested`. These kw aren't used and
appear to have been added to the API in error.

Fixes: #7703
Change-Id: I39ff3850929d83e6efeb7f284f2f4d5e4ca120b1

3 years agoMerge "establish mypy / typing approach for v2.0" into main
mike bayer [Sun, 13 Feb 2022 20:37:12 +0000 (20:37 +0000)] 
Merge "establish mypy / typing approach for v2.0" into main

3 years agoestablish mypy / typing approach for v2.0
Mike Bayer [Mon, 24 Jan 2022 22:04:27 +0000 (17:04 -0500)] 
establish mypy / typing approach for v2.0

large patch to get ORM / typing efforts started.
this is to support adding new test cases to mypy,
support dropping sqlalchemy2-stubs entirely from the
test suite, validate major ORM typing reorganization
to eliminate the need for the mypy plugin.

* New declarative approach which uses annotation
  introspection, fixes: #7535
* Mapped[] is now at the base of all ORM constructs
  that find themselves in classes, to support direct
  typing without plugins
* Mypy plugin updated for new typing structures
* Mypy test suite broken out into "plugin" tests vs.
  "plain" tests, and enhanced to better support test
  structures where we assert that various objects are
  introspected by the type checker as we expect.
  as we go forward with typing, we will
  add new use cases to "plain" where we can assert that
  types are introspected as we expect.
* For typing support, users will be much more exposed to the
  class names of things.  Add these all to "sqlalchemy" import
  space.
* Column(ForeignKey()) no longer needs to be `@declared_attr`
  if the FK refers to a remote table
* composite() attributes mapped to a dataclass no longer
  need to implement a `__composite_values__()` method
* with_variant() accepts multiple dialect names

Change-Id: I22797c0be73a8fbbd2d6f5e0c0b7258b17fe145d
Fixes: #7535
Fixes: #7551
References: #6810

3 years agoRaise and re-catch NameError from _ModNS
Mike Bayer [Sat, 12 Feb 2022 15:50:45 +0000 (10:50 -0500)] 
Raise and re-catch NameError from _ModNS

Fixed issue where using a fully qualified path for the classname in
:func:`_orm.relationship` that nonetheless contained an incorrect name for
path tokens that were not the first token, would fail to raise an
informative error and would instead fail randomly at a later step.

Fixes: #7697
Change-Id: I5e1a3aa4c2a6ea5b123be14666f589aec43f4b60

3 years agoremove dupe 'always" use
Mike Bayer [Fri, 11 Feb 2022 17:48:23 +0000 (12:48 -0500)] 
remove dupe 'always" use

Change-Id: Ib46d6f622fdf11f9813154c6f7a55bbe229b0184

3 years agoMerge "use QueuePool for sqlite file databases" into main
mike bayer [Fri, 11 Feb 2022 16:11:15 +0000 (16:11 +0000)] 
Merge "use QueuePool for sqlite file databases" into main

3 years agouse QueuePool for sqlite file databases
Mike Bayer [Wed, 22 Dec 2021 13:34:15 +0000 (08:34 -0500)] 
use QueuePool for sqlite file databases

The SQLite dialect now defaults to :class:`_pool.QueuePool` when a file
based database is used. This is set along with setting the
``check_same_thread`` parameter to ``False``. It has been observed that the
previous approach of defaulting to :class:`_pool.NullPool`, which does not
hold onto database connections after they are released, did in fact have a
measurable negative performance impact. As always, the pool class is always
customizable via the :paramref:`_sa.create_engine.poolclass` parameter.

Fixes: #7490
Change-Id: I5f6c259def0ef43d401c6163dc99f651e519148d

3 years agoMerge "update zimports" into main
mike bayer [Thu, 10 Feb 2022 03:56:04 +0000 (03:56 +0000)] 
Merge "update zimports" into main

3 years agodoc fixes
Mike Bayer [Thu, 10 Feb 2022 02:59:43 +0000 (21:59 -0500)] 
doc fixes

* clarify merge behavior for non-present attributes,
  references #7687
* fix AsyncSession in async_scoped_session documentation,
  name the scoped session AsyncScopedSession, fixes: #7671
* Use non-deprecated execute() style in sqltypes JSON examples,
  fixes: #7633
* Add note regarding mitigation for
  https://github.com/MagicStack/asyncpg/issues/727,
  fixes #7245

Fixes: #7671
Fixes: #7633
Fixes: #7245
Change-Id: Ic40b4378ca321367a912864f4eddfdd9714fe217

3 years agoupdate zimports
Mike Bayer [Wed, 9 Feb 2022 20:39:44 +0000 (15:39 -0500)] 
update zimports

includes new fix for formatting like black does.

also runs black on a few outliers.

Change-Id: I67446660a6bc10b73eb710389ae6d3f122af9302

3 years agoupdate Mypy plugin status
Mike Bayer [Wed, 9 Feb 2022 15:00:24 +0000 (10:00 -0500)] 
update Mypy plugin status

The Mypy plugin is not maintainable long-term and will be replaced
by new APIs that allow for typing to work inline without the need
for plugins.

Change-Id: Icc7a203df1d0b19bde2fd852719b7b7215774c58
References: #7535

3 years agoAccommodate escaped_bind_names for defaults/insert params
Mike Bayer [Tue, 8 Feb 2022 15:12:33 +0000 (10:12 -0500)] 
Accommodate escaped_bind_names for defaults/insert params

Fixed issue in Oracle dialect where using a column name that requires
quoting when written as a bound parameter, such as ``"_id"``, would not
correctly track a Python generated default value due to the bound-parameter
rewriting missing this value, causing an Oracle error to be raised.

Fixes: #7676
Change-Id: I5a54426d24f2f9b336e3597d5595fb3e031aad97

3 years agoMerge "add slotscheck to CI" into main
mike bayer [Mon, 7 Feb 2022 20:11:35 +0000 (20:11 +0000)] 
Merge "add slotscheck to CI" into main

3 years agoadd slotscheck to CI
Arie Bovenberg [Sun, 6 Feb 2022 21:37:02 +0000 (16:37 -0500)] 
add slotscheck to CI

As discussed in #7589, `slotscheck` can prevent slots-related mistakes from creeping back in.

Plan for now is to have slotscheck part of the "lint" tests
(renamed from pep8) that will run for CI and github actions.

To support slotscheck's runtime nature, slotscheck is
run twice, first with cython exts enabled and then
with them disabled via new environment variable.
Also added sqlalchemy[mypy] dependency to support slots
checking the mypy plugin.

Found and fixed one more `__slots__` issue by disabling C
exts.

Closes: #7670
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7670
Pull-request-sha: 3e77fe5449615a3c7c61ce9a1e4e79cd6636a89a

Change-Id: I90cdd284cdcee316a38856ba94d72ffc98947c5a

3 years agoMerge "apply literal value resolution to String" into main
mike bayer [Mon, 7 Feb 2022 17:50:56 +0000 (17:50 +0000)] 
Merge "apply literal value resolution to String" into main

3 years agoapply literal value resolution to String
Mike Bayer [Mon, 7 Feb 2022 17:08:51 +0000 (12:08 -0500)] 
apply literal value resolution to String

Python string values for which a SQL type is determined from the type of
the value, mainly when using :func:`_sql.literal`, will now apply the
:class:`_types.String` type, rather than the :class:`_types.Unicode`
datatype, for Python string values that test as "ascii only" using Python
``str.isascii()``. If the string is not ``isascii()``, the
:class:`_types.Unicode` datatype will be bound instead, which was used in
all string detection previously. This behavior **only applies to in-place
detection of datatypes when using ``literal()`` or other contexts that have
no existing datatype**, which is not usually the case under normal
:class:`_schema.Column` comparison operations, where the type of the
:class:`_schema.Column` being compared always takes precedence.

Use of the :class:`_types.Unicode` datatype can determine literal string
formatting on backends such as SQL Server, where a literal value (i.e.
using ``literal_binds``) will be rendered as ``N'<value>'`` instead of
``'value'``. For normal bound value handling, the :class:`_types.Unicode`
datatype also may have implications for passing values to the DBAPI, again
in the case of SQL Server, the pyodbc driver supports the use of
:ref:`setinputsizes mode <mssql_pyodbc_setinputsizes>` which will handle
:class:`_types.String` versus :class:`_types.Unicode` differently.

Fixes: #7551
Change-Id: I4f8de63e36532ae8ce4c630ee59211349ce95361

3 years agoMinor spacing fix (#7669)
spollard [Fri, 4 Feb 2022 22:23:20 +0000 (15:23 -0700)] 
Minor spacing fix (#7669)

3 years agoamend verbiage for #7667's changelog message
Mike Bayer [Fri, 4 Feb 2022 20:46:41 +0000 (15:46 -0500)] 
amend verbiage for #7667's changelog message

clarify this applies to async calling styles only.

Change-Id: I42286fe2651be13bd472fac981df9de276ed9bb1

3 years agoMerge "ensure exception raised for all stream w/ sync result" into main
mike bayer [Fri, 4 Feb 2022 20:42:15 +0000 (20:42 +0000)] 
Merge "ensure exception raised for all stream w/ sync result" into main

3 years agoMerge "fall back to SHOW VARIABLES for MySQL < 5.6" into main
mike bayer [Fri, 4 Feb 2022 20:37:41 +0000 (20:37 +0000)] 
Merge "fall back to SHOW VARIABLES for MySQL < 5.6" into main

3 years agoensure exception raised for all stream w/ sync result
Mike Bayer [Fri, 4 Feb 2022 14:04:49 +0000 (09:04 -0500)] 
ensure exception raised for all stream w/ sync result

Fixed issue where the :meth:`_asyncio.AsyncSession.execute` method failed
to raise an informative exception if the ``stream_results`` execution
option were used, which is incompatible with a sync-style
:class:`_result.Result` object. An exception is now raised in this scenario
in the same way one is already raised when using ``stream_results`` in
conjunction with the :meth:`_asyncio.AsyncConnection.execute` method.
Additionally, for improved stability with state-sensitive dialects such as
asyncmy, the cursor is now closed when this error condition is raised;
previously with the asyncmy dialect, the connection would go into an
invalid state with unconsumed server side results remaining.

Fixes: #7667
Change-Id: I6eb7affe08584889b57423a90258295f8b7085dc

3 years agofall back to SHOW VARIABLES for MySQL < 5.6
Mike Bayer [Fri, 4 Feb 2022 02:58:14 +0000 (21:58 -0500)] 
fall back to SHOW VARIABLES for MySQL < 5.6

Fixed regression caused by :ticket:`7518` where changing the syntax "SHOW
VARIABLES" to "SELECT @@" broke compatibility with MySQL versions older
than 5.6, including early 5.0 releases. While these are very old MySQL
versions, a change in compatibility was not planned, so version-specific
logic has been restored to fall back to "SHOW VARIABLES" for MySQL server
versions < 5.6.

includes unrelated orm/test_expire ordering issue , only showing
up on 1.4 / py2.7 but seems to be passing by luck otherwise

Fixes: #7518
Change-Id: Ia554080af742f2c3437f88cf3f7a4827b5e55da8

3 years agoMerge "Fix overlapping slots, base classes without slots" into main
mike bayer [Fri, 4 Feb 2022 17:11:27 +0000 (17:11 +0000)] 
Merge "Fix overlapping slots, base classes without slots" into main

3 years agoRemove duplicate word "other" in sentence (#7655)
Kurt McKee [Wed, 2 Feb 2022 19:46:40 +0000 (13:46 -0600)] 
Remove duplicate word "other" in sentence (#7655)

Spotted this while reading the docs.

Word wrapping makes it less obvious, but the sentence previously read "The phrase after "ON UPDATE" or "ON DELETE" may also ~~other~~ allow other phrases".

3 years agoFix overlapping slots, base classes without slots
Arie Bovenberg [Tue, 1 Feb 2022 20:08:19 +0000 (15:08 -0500)] 
Fix overlapping slots, base classes without slots

Some `__slots__` were not in order.

Fixes #7527

### Description

I'm fixing two types of slots mistakes:
- [x] remove overlapping slots (i.e. slots already defined on a base class)
- [x] fix broken inheritance (i.e. slots class inheriting from a non-slots class)
  - [x] slots added to base class `TransactionalContext`. It seemed to use two attributes, which I've added as slots.
  - [x] empty slots removed from `ORMOption`. Its base class explicitly makes use of `__dict__` so empty slots don't add anything.
  - [x] empty slots added to `PostLoader`. It doesn't appear to use any slots not already defined on its base classes.
  - [x] empty slots added to `IterateMappersMixin`. It doesn't appear to use any slots not already defined on its subclasses.
  - [x] empty slots added to `ImmutableContainer`. It doesn't use any fields.
  - [x] empty slots added to `OperatorType`. It's a protocol.
  - [x] empty slots added to `InternalTraversal`, `_HasTraversalDispatch`. They don't seem to use attributes on their own.

### Checklist

This pull request is:

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

**Have a nice day!**

Closes: #7589
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7589
Pull-request-sha: 70a9c4d46916b7c6907eb1d3ad4f7033ec964191

Change-Id: I6c6e3e69c3c34d0f3bdda7f0684849834fdd1863

3 years agofix typo in word 'establishing' (#7648)
Ben English [Mon, 31 Jan 2022 20:09:57 +0000 (15:09 -0500)] 
fix typo in word 'establishing' (#7648)

3 years agoadd pg14 to supported implementations
Mike Bayer [Mon, 31 Jan 2022 14:50:57 +0000 (09:50 -0500)] 
add pg14 to supported implementations

Fixes: #7647
Change-Id: I071f1a53714ebb0dc838fddc665640d46666318f

3 years agosplit out declarative varieties into the declarative mapping section
Mike Bayer [Sun, 30 Jan 2022 19:25:36 +0000 (14:25 -0500)] 
split out declarative varieties into the declarative mapping section

specific declarative styles like those for dataclasses and attrs
should be in the more reference-oriented "declarative_mapping"
section rather than the more introduction-oriented mapping_styles.

this will also make it easier for us to add still more ways of
mapping declaratively for 2.0.

Change-Id: I2700c2c2b34db9680f9cbe6ed6197add773a6a5d

3 years agoFix up Python logging metadata
Markus Gerstel [Wed, 26 Jan 2022 09:56:40 +0000 (04:56 -0500)] 
Fix up Python logging metadata

Adjusted the logging for key SQLAlchemy components including
:class:`_engine.Engine`, :class:`_engine.Connection` to establish an
appropriate stack level parameter, so that the Python logging tokens
``funcName`` and ``lineno`` when used in custom logging formatters will
report the correct information, which can be useful when filtering log
output; supported on Python 3.8 and above. Pull request courtesy Markus
Gerstel.

Fixes: #7612
Closes: #7615
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7615
Pull-request-sha: cf9567beb06680df320cb12dde1f15baa68e1eb5

Change-Id: Iff23c92ef3453ac93cbd0d190e7efbf8ea4457a2

3 years agoMerge "Add compiler support for PostgreSQL "NOT VALID" constraints." into main
mike bayer [Thu, 27 Jan 2022 14:19:02 +0000 (14:19 +0000)] 
Merge "Add compiler support for PostgreSQL "NOT VALID" constraints." into main

3 years agoAdd compiler support for PostgreSQL "NOT VALID" constraints.
Gilbert Gilb's [Sun, 23 Jan 2022 18:00:35 +0000 (13:00 -0500)] 
Add compiler support for PostgreSQL "NOT VALID" constraints.

Added compiler support for the PostgreSQL ``NOT VALID`` phrase when rendering
DDL for the :class:`.CheckConstraint`, :class:`.ForeignKeyConstraint`
and :class:`.ForeignKey` schema constructs.  Pull request courtesy
Gilbert Gilb's.

Fixes: #7600
Closes: #7601
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7601
Pull-request-sha: 78eecd55fd9fad07030d963f5fd6713c4af60e80

Change-Id: I84bfe84596856eeea2bcca45c04ad23d980a75ec

3 years agofix typing syntax in python < 3.9
Federico Caselli [Wed, 26 Jan 2022 18:44:14 +0000 (19:44 +0100)] 
fix typing syntax in python < 3.9

Change-Id: If4bca7299a333ff585de6e486ba84276cc75ab6d

3 years agoadd warning that the library is not released yet
Mike Bayer [Wed, 26 Jan 2022 13:15:16 +0000 (08:15 -0500)] 
add warning that the library is not released yet

Change-Id: I4f099f5ee5ea1e131c39d637263ebcdff70a484d
References: #7623
References: #7619

3 years agoMerge "restore set-as-superclass for OrderedSet" into main
mike bayer [Tue, 25 Jan 2022 17:51:57 +0000 (17:51 +0000)] 
Merge "restore set-as-superclass for OrderedSet" into main

3 years agorestore set-as-superclass for OrderedSet
Mike Bayer [Mon, 24 Jan 2022 23:13:05 +0000 (18:13 -0500)] 
restore set-as-superclass for OrderedSet

OrderedSet again subclasses set, spent some time
with the stubs at
https://github.com/python/typeshed/blob/master/stdlib/builtins.pyi#L887
to more deeply understand what they are doing here
so that we can type check fully.

Change-Id: Iec9b5ab43befd30e1f2c5cc40e59ab852dd28e75

3 years agojoin to existing mark expr with "and"
Mike Bayer [Tue, 25 Jan 2022 16:01:25 +0000 (11:01 -0500)] 
join to existing mark expr with "and"

ca48f461b2dcac2970829e4e0 considered an existing mark expression
plus legacy tags to be an error condition; however these can
be joined by "and" and will in our use case do the right thing.
The github action scripts make use of legacy tags.   We can change
that also but I want to just make sure this combination works
fully as well.

Change-Id: Ifc506de3dd961c01d68d594ec2f5b2c9a0bbad31

3 years agoMerge "replace test tags with pytest.mark" into main
mike bayer [Tue, 25 Jan 2022 14:59:43 +0000 (14:59 +0000)] 
Merge "replace test tags with pytest.mark" into main

3 years agoreplace test tags with pytest.mark
Mike Bayer [Tue, 25 Jan 2022 05:45:30 +0000 (00:45 -0500)] 
replace test tags with pytest.mark

replaced the __tags__ class attribute and the
--exclude-tags / --include-tags test runner options
with regular pytest.mark names
so that we can take advantage of mark expressions.
options --nomemory, --notimingintensive, --backend-only,
--exclude-tags, --include-tags remain as legacy but
make use of pytest mark for implemementation.

Added a "mypy" mark for the section of tests that are doing mypy
integration tests.

The __backend__ and __sparse_backend__ class attributes also
use pytest marks for their implementation, which also allows
the marks "backend" and "sparse_backend" to be used explicitly.

Also removed the no longer used "--cdecimal" option as this was
python 2 specific.

in theory, the usage of pytest marks could expand such that
the whole exclusions system would be based on it, but this
does not seem to have any advantage at the moment.

Change-Id: Ideeb57d9d49f0efc7fc0b6b923b31207ab783025

3 years agoreplace "e.g.::" with more context regarding attribute events example
Mike Bayer [Tue, 25 Jan 2022 14:14:32 +0000 (09:14 -0500)] 
replace "e.g.::" with more context regarding attribute events example

Fixes: #7613
Change-Id: I28a9577587399c41afd53fbd026003667654c3fc

3 years agomypy: sqlalchemy.util
Mike Bayer [Sun, 9 Jan 2022 16:49:02 +0000 (11:49 -0500)] 
mypy: sqlalchemy.util

Starting to set up practices and conventions to
get the library typed.

Key goals for typing are:

1. whole library can pass mypy without any strict
   turned on.
2. we can incrementally turn on some strict flags on a per-package/
   module basis, as here we turn on more strictness for sqlalchemy.util, exc,
   and log
3. mypy ORM plugin tests work fully without sqlalchemy2-stubs
   installed
4. public facing methods all have return types, major parameter
   signatures filled in also
5. Foundational elements like util etc. are typed enough so that
   we can use them in fully typed internals higher up the stack.

Conventions set up here:

1. we can use lots of config in setup.cfg to limit where mypy
   is throwing errors and how detailed it should be in different
   packages / modules.  We can use this to push up gerrits
   that will pass tests fully without everything being typed.
2. a new tox target pep484 is added.  this links to a new jenkins
   pep484 job that works across all projects (alembic, dogpile, etc.)

We've worked around some mypy bugs that will likely
be around for awhile, and also set up some core practices
for how to deal with certain things such as public_factory
modules (mypy won't accept a module from a callable at all,
so need to use simple type checking conditionals).

References: #6810
Change-Id: I80be58029896a29fd9f491aa3215422a8b705e12

3 years agoafter all that, use pytest warnings plugin
Mike Bayer [Sun, 23 Jan 2022 15:51:55 +0000 (10:51 -0500)] 
after all that, use pytest warnings plugin

The warnings plugin lets us set the filters up
in the config, and as our filter requirements are now
simple we can just set this up.

additionally pytest now recommends pyproject.toml, since
we fully include this now, let's move it there.

the pytest logging plugin seems to not be any problem either
at the moment, so re-enable that.  if it becomes apparent
whatever the problem was (which was probably that it was just
surprising, or something) we can disable it again and comment
what the reason was.

Change-Id: Ia9715533b01f72aa5fdcf6a27ce75b76f829fa43

3 years agoMerge "dont test squelched warnings against the filter" into main
mike bayer [Sun, 23 Jan 2022 15:06:41 +0000 (15:06 +0000)] 
Merge "dont test squelched warnings against the filter" into main

3 years agofix bullet indentation, clarify insert independent of DDL
Mike Bayer [Sun, 23 Jan 2022 14:41:52 +0000 (09:41 -0500)] 
fix bullet indentation, clarify insert independent of DDL

Change-Id: I3b6f2b7e23044148e837afdbe4fef66773e42777