]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
2 years agoUpdate test_reflection.py 8589/head
John Bodley [Fri, 30 Sep 2022 00:25:33 +0000 (17:25 -0700)] 
Update test_reflection.py

2 years agoFixes: 8588
John Bodley [Wed, 28 Sep 2022 01:35:51 +0000 (18:35 -0700)] 
Fixes: 8588
2 years agocorrect test criteria for mssql
Mike Bayer [Tue, 27 Sep 2022 14:23:28 +0000 (10:23 -0400)] 
correct test criteria for mssql

this test was failing on mssql b.c. mssql
reports false for supports_default_metavalue. however
insertmanyvalues is still used in this case, and the
assert SQL is against the default dialect in any case.

Change-Id: If8301bf4c1ed090dd1440328aba1644b597e58d8

2 years agoadd "index", "unique" to Column.merge() attrs
Mike Bayer [Tue, 27 Sep 2022 02:31:05 +0000 (22:31 -0400)] 
add "index", "unique" to Column.merge() attrs

Fixes: #8578
Change-Id: Ic79c19748d5bb00353d0a97f3a4b4f5eb9fdbb0c

2 years agoadjust for mypy 0.981
Mike Bayer [Mon, 26 Sep 2022 22:05:42 +0000 (18:05 -0400)] 
adjust for mypy 0.981

new release is out today, fix a very small number of new
issues.

Change-Id: I443c78f3384319d56deb2c9309118ffb750bbf41

2 years agoMerge "add typing for sqlalchemy.orm.validates" into main
mike bayer [Mon, 26 Sep 2022 12:57:31 +0000 (12:57 +0000)] 
Merge "add typing for sqlalchemy.orm.validates" into main

2 years agoadjust tests for sqlites w/o returning
Mike Bayer [Mon, 26 Sep 2022 12:54:59 +0000 (08:54 -0400)] 
adjust tests for sqlites w/o returning

the sqlite builds on github actions seem to be very
inconsistent about versions and many don't support
RETURNING.  ensure any tests that depend on RETURNING present
are marked as such.

Change-Id: I7a60a81fa70b90642448cdd58eda33212c3afebc

2 years agoMerge "`aggregate_order_by` now supports cache generation." into main
mike bayer [Mon, 26 Sep 2022 02:33:19 +0000 (02:33 +0000)] 
Merge "`aggregate_order_by` now supports cache generation." into main

2 years agoadd typing for sqlalchemy.orm.validates
Mike Bayer [Mon, 26 Sep 2022 01:40:48 +0000 (21:40 -0400)] 
add typing for sqlalchemy.orm.validates

Fixes: #8577
Change-Id: Iede1c956078960fb866da45f1ac6aa43842516bc

2 years agoMerge "New ORM Query Guide featuring DML support" into main
mike bayer [Mon, 26 Sep 2022 01:18:00 +0000 (01:18 +0000)] 
Merge "New ORM Query Guide featuring DML support" into main

2 years agoMerge "ORM bulk insert via execute" into main
mike bayer [Mon, 26 Sep 2022 01:17:44 +0000 (01:17 +0000)] 
Merge "ORM bulk insert via execute" into main

2 years agoMerge "implement batched INSERT..VALUES () () for executemany" into main
mike bayer [Mon, 26 Sep 2022 01:17:27 +0000 (01:17 +0000)] 
Merge "implement batched INSERT..VALUES () () for executemany" into main

2 years ago`aggregate_order_by` now supports cache generation.
Federico Caselli [Sun, 25 Sep 2022 14:37:15 +0000 (16:37 +0200)] 
`aggregate_order_by` now supports cache generation.

also adjusted CacheKeyFixture to be a general purpose
fixture so that sub-components / dialects can run
their own cache key tests.

Fixes: #8574
Change-Id: I6c66107856aee11e548d357cea77bceee3e316a0

2 years agoNew ORM Query Guide featuring DML support
Mike Bayer [Thu, 18 Aug 2022 17:56:50 +0000 (13:56 -0400)] 
New ORM Query Guide featuring DML support

reviewers:  these docs publish periodically at:
https://docs.sqlalchemy.org/en/gerrit/4042/orm/queryguide/index.html

See the "last generated" timestamp near the bottom of the
page to ensure the latest version is up

Change includes some other adjustments:

* small typing fixes for end-user benefit
* removal of a bunch of old examples for patterns that nobody
  uses or aren't really what we promote now
* modernization of some examples, including inheritance

Change-Id: I9929daab7797be9515f71c888b28af1209e789ff

2 years agoMerge "warn for local-only column in remote side" into main
mike bayer [Sun, 25 Sep 2022 23:15:46 +0000 (23:15 +0000)] 
Merge "warn for local-only column in remote side" into main

2 years agowarn for local-only column in remote side
Mike Bayer [Sun, 25 Sep 2022 18:56:22 +0000 (14:56 -0400)] 
warn for local-only column in remote side

A warning is emitted in ORM configurations when an explicit
:func:`_orm.remote` annotation is applied to columns that are local to the
immediate mapped class, when the referenced class does not include any of
the same table columns. Ideally this would raise an error at some point as
it's not correct from a mapping point of view.

Fixes: #7094
Fixes: #8575
Change-Id: Ia31be24aebe143161e19dc311b52c08fd5014d33

2 years agoUse aggregate order by instead of order by in subquery
Federico Caselli [Sun, 25 Sep 2022 16:20:22 +0000 (18:20 +0200)] 
Use aggregate order by instead of order by in subquery

Fixes: #8561
Change-Id: I2d9f6bd895061bf8fbc66723930716670791d896

2 years agoORM bulk insert via execute
Mike Bayer [Sun, 7 Aug 2022 16:14:19 +0000 (12:14 -0400)] 
ORM bulk insert via execute

* ORM Insert now includes "bulk" mode that will run
  essentially the same process as session.bulk_insert_mappings;
  interprets the given list of values as ORM attributes for
  key names
* ORM UPDATE has a similar feature, without RETURNING support,
  for session.bulk_update_mappings
* Added support for upserts to do RETURNING ORM objects as well
* ORM UPDATE/DELETE with list of parameters + WHERE criteria
  is a not implemented; use connection
* ORM UPDATE/DELETE defaults to "auto" synchronize_session;
  use fetch if RETURNING is present, evaluate if not, as
  "fetch" is much more efficient (no expired object SELECT problem)
  and less error prone if RETURNING is available
  UPDATE: howver this is inefficient!   please continue to
  use evaluate for simple cases, auto can move to fetch
  if criteria not evaluable
* "Evaluate" criteria will now not preemptively
  unexpire and SELECT attributes that were individually
  expired. Instead, if evaluation of the criteria indicates that
  the necessary attrs were expired, we expire the object
  completely (delete) or expire the SET attrs unconditionally
  (update). This keeps the object in the same unloaded state
  where it will refresh those attrs on the next pass, for
  this generally unusual case.  (originally #5664)
* Core change! update/delete rowcount comes from len(rows)
  if RETURNING was used.  SQLite at least otherwise did not
  support this.  adjusted test_rowcount accordingly
* ORM DELETE with a list of parameters at all is also a not
  implemented as this would imply "bulk", and there is no
  bulk_delete_mappings (could be, but we dont have that)
* ORM insert().values() with single or multi-values translates
  key names based on ORM attribute names
* ORM returning() implemented for insert, update, delete;
  explcit returning clauses now interpret rows in an ORM
  context, with support for qualifying loader options as well
* session.bulk_insert_mappings() assigns polymorphic identity
  if not set.
* explicit RETURNING + synchronize_session='fetch' is now
  supported with UPDATE and DELETE.
* expanded return_defaults() to work with DELETE also.
* added support for composite attributes to be present
  in the dictionaries used by bulk_insert_mappings and
  bulk_update_mappings, which is also the new ORM bulk
  insert/update feature, that will expand the composite
  values into their individual mapped attributes the way they'd
  be on a mapped instance.
* bulk UPDATE supports "synchronize_session=evaluate", is the
  default.  this does not apply to session.bulk_update_mappings,
  just the new version
* both bulk UPDATE and bulk INSERT, the latter with or without
  RETURNING, support *heterogenous* parameter sets.
  session.bulk_insert/update_mappings did this, so this feature
  is maintained.  now cursor result can be both horizontally
  and vertically spliced :)

This is now a long story with a lot of options, which in
itself is a problem to be able to document all of this
in some way that makes sense.  raising exceptions for
use cases we haven't supported is pretty important here
too, the tradition of letting unsupported things just not work
is likely not a good idea at this point, though there
are still many cases that aren't easily avoidable

Fixes: #8360
Fixes: #7864
Fixes: #7865
Change-Id: Idf28379f8705e403a3c6a937f6a798a042ef2540

2 years agoadd missing changelog for #8569
Mike Bayer [Sat, 24 Sep 2022 15:16:16 +0000 (11:16 -0400)] 
add missing changelog for #8569

Missed this in 57b400f07951f0ae8651ca383.  have no idea how.

Fixes: #8569
Change-Id: I4cec98d8c963930ef822bfd53d8a60a20be02894

2 years agoimplement batched INSERT..VALUES () () for executemany
Mike Bayer [Mon, 18 Jul 2022 19:08:37 +0000 (15:08 -0400)] 
implement batched INSERT..VALUES () () for executemany

the feature is enabled for all built in backends
when RETURNING is used,
except for Oracle that doesn't need it,  and on
psycopg2 and mssql+pyodbc it is used for all INSERT statements,
not just those that use RETURNING.

third party dialects would need to opt in to the new feature
by setting use_insertmanyvalues to True.

Also adds dialect-level guards against using returning
with executemany where we dont have an implementation to
suit it.   execute single w/ returning still defers to the
server without us checking.

Fixes: #6047
Fixes: #7907
Change-Id: I3936d3c00003f02e322f2e43fb949d0e6e568304

2 years agoAdd oracledb to whatsnew list.
Federico Caselli [Sat, 24 Sep 2022 11:05:44 +0000 (13:05 +0200)] 
Add oracledb to whatsnew list.

Change-Id: I8153a6af599a8ce6dfb45bbda13f01801eda3b6e

2 years agoMerge "Tighten password security by removing `URL.__str__`" into main
mike bayer [Sat, 24 Sep 2022 01:02:16 +0000 (01:02 +0000)] 
Merge "Tighten password security by removing `URL.__str__`" into main

2 years agoMerge "remove should_nest behavior for contains_eager()" into main
mike bayer [Sat, 24 Sep 2022 01:00:10 +0000 (01:00 +0000)] 
Merge "remove should_nest behavior for contains_eager()" into main

2 years agoTighten password security by removing `URL.__str__`
Yassen Damyanov [Thu, 22 Sep 2022 16:12:28 +0000 (12:12 -0400)] 
Tighten password security by removing `URL.__str__`

For improved security, the :class:`_url.URL` object will now use password
obfuscation by default when ``str(url)`` is called. To stringify a URL with
cleartext password, the :meth:`_url.URL.render_as_string` may be used,
passing the :paramref:`_url.URL.render_as_string.hide_password` parameter
as ``False``. Thanks to our contributors for this pull request.

Fixes: #8567
Closes: #8563
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8563
Pull-request-sha: d1f1127f753849eb70b8d6cc64badf34e1b9219b

Change-Id: If756c8073ff99ac83876d9833c8fe1d7c76211f9

2 years agoremove should_nest behavior for contains_eager()
Mike Bayer [Fri, 23 Sep 2022 19:17:57 +0000 (15:17 -0400)] 
remove should_nest behavior for contains_eager()

Fixed regression for 1.4 in :func:`_orm.contains_eager` where the "wrap in
subquery" logic of :func:`_orm.joinedload` would be inadvertently triggered
for use of the :func:`_orm.contains_eager` function with similar statements
(e.g. those that use ``distinct()``, ``limit()`` or ``offset()``). This is
not appropriate for :func:`_orm.contains_eager` which has always had the
contract that the user-defined SQL statement is unmodified with the
exception of adding the appropriate columns.

Also includes an adjustment to the assertion in Label._make_proxy()
which was there to prevent a fixed label name from being anonymized;
if the label is already anonymous, the change should proceed.
This logic was being hit before the contains_eager behavior was
adjusted. With the adjustment, this code is not used.

Fixes: #8569
Change-Id: I161e65041c0162fd2b83cbef40f57a50fcfaf0fd

2 years agoupdate whatsnew/ migration
Mike Bayer [Fri, 23 Sep 2022 17:20:16 +0000 (13:20 -0400)] 
update whatsnew/ migration

The migration20 guide had a lot of "whats new" stuff in it,
which is moved to the whatsnew20 document.

Also moved most of the content regarding the reflection rewrite
into the whatsnew20 document and added some performance comparisons
to 1.4.

The sectioning for these two documents, as has happened for some
other documents I'm working on, has been modified to only use the
double-equals operator at the top.  This is strictly because my
vscode seems to be able to show me an .rst outline in the side panel
if I do it this way, and otherwise it's blank.

Change-Id: I1c89af8b6fd47a3c14f33becc6f9ee06b1743a0f

2 years agoauto-cast PG range types
Mike Bayer [Tue, 20 Sep 2022 16:21:14 +0000 (12:21 -0400)] 
auto-cast PG range types

Range type handling has been enhanced so that it automatically
renders type casts, so that in-place round trips for statements that don't
provide the database with any context don't require the :func:`_sql.cast`
construct to be explicit for the database to know the desired type.

Change-Id: Id630b726f8a23059dd2f4cbc410bf5229d89cbfb
References: #8540

2 years agoMerge "break out text() from TextualSelect for col matching" into main
mike bayer [Tue, 20 Sep 2022 02:34:31 +0000 (02:34 +0000)] 
Merge "break out text() from TextualSelect for col matching" into main

2 years agoMerge "add raiseload to load_only()" into main
mike bayer [Mon, 19 Sep 2022 23:30:23 +0000 (23:30 +0000)] 
Merge "add raiseload to load_only()" into main

2 years agobreak out text() from TextualSelect for col matching
Mike Bayer [Mon, 19 Sep 2022 13:40:40 +0000 (09:40 -0400)] 
break out text() from TextualSelect for col matching

Fixed issue where mixing "*" with additional explicitly-named column
expressions within the columns clause of a :func:`_sql.select` construct
would cause result-column targeting to sometimes consider the label name or
other non-repeated names to be an ambiguous target.

Fixes: #8536
Change-Id: I3c845eaf571033e54c9208762344f67f4351ac3a

2 years agoadd raiseload to load_only()
Mike Bayer [Mon, 19 Sep 2022 16:18:47 +0000 (12:18 -0400)] 
add raiseload to load_only()

currently this can't be finessed in another way,
at least not easily.   The deferred() that it sets up
doesn't seem to be cancellable.  in any case, this is more consistent
API with that of defer().

Change-Id: I30fca1cc371c9102d013cda8e23a522eea1033f8

2 years agoBump pypa/cibuildwheel from 2.10.0 to 2.10.1 (#8537)
dependabot[bot] [Mon, 19 Sep 2022 19:12:02 +0000 (21:12 +0200)] 
Bump pypa/cibuildwheel from 2.10.0 to 2.10.1 (#8537)

Bumps [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel) from 2.10.0 to 2.10.1.
- [Release notes](https://github.com/pypa/cibuildwheel/releases)
- [Changelog](https://github.com/pypa/cibuildwheel/blob/main/docs/changelog.md)
- [Commits](https://github.com/pypa/cibuildwheel/compare/v2.10.0...v2.10.1)

---
updated-dependencies:
- dependency-name: pypa/cibuildwheel
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoMerge "change verbiage stating exact compliance with RFC-1738" into main
mike bayer [Sat, 17 Sep 2022 17:40:11 +0000 (17:40 +0000)] 
Merge "change verbiage stating exact compliance with RFC-1738" into main

2 years agoMerge "Improve array_agg and Array processing" into main
mike bayer [Sat, 17 Sep 2022 14:55:04 +0000 (14:55 +0000)] 
Merge "Improve array_agg and Array processing" into main

2 years agochange verbiage stating exact compliance with RFC-1738
Mike Bayer [Sat, 17 Sep 2022 14:33:55 +0000 (10:33 -0400)] 
change verbiage stating exact compliance with RFC-1738

As long as we aren't using urlparse() to parse URLs,
we are not RFC-1738 compliant.   As we accept underscores
in the scheme and not dashes or dots, we are not
RFC-1738 compliant, so emulate language like
that of PostgreSQL [1] that we "generally follow" this
scheme but include some exceptions.

[1] https://www.postgresql.org/docs/current/libpq-connect.html#id-1.7.3.8.3.6
Fixes: #8519
Change-Id: I2d7e55d9df17aed122cebb2c4c315f56c06a3da5

2 years agoremove obtuse section about "bundled bind parameters"
Mike Bayer [Sat, 17 Sep 2022 14:18:56 +0000 (10:18 -0400)] 
remove obtuse section about "bundled bind parameters"

Just looking for basics on insert in the first pages
of the tutorial I see this weird detour into something that
nobody ever uses and definitely isn't going to make sense
to the people I see complaining about our docs on twitter,
remove this.   the tutorial probably needs a big sweep
for wordy obtuse things.  the userbase is changing and
we really have a lot of brand-new-to-programming types coming
in.

Change-Id: I3bb11f0399e55edbb8f874e7eb63c40616b04e8b

2 years agoImprove array_agg and Array processing
Federico Caselli [Sat, 17 Sep 2022 11:12:35 +0000 (13:12 +0200)] 
Improve array_agg and Array processing

The :class:`_functions.array_agg` will now set the array dimensions to 1.
Improved :class:`_types.ARRAY` processing to accept ``None`` values as
value of a multi-array.

Fixes: #7083
Change-Id: Iafec4f77fde9719ccc7c8535bf6235dbfbc62102

2 years agoMerge "Ignore max_overflow when pool_size is 0" into main
mike bayer [Fri, 16 Sep 2022 22:28:45 +0000 (22:28 +0000)] 
Merge "Ignore max_overflow when pool_size is 0" into main

2 years agoMerge "Support GROUP BY ROLLUP on MySql/MariaDB" into main
mike bayer [Fri, 16 Sep 2022 22:27:14 +0000 (22:27 +0000)] 
Merge "Support GROUP BY ROLLUP on MySql/MariaDB" into main

2 years agoMerge "catch exception for system_views also" into main
mike bayer [Fri, 16 Sep 2022 22:26:25 +0000 (22:26 +0000)] 
Merge "catch exception for system_views also" into main

2 years agofix documentation typos
Federico Caselli [Fri, 16 Sep 2022 21:50:47 +0000 (23:50 +0200)] 
fix documentation typos

Closes #8527
Change-Id: I0354f3953075fa35a84b09ad45fd850d8889c992

(cherry picked from commit 02b1ed522038cbe90f9548c49ce41c29fc68032c)

2 years agoIgnore max_overflow when pool_size is 0
Federico Caselli [Thu, 15 Sep 2022 20:42:08 +0000 (22:42 +0200)] 
Ignore max_overflow when pool_size is 0

The :class:`_pool.QueuePool` now ignores ``max_overflow`` when
``pool_size=0``, properly making the pool unlimited in all cases.

Fixes: #8523
Change-Id: Ifc32eb47a281c4b3acf357352f07b9b8a73d1b6f

2 years agoMerge "Improved usage of ``asyncio.shield()``" into main
Federico Caselli [Thu, 15 Sep 2022 20:18:58 +0000 (20:18 +0000)] 
Merge "Improved usage of ``asyncio.shield()``" into main

2 years agoMerge "Use ``;`` instead of ``select 1`` to ping PostgreSQL" into main
Federico Caselli [Thu, 15 Sep 2022 20:18:39 +0000 (20:18 +0000)] 
Merge "Use ``;`` instead of ``select 1`` to ping PostgreSQL" into main

2 years agoMerge "Add type awareness to evaluator" into main
mike bayer [Thu, 15 Sep 2022 15:30:23 +0000 (15:30 +0000)] 
Merge "Add type awareness to evaluator" into main

2 years agoUse ``;`` instead of ``select 1`` to ping PostgreSQL
Federico Caselli [Tue, 13 Sep 2022 19:47:50 +0000 (21:47 +0200)] 
Use ``;`` instead of ``select 1`` to ping PostgreSQL

Fixes: #8491
Change-Id: I941d2a3cf92e5609e2045a53cec94522340951db

2 years agoImproved usage of ``asyncio.shield()``
Federico Caselli [Tue, 13 Sep 2022 19:23:12 +0000 (21:23 +0200)] 
Improved usage of ``asyncio.shield()``

Fixes: #8516
Change-Id: Ifd8f5e5f42d9fbcd5b8d00bddc81ff6be690a75e

2 years agocatch exception for system_views also
Mike Bayer [Thu, 15 Sep 2022 12:42:34 +0000 (08:42 -0400)] 
catch exception for system_views also

Fixed yet another regression in SQL Server isolation level fetch (see
:ticket:`8231`, :ticket:`8475`), this time with "Microsoft Dynamics CRM
Database via Azure Active Directory", which apparently lacks the
``system_views`` view entirely. Error catching has been extended that under
no circumstances will this method ever fail, provided database connectivity
is present.

Fixes: #8525
Change-Id: I76a429e3329926069a0367d2e77ca1124b9a059d

2 years agoadd missing doc for mariadb-connector
Mike Bayer [Thu, 15 Sep 2022 03:09:08 +0000 (23:09 -0400)] 
add missing doc for mariadb-connector

this module was never indexed.   kind of a major oversight

Change-Id: I4389a2ca3900edc70130fbae66195605a5704362

2 years agoBump pypa/cibuildwheel from 2.9.0 to 2.10.0 (#8517)
dependabot[bot] [Tue, 13 Sep 2022 19:03:28 +0000 (21:03 +0200)] 
Bump pypa/cibuildwheel from 2.9.0 to 2.10.0 (#8517)

Bumps [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel) from 2.9.0 to 2.10.0.
- [Release notes](https://github.com/pypa/cibuildwheel/releases)
- [Changelog](https://github.com/pypa/cibuildwheel/blob/main/docs/changelog.md)
- [Commits](https://github.com/pypa/cibuildwheel/compare/v2.9.0...v2.10.0)

---
updated-dependencies:
- dependency-name: pypa/cibuildwheel
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoAdd type awareness to evaluator
Mike Bayer [Tue, 13 Sep 2022 15:00:46 +0000 (11:00 -0400)] 
Add type awareness to evaluator

Fixed regression where using ORM update() with synchronize_session='fetch'
would fail due to the use of evaluators that are now used to determine the
in-Python value for expressions in the the SET clause when refreshing
objects; if the evaluators make use of math operators against non-numeric
values such as PostgreSQL JSONB, the non-evaluable condition would fail to
be detected correctly. The evaluator now limits the use of math mutation
operators to numeric types only, with the exception of "+" that continues
to work for strings as well. SQLAlchemy 2.0 may alter this further by
fetching the SET values completely rather than using evaluation.

Fixes: #8507
Change-Id: Icf7120ccbf4266499df6bb3e05159c9f50971d69

2 years agoSupport GROUP BY ROLLUP on MySql/MariaDB
Federico Caselli [Fri, 9 Sep 2022 19:29:53 +0000 (21:29 +0200)] 
Support GROUP BY ROLLUP on MySql/MariaDB

The ``ROLLUP`` function will now correctly render ``WITH ROLLUP`` on
MySql and MariaDB, allowing the use of group by rollup with these
backend.

Fixes: #8503
Change-Id: I9289af3a39ca667a2f0f84f73346ebd4b091fedd

2 years agoMerge "additional de-stringify pass for unions" into main
mike bayer [Thu, 8 Sep 2022 19:00:08 +0000 (19:00 +0000)] 
Merge "additional de-stringify pass for unions" into main

2 years agoMerge "implement icontains, istartswith, iendswith operators" into main
mike bayer [Thu, 8 Sep 2022 18:19:46 +0000 (18:19 +0000)] 
Merge "implement icontains, istartswith, iendswith operators" into main

2 years agoadditional de-stringify pass for unions
Mike Bayer [Thu, 8 Sep 2022 17:19:08 +0000 (13:19 -0400)] 
additional de-stringify pass for unions

the change in c3cfee5b00a40790c18d took out
a pass for de-stringify that broke some un-tested cases
for Optional with future annotations mode.   Adding tests
for this revealed that this was a subset of
a more general case where Union is presented
with ForwardRefs inside of it matching up within the type
map, which wasn't working before either, fixed that as well with
an additional de-stringify for elements within the Union.

Fixes: #8478
Change-Id: I8804cf6c67f14d10804584e1cddd2cfaa2376654

2 years agolimit sqlite UPDATE..FROM to 3.33.0
Mike Bayer [Thu, 8 Sep 2022 17:46:41 +0000 (13:46 -0400)] 
limit sqlite UPDATE..FROM to 3.33.0

Change-Id: I25ad8a9d6f657f85dd216b4d624f711225ef9f04
References: https://www.sqlite.org/lang_update.html

2 years agoMerge "enable UPDATE..FROM for SQLite" into main
mike bayer [Thu, 8 Sep 2022 16:31:35 +0000 (16:31 +0000)] 
Merge "enable UPDATE..FROM for SQLite" into main

2 years agoimplement icontains, istartswith, iendswith operators
Matias Martinez Rebori [Wed, 7 Sep 2022 16:36:06 +0000 (12:36 -0400)] 
implement icontains, istartswith, iendswith operators

Added long-requested case-insensitive string operators
:meth:`_sql.ColumnOperators.icontains`,
:meth:`_sql.ColumnOperators.istartswith`,
:meth:`_sql.ColumnOperators.iendswith`, which produce case-insensitive
LIKE compositions (using ILIKE on PostgreSQL, and the LOWER() function on
all other backends) to complement the existing LIKE composition operators
:meth:`_sql.ColumnOperators.contains`,
:meth:`_sql.ColumnOperators.startswith`, etc. Huge thanks to Matias
Martinez Rebori for their meticulous and complete efforts in implementing
these new methods.

Fixes: #3482
Closes: #8496
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8496
Pull-request-sha: 7287e2c436959fac4fef022f359fcc73d1528211

Change-Id: I9fcdd603716218067547cc92a2b07bd02a2c366b

2 years agoenable UPDATE..FROM for SQLite
Mike Bayer [Wed, 7 Sep 2022 21:13:23 +0000 (17:13 -0400)] 
enable UPDATE..FROM for SQLite

The SQLite dialect now supports UPDATE..FROM syntax, for UPDATE statements
that may refer to additional tables within the WHERE criteria of the
statement without the need to use subqueries. This syntax is invoked
automatically when using the :class:`_dml.Update` construct when more than
one table or other entity or selectable is used.

Fixes: #7185
Change-Id: I27e94ace9ff761cc45e652fa1abff8cd1f42fec5

2 years agoadd docs for session.get()
Mike Bayer [Wed, 7 Sep 2022 23:00:31 +0000 (19:00 -0400)] 
add docs for session.get()

also use the term "primary key" a bit more

Change-Id: Ib654b30a9d06a2aeed019b4754db920afe05d774
References: https://twitter.com/encthenet/status/1567644850471989248

2 years agocherry-pick changelog update for 1.4.42
Mike Bayer [Wed, 7 Sep 2022 00:58:38 +0000 (20:58 -0400)] 
cherry-pick changelog update for 1.4.42

2 years agocherry-pick changelog from 1.4.41
Mike Bayer [Wed, 7 Sep 2022 00:58:37 +0000 (20:58 -0400)] 
cherry-pick changelog from 1.4.41

2 years agochangelog fixes
Mike Bayer [Wed, 7 Sep 2022 00:49:15 +0000 (20:49 -0400)] 
changelog fixes

Change-Id: Ie0217dfea32d08abf7934950b1e1b381e612bb56
(cherry picked from commit 1ce530c0b25bc8a7d09b97bf300aba55d2603892)

2 years agoImprove compiled extension detection
Federico Caselli [Sun, 4 Sep 2022 19:44:46 +0000 (21:44 +0200)] 
Improve compiled extension detection

Ensure that all cython extension are imported by the compied detection logic.
This is required since cython extensions moduels are marked as optional
in the install, so it's possible that only some of them are compiled.
The extensions are enabled only if all of them are correctly compiled

Change-Id: I355cbac06f5c7a47d35661f42ebab3b0156c1965

2 years agoexpand @ sign warning to include other characters
Mike Bayer [Sat, 3 Sep 2022 15:14:27 +0000 (11:14 -0400)] 
expand @ sign warning to include other characters

Change-Id: Ied7d81ddda11f77cabc8cdc11723c95ba05a708c

2 years agoMerge "Fix Azure Synapse connection error" into main
mike bayer [Fri, 2 Sep 2022 23:21:14 +0000 (23:21 +0000)] 
Merge "Fix Azure Synapse connection error" into main

2 years agoMerge "Detection of PEP 604 union syntax." into main
mike bayer [Fri, 2 Sep 2022 14:07:26 +0000 (14:07 +0000)] 
Merge "Detection of PEP 604 union syntax." into main

2 years agoFix Azure Synapse connection error
Gord Thompson [Thu, 1 Sep 2022 17:10:20 +0000 (11:10 -0600)] 
Fix Azure Synapse connection error

Fixed regression caused by the fix for :ticket:`8231` released in 1.4.40
where connection would fail if the user does not have permission to query
the dm_exec_sessions or dm_pdw_nodes_exec_sessions system view when trying
to determine the current transaction isolation level.

Fixes: #8475
Change-Id: Ie2bcda92f2ef2d12360ddda47eb6e896313c71f2

2 years agoDetection of PEP 604 union syntax.
Peter Schutt [Thu, 1 Sep 2022 23:11:40 +0000 (19:11 -0400)] 
Detection of PEP 604 union syntax.

### Description

Fixes #8478

Handle `UnionType` as arguments to `Mapped`, e.g., `Mapped[str | None]`:

- adds `utils.typing.is_optional_union()` used to detect if a column should be nullable.
- adds `"UnionType"` to `utils.typing.is_optional()` names.
- uses `get_origin()` in `utils.typing.is_origin_of()` as `UnionType` has no `__origin__` attribute.
- tests with runtime type and postponed annotations and guard the tests running with `compat.py310`.

### 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: #8479
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8479
Pull-request-sha: 12417654822272c5847e684c53677f665553ef0e

Change-Id: Ib3248043dd4a97324ac592c048385006536b2d49

2 years agoMark extension modules as optional
Federico Caselli [Mon, 29 Aug 2022 22:26:49 +0000 (00:26 +0200)] 
Mark extension modules as optional

This greatly simplifies the setup.py file and makes it compatible with
setuptools 64+ change to editable install.

Change-Id: I16a776b175bcf67e26f4bbb8f80b1b473f585e2a

2 years agorun update_subclass anytime we add new clslevel dispatch
Mike Bayer [Wed, 31 Aug 2022 15:07:23 +0000 (11:07 -0400)] 
run update_subclass anytime we add new clslevel dispatch

Fixed event listening issue where event listeners added to a superclass
would be lost if a subclass were created which then had its own listeners
associated. The practical example is that of the :class:`.sessionmaker`
class created after events have been associated with the
:class:`_orm.Session` class.

Fixes: #8467
Change-Id: I9bdba8769147e30110a09900d4a577e833ac3af9

2 years agoFix doc snippet (#8414)
Daniel Dương [Tue, 30 Aug 2022 21:05:25 +0000 (18:05 -0300)] 
Fix doc snippet (#8414)

2 years agoMerge "include TableClause.schema in cache key" into main
mike bayer [Tue, 30 Aug 2022 17:11:03 +0000 (17:11 +0000)] 
Merge "include TableClause.schema in cache key" into main

2 years agoinclude TableClause.schema in cache key
Mike Bayer [Tue, 30 Aug 2022 14:47:24 +0000 (10:47 -0400)] 
include TableClause.schema in cache key

Fixed issue where use of the :func:`_sql.table` construct, passing a string
for the :paramref:`_sql.table.schema` parameter, would fail to take the
"schema" string into account when producing a cache key, thus leading to
caching collisions if multiple, same-named :func:`_sql.table` constructs
with different schemas were used.

Fixes: #8441
Change-Id: Ic4b55b3e8ec53b4c88ba112691bdf60ea1d4c448

2 years agoimplement event for merge/load=False for mutable state setup
Mike Bayer [Tue, 30 Aug 2022 14:25:47 +0000 (10:25 -0400)] 
implement event for merge/load=False for mutable state setup

Fixed issue in :mod:`sqlalchemy.ext.mutable` extension where collection
links to the parent object would be lost if the object were merged with
:meth:`.Session.merge` while also passing :paramref:`.Session.merge.load`
as False.

The event added here is currently private for expediency, but
is acceptable to become a public event at some point.

Fixes: #8446
Change-Id: I9e5b9f1f5a0c5a9781f51635d5e57b1134c9e866

2 years agoapply consistent ORM mutable notes for all mutable SQL types
Mike Bayer [Tue, 30 Aug 2022 13:50:03 +0000 (09:50 -0400)] 
apply consistent ORM mutable notes for all mutable SQL types

in
https://github.com/sqlalchemy/sqlalchemy/discussions/8447
I was surprised that we didnt have any notes about using Mutable
for ARRAY classes, since we have them for HSTORE and JSON.

Add a consistent topic box for these so we have something to
point towards.

Change-Id: Idfa1b2cbee67024545f4fa299e4c875075ec7d3f

2 years agoMerge "Use cibuildwheel to create wheels" into main
Federico Caselli [Tue, 30 Aug 2022 13:13:59 +0000 (13:13 +0000)] 
Merge "Use cibuildwheel to create wheels" into main

2 years agoMerge "refine ruleset to determine when poly adaption should be used" into main
mike bayer [Tue, 30 Aug 2022 04:52:57 +0000 (04:52 +0000)] 
Merge "refine ruleset to determine when poly adaption should be used" into main

2 years agorefine ruleset to determine when poly adaption should be used
Mike Bayer [Mon, 29 Aug 2022 14:43:36 +0000 (10:43 -0400)] 
refine ruleset to determine when poly adaption should be used

Fixed regression appearing in the 1.4 series where a joined-inheritance
query placed as a subquery within an enclosing query for that same entity
would fail to render the JOIN correctly for the inner query. The issue
manifested in two different ways prior and subsequent to version 1.4.18
(related issue #6595), in one case rendering JOIN twice, in the other
losing the JOIN entirely. To resolve, the conditions under which
"polymorphic loading" are applied have been scaled back to not be invoked
for simple joined inheritance queries.

Fixes: #8456
Change-Id: Ie4332fadb1dfc670cd31d098a6586a9f6976bcf7

2 years agorestore test concurrency try 2
Federico Caselli [Mon, 29 Aug 2022 18:57:01 +0000 (20:57 +0200)] 
restore test concurrency try 2

Change-Id: I54730f9683a1de3f1379ca8d2a1cab8c485e7bcc

2 years agoUse cibuildwheel to create wheels
Trevor Gross [Wed, 24 Aug 2022 10:32:31 +0000 (06:32 -0400)] 
Use cibuildwheel to create wheels

Using cibuildwheel the following wheels are created:
- windows x64 and x84
- macos x64 and arm
- linux x64 and arm on manylinux and mosulinux (for alpine)
- create a pure python wheel (for pypy and other archs)

Fixes: #6702
Fixes: #7607
Closes: #7992
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7992
Pull-request-sha: 61d5e24e5b76c97db73aa2507af7f5c2d3a948fa

Change-Id: If0c0b353766e0b61d421789d619eb2b940c08ad0

2 years agoRevert "restore test concurrency"
Mike Bayer [Mon, 29 Aug 2022 16:56:27 +0000 (12:56 -0400)] 
Revert "restore test concurrency"

This reverts commit fa30381444803af15eb128eabd7dd49609716f01.

2 years agorestore test concurrency
Federico Caselli [Sat, 27 Aug 2022 12:48:02 +0000 (14:48 +0200)] 
restore test concurrency

Change-Id: I118ce933d1fd1203e97ef2959ee6def595f1fc0b

2 years agoMerge "try out greenlet / cython on py311" into main
mike bayer [Fri, 26 Aug 2022 19:43:46 +0000 (19:43 +0000)] 
Merge "try out greenlet / cython on py311" into main

2 years agotry out greenlet / cython on py311
Mike Bayer [Thu, 25 Aug 2022 18:05:16 +0000 (14:05 -0400)] 
try out greenlet / cython on py311

I've updated jenkins to see what happens

Change-Id: If71b3f6da98dacd21419e8ece2395bc5fd20d133

2 years agorun github pipeline on python 3.11
Federico Caselli [Thu, 25 Aug 2022 18:46:46 +0000 (20:46 +0200)] 
run github pipeline on python 3.11

Change-Id: Id1f13e71b803ead2cebfcca02720ab3d6504f57c

2 years agoMerge "integrate connection.terminate() for supporting dialects" into main
mike bayer [Wed, 24 Aug 2022 18:08:17 +0000 (18:08 +0000)] 
Merge "integrate connection.terminate() for supporting dialects" into main

2 years agofix mock issue in pool test
Mike Bayer [Wed, 24 Aug 2022 17:06:09 +0000 (13:06 -0400)] 
fix mock issue in pool test

Due to the change for #5648 in ad14471bc99c2fb2315d3333a95dd,
the mock in test_recycle_pool_no_race needs to implement
an empty handle_error dispatcher.

the exception was in a thread so did not interrupt the
test suite:

File "/home/classic/dev/sqlalchemy/lib/sqlalchemy/engine/base.py", line 2059, in _handle_dbapi_exception
      for fn in self.dialect.dispatch.handle_error:
  TypeError: 'Mock' object is not iterable

Change-Id: I764357c48aa1bf53a572d8ee24c89a7463505092

2 years agointegrate connection.terminate() for supporting dialects
Mike Bayer [Tue, 23 Aug 2022 13:28:06 +0000 (09:28 -0400)] 
integrate connection.terminate() for supporting dialects

Integrated support for asyncpg's ``terminate()`` method call for cases
where the connection pool is recycling a possibly timed-out connection,
where a connection is being garbage collected that wasn't gracefully
closed, as well as when the connection has been invalidated. This allows
asyncpg to abandon the connection without waiting for a response that may
incur long timeouts.

Fixes: #8419
Change-Id: Ia575af779d5733b483a72dff3690b8bbbad2bb05

2 years agoMerge "include mssql_clustered dialect_options when reflecting - issue #8288" into...
mike bayer [Wed, 24 Aug 2022 17:00:25 +0000 (17:00 +0000)] 
Merge "include mssql_clustered dialect_options when reflecting - issue #8288" into main

2 years agoinclude mssql_clustered dialect_options when reflecting - issue #8288
John Lennox [Sun, 21 Aug 2022 05:35:44 +0000 (01:35 -0400)] 
include mssql_clustered dialect_options when reflecting - issue #8288

Implemented reflection of the "clustered index" flag ``mssql_clustered``
for the SQL Server dialect. Pull request courtesy John Lennox.

Fixes: #8288
Closes: #8289
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8289
Pull-request-sha: 1bb57352e3e31d8fb7de69ab5e60e5464949f640

Change-Id: Ife367066328f9e47ad823e4098647964a18e21e8

2 years agorepair sphinx undoc-members directive
Mike Bayer [Mon, 22 Aug 2022 19:29:31 +0000 (15:29 -0400)] 
repair sphinx undoc-members directive

"undoc-members" : False means *include* undocumented
members, it seems.

Change-Id: I90faf9b3ce3a94448b6522f7ad9946426f762900

2 years agomore function adjustments
Mike Bayer [Mon, 22 Aug 2022 17:55:08 +0000 (13:55 -0400)] 
more function adjustments

the inherited-members feature works very poorly
and inconsistently in sphinx.  just dont use it here as it
refuses to exclude ColumnOperators methods

Change-Id: Ic50865c9901e7225a99ff7f33454da15ff91b12f

2 years agoreformat functions.rst; document coalsce
Mike Bayer [Mon, 22 Aug 2022 17:43:59 +0000 (13:43 -0400)] 
reformat functions.rst; document coalsce

this file was all over the place autodocumenting all the
contents of functions.py with no regards to the heading
paragraph which seemed to be introducing the generic functions.
Use specific autoclass/autofunc docs as automodule is generally
unworkable.

Add missing docstring for coalesce function.

Fixes: #8415
Change-Id: I4c37e6153282ce99b9f5d674f6e802c25ef536e1

2 years agoMerge "support create/drop events for all CREATE/DROP" into main
mike bayer [Mon, 22 Aug 2022 13:30:36 +0000 (13:30 +0000)] 
Merge "support create/drop events for all CREATE/DROP" into main

2 years agoColumn._copy() duplicates "user defined" nullable state exactly
Mike Bayer [Sun, 21 Aug 2022 15:58:20 +0000 (11:58 -0400)] 
Column._copy() duplicates "user defined" nullable state exactly

To accommodate how mapped_column() works, after many
attempts to get this working it became clear that _copy()
should just transfer "nullable" state exactly as it was,
including the state where .nullable was set but user_defined_nullable
remains at not user set.

additionally, added a similar step to _merge() that was needed
to preserve the nullability behavior when Identity is present.

server / client default objects are not copied within column._copy()
and this should be fixed.

Fixes: #8410
Change-Id: Ib09df52b71f3e58e67e9f19b893d40a6cc4eec5c

2 years agosupport create/drop events for all CREATE/DROP
Mike Bayer [Tue, 16 Aug 2022 14:44:48 +0000 (10:44 -0400)] 
support create/drop events for all CREATE/DROP

Implemented the DDL event hooks :meth:`.DDLEvents.before_create`,
:meth:`.DDLEvents.after_create`, :meth:`.DDLEvents.before_drop`,
:meth:`.DDLEvents.after_drop` for all :class:`.SchemaItem` objects that
include a distinct CREATE or DROP step, when that step is invoked as a
distinct SQL statement, including for :class:`.ForeignKeyConstraint`,
:class:`.Sequence`, :class:`.Index`, and PostgreSQL's
:class:`_postgresql.ENUM`.

Fixes: #8394
Change-Id: Iee6274984e794f50103451a04d089641d6ac443a

2 years agoadd missing abstract concrete base changelog
Mike Bayer [Fri, 19 Aug 2022 16:30:35 +0000 (12:30 -0400)] 
add missing abstract concrete base changelog

Was missing from commit d0abdbe247dc82db51aa0af3d31b0510

Fixes: #8403
Change-Id: Ic4d9116236072ce495b5bef2671515a24d04eca2

2 years agoremove narrative "reconstructor" document
Mike Bayer [Fri, 19 Aug 2022 15:12:41 +0000 (11:12 -0400)] 
remove narrative "reconstructor" document

this event hook is not commonly used and this page does not
fit into the current narrative very well.  We should possibly
write a new paragraph regarding how instances load
at some point though the best place to put it is not clear.

2 years agoremove notes re: current pymssql DBAPI features
Mike Bayer [Fri, 19 Aug 2022 14:16:34 +0000 (10:16 -0400)] 
remove notes re: current pymssql DBAPI features

Fixes: #8337
Change-Id: Ib0c107bb386489dcb6d1683f29d0a9574dd96f1e