]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
3 years agoclarifies that @reconstructor only applies to a single method 7114/head
E. Seiver [Wed, 29 Sep 2021 19:25:36 +0000 (12:25 -0700)] 
clarifies that @reconstructor only applies to a single method

3 years agoMerge "warn or deprecate for auto-aliasing in joins"
mike bayer [Tue, 28 Sep 2021 20:14:12 +0000 (20:14 +0000)] 
Merge "warn or deprecate for auto-aliasing in joins"

3 years agoimprove bug report template. Many people don't know what dbapi is
Federico Caselli [Tue, 28 Sep 2021 18:06:20 +0000 (20:06 +0200)] 
improve bug report template. Many people don't know what dbapi is

Change-Id: Ibbe47a159292d333ae58fe046e5c32e949856d6d

3 years agoMerge "Fixes: #5151"
mike bayer [Tue, 28 Sep 2021 18:12:51 +0000 (18:12 +0000)] 
Merge "Fixes: #5151"

3 years agoMerge "Fixes: #2937"
mike bayer [Tue, 28 Sep 2021 18:00:16 +0000 (18:00 +0000)] 
Merge "Fixes: #2937"

3 years agoFixes: #2937
jonathan vanasco [Thu, 23 Sep 2021 17:06:40 +0000 (13:06 -0400)] 
Fixes: #2937
* docs for event listen kwargs
* docs for mysql to use `listen` for changing the sql_mode`

Change-Id: I7c1678488658edda3c5baaf0f7648108e93a4be1

3 years agoMerge "Fixes: #7051"
mike bayer [Tue, 28 Sep 2021 17:33:34 +0000 (17:33 +0000)] 
Merge "Fixes: #7051"

3 years agowarn or deprecate for auto-aliasing in joins
Mike Bayer [Sat, 4 Sep 2021 16:12:46 +0000 (12:12 -0400)] 
warn or deprecate for auto-aliasing in joins

An extra layer of warning messages has been added to the functionality
of :meth:`_orm.Query.join` and the ORM version of
:meth:`_sql.Select.join`, where a few places where "automatic aliasing"
continues to occur will now be called out as a pattern to avoid, mostly
specific to the area of joined table inheritance where classes that share
common base tables are being joined together without using explicit aliases.
One case emits a legacy warning for a pattern that's not recommended,
the other case is fully deprecated.

The automatic aliasing within ORM join() which occurs for overlapping
mapped tables does not work consistently with all APIs such as
``contains_eager()``, and rather than continue to try to make these use
cases work everywhere, replacing with a more user-explicit pattern
is clearer, less prone to bugs and simplifies SQLAlchemy's internals
further.

The warnings include links to the errors.rst page where each pattern is
demonstrated along with the recommended pattern to fix.

* Improved the exception message generated when configuring a mapping with
  joined table inheritance where the two tables either have no foreign key
  relationships set up, or where they have multiple foreign key relationships
  set up. The message is now ORM specific and includes context that the
  :paramref:`_orm.Mapper.inherit_condition` parameter may be needed
  particularly for the ambiguous foreign keys case.

* Add explicit support in the _expect_warnings() assertion for nested
  _expect_warnings calls

* generalize the NoCache fixture, which we also need to catch warnings
  during compilation consistently

* generalize the __str__() method for the HasCode mixin so all warnings
  and errors include the code link in their string

Fixes: #6974
Change-Id: I84ed79ba2112c39eaab7973b6d6f46de7fa80842

3 years agoFixes: #5151
jonathan vanasco [Mon, 27 Sep 2021 19:53:03 +0000 (15:53 -0400)] 
Fixes: #5151
document `listen=True` on `before_create`

Change-Id: I0804ee073044d879eb0decafeb1b358741d69f02

3 years agorepair pg8000 changelogs; state that python 2 was dropped
Mike Bayer [Mon, 27 Sep 2021 17:39:35 +0000 (13:39 -0400)] 
repair pg8000 changelogs; state that python 2 was dropped

Change-Id: I3970682d5d7bede56618d722d9068e3998bc6560
References: #7010

3 years agoFix typo introduced in #3086/I44c1a021a3e7ab7d66fea2d79a36cb2195a1969d
jonathan vanasco [Mon, 27 Sep 2021 14:13:56 +0000 (10:13 -0400)] 
Fix typo introduced in #3086/I44c1a021a3e7ab7d66fea2d79a36cb2195a1969d

Thank you @lelit

Change-Id: I98e8e0fca25d6de6c7fa6c8c0ee429e80b14c102

3 years agoFixes: #7051
jonathan vanasco [Thu, 23 Sep 2021 15:22:37 +0000 (11:22 -0400)] 
Fixes: #7051
Update documentation regarding callproc and functions/stored procedures.

Change-Id: I47bc6ec648d11604a1b1a8e4ad4581cc7612b953

3 years agoFixes: #3086
jonathan vanasco [Thu, 23 Sep 2021 20:15:27 +0000 (16:15 -0400)] 
Fixes: #3086
show that `server_defaults` can accept contextually valid SQLAlchemy expressions or constructs

Change-Id: I44c1a021a3e7ab7d66fea2d79a36cb2195a1969d

3 years agoVersion 1.4.26 placeholder
Mike Bayer [Thu, 23 Sep 2021 01:58:05 +0000 (21:58 -0400)] 
Version 1.4.26 placeholder

3 years ago- 1.4.25 rel_1_4_25
Mike Bayer [Thu, 23 Sep 2021 01:51:25 +0000 (21:51 -0400)] 
- 1.4.25

3 years agoedits
Mike Bayer [Thu, 23 Sep 2021 01:50:32 +0000 (21:50 -0400)] 
edits

Change-Id: I8227dd30b037b405872c7fb4959c225e47fe0be1

3 years agoPlatform_machine names for greenlet check
JAMES.DOW [Wed, 22 Sep 2021 21:04:19 +0000 (17:04 -0400)] 
Platform_machine names for greenlet check

Fixed regression due to #7024 where the reorganization of the "platform
machine" names for greenlet dependency mis-spelled "aarch64" and
additionally omitted uppercase "AMD64" as is needed for windows machines.
Pull request courtesy James Dow.

Fixes: #7024
Closes: #7069
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7069
Pull-request-sha: dbd7419e21d2eb96a02b34a7f41de8a0382be559

Change-Id: Ia2793376a8fbb71d9b5b02fdc955dddbc0a0e80e

3 years agoVersion 1.4.25 placeholder
Mike Bayer [Wed, 22 Sep 2021 15:26:12 +0000 (11:26 -0400)] 
Version 1.4.25 placeholder

3 years ago- 1.4.24 rel_1_4_24
Mike Bayer [Wed, 22 Sep 2021 15:18:00 +0000 (11:18 -0400)] 
- 1.4.24

3 years agochangelog, doc edits
Mike Bayer [Wed, 22 Sep 2021 15:16:04 +0000 (11:16 -0400)] 
changelog, doc edits

Change-Id: Iafb50de7e28626d9cee755db9c05ac7189b4d963

3 years agoMerge "coerce for multivalues keys"
mike bayer [Wed, 22 Sep 2021 03:25:12 +0000 (03:25 +0000)] 
Merge "coerce for multivalues keys"

3 years agoMerge "implement _all_selected_columns for functionelement"
mike bayer [Wed, 22 Sep 2021 03:19:55 +0000 (03:19 +0000)] 
Merge "implement _all_selected_columns for functionelement"

3 years agoMerge "include setup_joins targets when scanning for FROM objects to clone"
mike bayer [Wed, 22 Sep 2021 03:19:31 +0000 (03:19 +0000)] 
Merge "include setup_joins targets when scanning for FROM objects to clone"

3 years agocoerce for multivalues keys
Mike Bayer [Wed, 22 Sep 2021 02:35:41 +0000 (22:35 -0400)] 
coerce for multivalues keys

Fixed issue where using ORM column expressions as keys in the list of
dictionaries passed to :meth:`_sql.Insert.values` for "multi-valued insert"
would not be processed correctly into the correct column expressions.

Fixes: #7060
Change-Id: I1c4c286c33ea6eeaafba617996828f5c88ff0a1c

3 years agoadd note to "quote" regarding case insensitive table reflection
Mike Bayer [Wed, 22 Sep 2021 01:12:15 +0000 (21:12 -0400)] 
add note to "quote" regarding case insensitive table reflection

this note basically states that the use case requested in
issue #7026 is not supported.  I'm not sure the note is
going to otherwise make sense to  anyone.

Fixes: #7026
Change-Id: Ib7782afc9bc5dc0c43cfab9b1f969a55c43209fe

3 years agoFix order of warnings filters 7062/head
rallyemax [Tue, 21 Sep 2021 22:27:41 +0000 (16:27 -0600)] 
Fix order of warnings filters

The `warnings.filterwarnings` method inserts entries at the front of the filter list, and entries closer to the front of the list override entries later in the list, if both match a particular warning. (See https://docs.python.org/3/library/warnings.html)

The intended behavior is for all `RemovedIn20Warning` warnings to log and continue, except that specific warnings that match the defined regular expressions should be raised as exceptions. To accomplish this intent, the general filter must be inserted before the regular expression special cases.

The original order would work if `warnings.filterwarnings` for the default case were invoked with `append=True`, but the intent of the documentation is for this set of filters to be determinative (i.e. to override any conflicting pre-existing filters that may exist), so `append=True` should not be used.

3 years agoinclude setup_joins targets when scanning for FROM objects to clone
Mike Bayer [Mon, 20 Sep 2021 17:43:21 +0000 (13:43 -0400)] 
include setup_joins targets when scanning for FROM objects to clone

Fixed a two issues where combinations of ``select()`` and ``join()`` when
adapted to form a copy of the element would not completely copy the state
of all column objects associated with subqueries. A key problem this caused
is that usage of the :meth:`_sql.ClauseElement.params` method (which should
probably be moved into a legacy category as it is inefficient and error
prone) would leave copies of the old :class:`_sql.BindParameter` objects
around, leading to issues in correctly setting the parameters at execution
time.

Fixes: #7055
Change-Id: Ib822a978a99561b4402da3fb727b370f5c58210b

3 years agoMerge "Relax the Python version check for `__class_getitem__` tests"
mike bayer [Mon, 20 Sep 2021 19:21:48 +0000 (19:21 +0000)] 
Merge "Relax the Python version check for `__class_getitem__` tests"

3 years agoimplement _all_selected_columns for functionelement
Mike Bayer [Mon, 20 Sep 2021 19:16:56 +0000 (15:16 -0400)] 
implement _all_selected_columns for functionelement

Implemented a method in ``FunctionElement`` that is essentially abstract in
an ancestor class (even though not used), leading to pylint complaints.

Fixes: #7052
Change-Id: Iceeeb332fbb3c7187cd2b1969e2f4233a47136b1

3 years agoclarify "encoding" parameter further
Mike Bayer [Mon, 20 Sep 2021 13:48:57 +0000 (09:48 -0400)] 
clarify "encoding" parameter further

Prevent any reading of this parameter that would omit that it
is not used under Python 3 and in Python 2 is not used very
much either.

Fixes: #7050
Change-Id: Iaf619f1ee164fc58afe710d11627ed6368d74343

3 years agoRemove misplaced apostrophe in tutorial/index.rst (#7043)
JMcB17 [Sun, 19 Sep 2021 16:30:24 +0000 (17:30 +0100)] 
Remove misplaced apostrophe in tutorial/index.rst (#7043)

Citation: http://www.sussex.ac.uk/informatics/punctuation/apostrophe/possessives

3 years agoRelax the Python version check for `__class_getitem__` tests
layday [Sun, 19 Sep 2021 15:58:05 +0000 (11:58 -0400)] 
Relax the Python version check for `__class_getitem__` tests

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

### Description
`__class_getitem__` to support generics was introduced in Python 3.7.
In 3.9 some built-ins were made generic but the functionality
for user-defined classes has been there since 3.7.

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

Change-Id: I4f45b9585d263636e613cc5c86e710fa31c7d283

3 years agoMerge "pin asyncmy>=0.2.0 and remove cursor close workarounds"
mike bayer [Sat, 18 Sep 2021 14:55:49 +0000 (14:55 +0000)] 
Merge "pin asyncmy>=0.2.0 and remove cursor close workarounds"

3 years agoMerge "Surface driver connection object when using a proxied dialect"
mike bayer [Sat, 18 Sep 2021 14:00:16 +0000 (14:00 +0000)] 
Merge "Surface driver connection object when using a proxied dialect"

3 years agopin asyncmy>=0.2.0 and remove cursor close workarounds
Mike Bayer [Sat, 18 Sep 2021 13:47:34 +0000 (09:47 -0400)] 
pin asyncmy>=0.2.0 and remove cursor close workarounds

Change-Id: I9426e09e4fd21f9c94f3c89b199a7784d33b949f

3 years agoSurface driver connection object when using a proxied dialect
Federico Caselli [Tue, 31 Aug 2021 21:03:18 +0000 (23:03 +0200)] 
Surface driver connection object when using a proxied dialect

Improve the interface used by adapted drivers, like the asyncio ones,
to access the actual connection object returned by the driver.

The :class:`_engine._ConnectionRecord` and
:class:`_engine._ConnectionFairy` now have two new attributes:

* ``dbapi_connection`` always represents a DBAPI compatible
object.  For pep-249 drivers, this is the DBAPI connection as it always
has been, previously accessed under the ``.connection`` attribute.
For asyncio drivers that SQLAlchemy adapts into a pep-249 interface,
the returned object will normally be a SQLAlchemy adaption object
called :class:`_engine.AdaptedConnection`.
* ``driver_connection`` always represents the actual connection object
maintained by the third party pep-249 DBAPI or async driver in use.
For standard pep-249 DBAPIs, this will always be the same object
as that of the ``dbapi_connection``.  For an asyncio driver, it will be
the underlying asyncio-only connection object.

The ``.connection`` attribute remains available and is now a legacy alias
of ``.dbapi_connection``.

Fixes: #6832
Change-Id: Ib72f97deefca96dce4e61e7c38ba430068d6a82e

3 years agoadd attribute sphinx is breaking on
Mike Bayer [Fri, 17 Sep 2021 21:27:46 +0000 (17:27 -0400)] 
add attribute sphinx is breaking on

the hybridmethod internal seems to be confusing
a recent version of sphinx autodoc, add attribute it's searching
for.

Change-Id: I27f671a51f857b62337cc2374bbc87383ae9710d

3 years agovendor asynccontextmanager
Mike Bayer [Fri, 17 Sep 2021 18:34:51 +0000 (14:34 -0400)] 
vendor asynccontextmanager

while we still support python 3.6 vendor a simple version
of this for now in the one place we currently use it.

Change-Id: Ibcfc8b004b17e2ac79f9123ccb76c5eb25243f90

3 years agoMerge "Add `asyncmy` support"
mike bayer [Fri, 17 Sep 2021 17:35:55 +0000 (17:35 +0000)] 
Merge "Add `asyncmy` support"

3 years agoImplement nesting CTE
Eric Masseran [Mon, 13 Sep 2021 17:45:57 +0000 (13:45 -0400)] 
Implement nesting CTE

Added new parameter :meth:`_sql.HasCte.cte.nesting` to the
:class:`_sql.CTE` constructor and :meth:`_sql.HasCTE.cte` method, which
flags the CTE as one which should remain nested within an enclosing CTE,
rather than being moved to the top level of the outermost SELECT. While in
the vast majority of cases there is no difference in SQL functionality,
users have identified various edge-cases where true nesting of CTE
constructs is desirable. Much thanks to Eric Masseran for lots of work on
this intricate feature.

Fixes: #4123
Closes: #6709
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6709
Pull-request-sha: 64ab2f6ea269f2dcf37376a13ea38c48c5226fb6

Change-Id: Ic4dc25ab763af96d96632369e01527d48a654149

3 years agoMerge "References: #5831"
mike bayer [Fri, 17 Sep 2021 15:30:31 +0000 (15:30 +0000)] 
Merge "References: #5831"

3 years agoMerge "use the stack for insert_from_select"
mike bayer [Fri, 17 Sep 2021 15:30:07 +0000 (15:30 +0000)] 
Merge "use the stack for insert_from_select"

3 years agoMerge "test update_nowait - added support in MariaDB-10.3"
mike bayer [Fri, 17 Sep 2021 15:22:21 +0000 (15:22 +0000)] 
Merge "test update_nowait - added support in MariaDB-10.3"

3 years agoAdd `asyncmy` support
long2ice [Thu, 16 Sep 2021 15:08:25 +0000 (11:08 -0400)] 
Add `asyncmy` support

Added initial support for the ``asyncmy`` asyncio database driver for MySQL
and MariaDB. This driver is very new, however appears to be the only
current alternative to the ``aiomysql`` driver which currently appears to
be unmaintained and is not working with current Python versions. Much
thanks to long2ice for the pull request for this dialect.

Fixes: #6993
Closes: #7000
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7000
Pull-request-sha: f7d6c811fc72324a83c8af635bbca8b268b0098e

Change-Id: I4ef54b43334feff7e3a710fc4de6821437f3bb68

3 years agouse the stack for insert_from_select
Mike Bayer [Thu, 16 Sep 2021 17:38:11 +0000 (13:38 -0400)] 
use the stack for insert_from_select

Fixed issue related to new ``add_cte()`` feature where pairing two
"INSERT..FROM SELECT" statements simultaneously would lose track of the two
independent SELECT statements, leading to the wrong SQL.

Fixes: #7036
Change-Id: I90fe47eb203bc5c1ea5810db0edba08250b2b7e6

3 years agoMerge "test_for_update to recognise skip_locked for MariaDB-10.6"
mike bayer [Thu, 16 Sep 2021 15:33:11 +0000 (15:33 +0000)] 
Merge "test_for_update to recognise skip_locked for MariaDB-10.6"

3 years agotest update_nowait - added support in MariaDB-10.3
Daniel Black [Sun, 12 Sep 2021 05:17:50 +0000 (01:17 -0400)] 
test update_nowait - added support in MariaDB-10.3

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

MariaDB supported NOWAIT in 10.3.

ref: https://mariadb.com/kb/en/wait-and-nowait/

This pull request is:

- [X] very trivial test change
- [ ] 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: #7009
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7009
Pull-request-sha: 4fa750e3d34638be7e9583d849216f6d90ca88fc

Change-Id: I4ee8cf2cf84daf7af3300e6f80671375232fcf02

3 years agoMerge "Fixes: #5289"
mike bayer [Wed, 15 Sep 2021 20:56:38 +0000 (20:56 +0000)] 
Merge "Fixes: #5289"

3 years agoMerge "Fixes: #6930"
mike bayer [Wed, 15 Sep 2021 20:54:25 +0000 (20:54 +0000)] 
Merge "Fixes: #6930"

3 years agoMerge "Fixes: #5596 replace `assert` with ValueError, as assert is optimized away...
mike bayer [Wed, 15 Sep 2021 13:10:22 +0000 (13:10 +0000)] 
Merge "Fixes: #5596 replace `assert` with ValueError, as assert is optimized away by cpython"

3 years agoMerge "Add scalars method to connection and session classes"
mike bayer [Wed, 15 Sep 2021 13:09:41 +0000 (13:09 +0000)] 
Merge "Add scalars method to connection and session classes"

3 years agoFixes: #5596
jonathan vanasco [Wed, 8 Sep 2021 18:19:24 +0000 (14:19 -0400)] 
Fixes: #5596
replace `assert` with ValueError, as assert is optimized away by cpython

Change-Id: I963ec962ee0b03935b4cda76abcf82f71274aba8

3 years agoAdd scalars method to connection and session classes
Miguel Grinberg [Mon, 13 Sep 2021 18:41:13 +0000 (14:41 -0400)] 
Add scalars method to connection and session classes

Added new methods :meth:`_orm.Session.scalars`,
:meth:`_engine.Connection.scalars`, :meth:`_asyncio.AsyncSession.scalars`
and :meth:`_asyncio.AsyncSession.stream_scalars`, which provide a short cut
to the use case of receiving a row-oriented :class:`_result.Result` object
and converting it to a :class:`_result.ScalarResult` object via the
:meth:`_engine.Result.scalars` method, to return a list of values rather
than a list of rows. The new methods are analogous to the long existing
:meth:`_orm.Session.scalar` and :meth:`_engine.Connection.scalar` methods
used to return a single value from the first row only. Pull request
courtesy Miguel Grinberg.

Fixes: #6990
Closes: #6991
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6991
Pull-request-sha: b3e0bb3042c55b0cc5af6a25cb3f31b929f88a47

Change-Id: Ia445775e24ca964b0162c2c8e5ca67dd1e39199f

3 years agoMerge "replace "in" operator with "==" + "or" for greenlet platforms"
mike bayer [Tue, 14 Sep 2021 16:43:01 +0000 (16:43 +0000)] 
Merge "replace "in" operator with "==" + "or" for greenlet platforms"

3 years agoMerge "Ensure str is callect on the URL password."
mike bayer [Tue, 14 Sep 2021 16:42:00 +0000 (16:42 +0000)] 
Merge "Ensure str is callect on the URL password."

3 years agoEnsure str is callect on the URL password.
Federico Caselli [Wed, 8 Sep 2021 20:25:12 +0000 (22:25 +0200)] 
Ensure str is callect on the URL password.

Ensure that ``str()`` is called on the an ``URL.password`` argument,
allowing usage of objects that implement the ``__str__()`` method
as password attributes.
Also clarified that one such object is not appropriate to dynamically
change the password.

Fixes: #6958
Change-Id: Id0690990a64b9e0935537b7b8f5a73efe6a9e3dc

3 years agoreplace "in" operator with "==" + "or" for greenlet platforms
Mike Bayer [Mon, 13 Sep 2021 18:38:02 +0000 (14:38 -0400)] 
replace "in" operator with "==" + "or" for greenlet platforms

Further adjusted the "greenlet" package specifier in setup.cfg to use a
long chain of "or" expressions, so that the comparison of
``platform_machine`` to a specific identifier matches only the complete
string.

Fixes: #7024
Change-Id: I1cd40f5e14c62c21bd2e530ca8e38a5a3d50d353

3 years agotest_update_delete - fix the fixed comment (#7020)
Daniel Black [Sun, 12 Sep 2021 18:46:48 +0000 (04:46 +1000)] 
test_update_delete - fix the fixed comment (#7020)

Spelling Criteria right.

Fixes 3ea321ce22438c5b7450e027d087437474eb4498

Also makes it PEP8 compatible again to be under 80
characters.

3 years agoFix various lib / test / examples typos (#7017)
Kevin Kirsche [Sat, 11 Sep 2021 20:26:59 +0000 (16:26 -0400)] 
Fix various lib / test / examples typos (#7017)

* fix: lib/sqlalchemy/sql/lambdas.py

* fix: lib/sqlalchemy/sql/compiler.py

* fix: lib/sqlalchemy/sql/selectable.py

* fix: lib/sqlalchemy/orm/relationships.py

* fix: lib/sqlalchemy/dialects/mssql/base.py

* fix: lib/sql/test_compiler.py

* fix: lib/sqlalchemy/testing/requirements.py

* fix: lib/sqlalchemy/orm/path_registry.py

* fix: lib/sqlalchemy/dialects/postgresql/psycopg2.py

* fix: lib/sqlalchemy/cextension/immutabledict.c

* fix: lib/sqlalchemy/cextension/resultproxy.c

* fix: ./lib/sqlalchemy/dialects/oracle/cx_oracle.py

* fix: examples/versioned_rows/versioned_rows_w_versionid.py

* fix: examples/elementtree/optimized_al.py

* fix: test/orm/test_attribute.py

* fix: test/sql/test_compare.py

* fix: test/sql/test_type_expression.py

* fix: capitalization in test/dialect/mysql/test_compiler.py

* fix: typos in test/dialect/postgresql/test_reflection.py

* fix: typo in tox.ini comment

* fix: typo in /lib/sqlalchemy/orm/decl_api.py

* fix: typo in test/orm/test_update_delete.py

* fix: self-induced typo

* fix: typo in test/orm/test_query.py

* fix: typos in test/dialect/mssql/test_types.py

* fix: typo in test/sql/test_types.py

3 years agoREADME.unittest container edits mainly mariadb/mysql (#7014)
Daniel Black [Sat, 11 Sep 2021 20:22:47 +0000 (06:22 +1000)] 
README.unittest container edits mainly mariadb/mysql (#7014)

Simplify it a bit:

* test_schema2 isn't needed in MySQL/MariaDB test.
* Only permissions on test_schema are needed.
* User without qualification defaults to user@'%'.
* Use MARIADB_* names with MariaDB container that has
  been there most of this year in releases.
* We don't need to specify a database on connection
  when creating users/databases.
* On all containers - docker will always pull image
  if not available. Also postgres image didn't match
  container initialization.
* Remove container versions, just use latest

3 years agoFix documentation mistake (#7018)
owgreen [Sat, 11 Sep 2021 20:04:31 +0000 (05:04 +0900)] 
Fix documentation mistake (#7018)

3 years agoMerge "ignore and warn for native_enum=False with pg.ENUM datatype"
mike bayer [Fri, 10 Sep 2021 15:58:43 +0000 (15:58 +0000)] 
Merge "ignore and warn for native_enum=False with pg.ENUM datatype"

3 years agoignore and warn for native_enum=False with pg.ENUM datatype
Mike Bayer [Tue, 30 Mar 2021 19:22:01 +0000 (15:22 -0400)] 
ignore and warn for native_enum=False with pg.ENUM datatype

any UPPERCASE datatype refers to that exact type name rendered
on the database.   So PG's ENUM must render "ENUM" and is
"native" by definition.  warn if this flag is passed.

The :class:`_postgresql.ENUM` datatype is PostgreSQL-native and therefore
should not be used with the ``native_enum=False`` flag. This flag is now
ignored if passed to the :class:`_postgresql.ENUM` datatype and a warning
is emitted; previously the flag would cause the type object to fail to
function correctly.

Fixes: #6106
Change-Id: I08e0ec6fcfafd068e1eaf6aec13c8010f09ce94a

3 years agoMerge "Modernize tests - remaining DML"
mike bayer [Fri, 10 Sep 2021 14:22:05 +0000 (14:22 +0000)] 
Merge "Modernize tests - remaining DML"

3 years agoMerge "turn off deduping for col expressions"
mike bayer [Fri, 10 Sep 2021 14:21:42 +0000 (14:21 +0000)] 
Merge "turn off deduping for col expressions"

3 years agobulk_save->return_defaults does not populate server defaults
Mike Bayer [Fri, 10 Sep 2021 14:07:15 +0000 (10:07 -0400)] 
bulk_save->return_defaults does not populate server defaults

it fetches them but doesn't put them on the objects, which
is likely a bug, however i have no intention of working
on the bulk methods.   Add more documentation to strongly
discourage these methods in favor of more explicit bulk
approaches, e.g. using an insert() construct directly.

Fixes: #6273
Change-Id: I83eac9319f4e35111302cc81471ecaf19514ce86

3 years agofix mysql-connector-python dep
Mike Bayer [Fri, 10 Sep 2021 13:47:37 +0000 (09:47 -0400)] 
fix mysql-connector-python dep

Fixes: #7012
Change-Id: Ie4e32a9c0f084bfeb10dbecf021db0b70208379a

3 years agodocument placement of declarative init method
Mike Bayer [Fri, 10 Sep 2021 13:42:11 +0000 (09:42 -0400)] 
document placement of declarative init method

Fixes: #7013
Fixes: #7015
Change-Id: Iba7eb8aeb37cec08e1bd1edcf28e05b02004afe7

3 years agoFix typo (#6994)
Yutian Li [Wed, 8 Sep 2021 19:16:22 +0000 (15:16 -0400)] 
Fix typo (#6994)

3 years agofix: typos in doc/build/tutorial (#7005)
Kevin Kirsche [Wed, 8 Sep 2021 19:14:56 +0000 (15:14 -0400)] 
fix: typos in doc/build/tutorial (#7005)

3 years agofix: typos in doc/build/changelog (#7004)
Kevin Kirsche [Wed, 8 Sep 2021 19:14:50 +0000 (15:14 -0400)] 
fix: typos in doc/build/changelog (#7004)

3 years agofix: typos in doc/build/core and doc/build/errors (#7006)
Kevin Kirsche [Wed, 8 Sep 2021 19:14:43 +0000 (15:14 -0400)] 
fix: typos in doc/build/core and doc/build/errors (#7006)

3 years agofix: typos in doc/build/orm (#7003)
Kevin Kirsche [Wed, 8 Sep 2021 19:14:31 +0000 (15:14 -0400)] 
fix: typos in doc/build/orm (#7003)

* fix: typos in doc/build/orm

* though -> through

Change-Id: I785336056497a4ac17f2d494f6d9cf913c12b024

Co-authored-by: Federico Caselli <cfederico87@gmail.com>
3 years agoReferences: #5831
jonathan vanasco [Wed, 8 Sep 2021 17:27:20 +0000 (13:27 -0400)] 
References: #5831

Add a note to docs regarding future session under asyncio

Change-Id: Ib152be833dcb8ea46217e761a715f639859133c6

3 years agoFixes: #5289
jonathan vanasco [Wed, 8 Sep 2021 16:50:10 +0000 (12:50 -0400)] 
Fixes: #5289
Clarify Foreign Key support on SQLite must be enabled before `MetaData.create_all`

Change-Id: Ic41b86f736be21dd6fc890a915a2ffd572df73a4

3 years agoFixes: #6930
jonathan vanasco [Wed, 8 Sep 2021 16:39:02 +0000 (12:39 -0400)] 
Fixes: #6930
Note in docstrings that ignored kwargs are required for API conformance.

Change-Id: Icc9a8c63c0936a7c5255841ef49d10a83496763a

3 years agotest_for_update to recognise skip_locked for MariaDB-10.6
Daniel Black [Wed, 8 Sep 2021 07:12:16 +0000 (03:12 -0400)] 
test_for_update to recognise skip_locked for MariaDB-10.6

### Description

Alters the test for skip_locked to recognize that `SKIP LOCKED` was added to the MariaDB syntax in 10.6.0 https://mariadb.com/kb/en/select/#skip-locked.

### Checklist

This pull request is:

- [X] A minor test case fix
- [ ] 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!**

:smile: You too :boat:

Note:

```
$ podman run  --rm  -d -e MARIADB_USER=scott -e MARIADB_PASSWORD=tiger -e MARIADB_DATABASE=test -e MARIADB_RANDOM_ROOT_PASSWORD=1  -P mariadb:10.6
7248491216e93320d7eff4c8c3a9f8c6b6c43cc84a7a65e721265616f8854f4d

$ podman port 7248491216e93320d7eff4c8c3a9f8c6b6c43cc84a7a65e721265616f8854f4d   3306
0.0.0.0:43809

$ pytest --db  mariadb  --dburi   mariadb://scott:tiger@127.0.0.1:43809/test  test/dialect/mysql/test_for_update.py
...
INTERNALERROR>   File "/home/dan/.py3/lib64/python3.9/site-packages/MySQLdb/connections.py", line 185, in __init__
INTERNALERROR>     super().__init__(*args, **kwargs2)
INTERNALERROR> sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError) (2002, "Can't connect to MySQL server on '127.0.0.1' (115)")
INTERNALERROR> (Background on this error at: https://sqlalche.me/e/14/e3q8)
```
Some queries where executed on the container instance however there's something in the test hard-coded to 3306 (observed in strace). And/or I'm doing something incorrectly.

Closes: #6998
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6998
Pull-request-sha: a8f9c05abea0795cfa39cd972e096e4581dbf892

Change-Id: I3cd41587d7207f0e6747dea97d6be1e33d7c7aa0

3 years agoMerge branch 'workflow_test_aiosqlite' into master_gerrit
Federico Caselli [Mon, 6 Sep 2021 21:22:58 +0000 (23:22 +0200)] 
Merge branch 'workflow_test_aiosqlite' into master_gerrit

Change-Id: I81767d0c0b99aa1c125e5879232b3613e1d3c178

3 years agoAdd async tests to the github workflow
Federico Caselli [Mon, 6 Sep 2021 19:12:03 +0000 (21:12 +0200)] 
Add async tests to the github workflow

Fixes: #6967
Change-Id: I222cb5bdedf572e734c827d72bcbced202cdd62f

3 years agoMerge "remove erroneous None check from _assert_str"
mike bayer [Sat, 4 Sep 2021 16:21:25 +0000 (16:21 +0000)] 
Merge "remove erroneous None check from _assert_str"

3 years agoremove erroneous None check from _assert_str
Mike Bayer [Sat, 4 Sep 2021 15:29:10 +0000 (11:29 -0400)] 
remove erroneous None check from _assert_str

Fixed issue in ``URL`` where validation of "drivername" would not
appropriately respond to the ``None`` value where a string were expected.

Fixes: #6983
Change-Id: If546c373a60533779595a9e393ea9a59a9b8a96f

3 years agoturn off deduping for col expressions
Mike Bayer [Thu, 2 Sep 2021 18:11:38 +0000 (14:11 -0400)] 
turn off deduping for col expressions

Fixed ORM issue where column expressions passed to ``query()`` or
ORM-enabled ``select()`` would be deduplicated on the identity of the
object, such as a phrase like ``select(A.id, null(), null())`` would
produce only one "NULL" expression, which previously was not the case in
1.3. However, the change also allows for ORM expressions to render as given
as well, such as ``select(A.data, A.data)`` will produce a result row with
two columns.

Fixes: #6979
Change-Id: I4dd59d4c7b1baa711b686379eb959f87c44841c4

3 years agoAdded loader options to session.merge, asyncsession.merge
Daniel Stone [Mon, 30 Aug 2021 15:15:25 +0000 (11:15 -0400)] 
Added loader options to session.merge, asyncsession.merge

Added loader options to :meth:`_orm.Session.merge` and
:meth:`_asyncio.AsyncSession.merge`, which will apply the given loader
options to the ``get()`` used internally by merge, allowing eager loading
of relationships etc. to be applied when the merge process loads a new
object. Pull request courtesy Daniel Stone.

Fixes: #6955
Closes: #6957
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6957
Pull-request-sha: ab4d96cd5da9a5dd01112b8dcd6514db64aa8d9f

Change-Id: I5b94dfda1088a8bc6396e9fd9a072827df1f8680

3 years agoadd asyncio.gather() example; add connection opts
Mike Bayer [Wed, 1 Sep 2021 12:58:06 +0000 (08:58 -0400)] 
add asyncio.gather() example; add connection opts

while I dont like this approach very much, people will likely
be asking for it a lot, so represent the most correct and
efficient form we can handle right now.

Added missing ``**kw`` arguments to the
:meth:`_asyncio.AsyncSession.connection` method.

Change-Id: Idadae2a02a4d96ecb96a5723ce64d017ab4c6217
References: https://github.com/sqlalchemy/sqlalchemy/discussions/6965

3 years agoFix and test sequences w/ executemany in pre-exec scenarios
Mike Bayer [Tue, 31 Aug 2021 17:34:43 +0000 (13:34 -0400)] 
Fix and test sequences w/ executemany in pre-exec scenarios

Fixed issue where an engine that had ``implicit_returning`` set to False
would fail to function when PostgreSQL's "fast insertmany" feature were
used in conjunction with a ``Sequence``, as well as if any kind of
"executemany" with "return_defaults()" were used in conjunction with a
``Sequence``. Note that PostgreSQL "fast insertmany" uses "RETURNING" by
definition, when the SQL statement is passed to the driver; overall, the
``implicit_returning`` flag is legacy and has no real use in modern
SQLAlchemy, and will be deprecated in a separate change.

Fixes: #6963
Change-Id: Id8e3dd50a21b9124f338067b0fdb57b8f608dca8

3 years agoremove async session slots
Mike Bayer [Tue, 31 Aug 2021 20:41:58 +0000 (16:41 -0400)] 
remove async session slots

1798c3cf1c added __slots__ to the base which then
caused af0824fd79 to fail.  as we can't use an assignable
class variable with slots, remove slots from AsyncSession
which is how this class was working anyway.

Fixes: #6967
Change-Id: I4e0adab923db8e77cf748a8728e253258838e8f1

3 years agoMerge "Allow custom sync session class in ``AsyncSession``."
mike bayer [Mon, 30 Aug 2021 19:38:40 +0000 (19:38 +0000)] 
Merge "Allow custom sync session class in ``AsyncSession``."

3 years agoMerge "Improve error message when inspecting async proxies"
mike bayer [Mon, 30 Aug 2021 19:36:40 +0000 (19:36 +0000)] 
Merge "Improve error message when inspecting async proxies"

3 years agoImprove error message when inspecting async proxies
Federico Caselli [Fri, 27 Aug 2021 19:50:01 +0000 (21:50 +0200)] 
Improve error message when inspecting async proxies

Provide better error message when trying to insepct and async engine
or asnyc connection.

Change-Id: I907f3a22c6b76fe43df9d40cb0e69c57f74a7982

3 years agoensure pysqlite dialect enumerates correct isolation levels
Mike Bayer [Mon, 30 Aug 2021 02:17:13 +0000 (22:17 -0400)] 
ensure pysqlite dialect enumerates correct isolation levels

Fixed bug where the error message for SQLite invalid isolation level on the
pysqlite driver would fail to indicate that "AUTOCOMMIT" is one of the
valid isolation levels.

Change-Id: Icbceab9a28af6a560859761fa92320b5473269a9
References: #6959

3 years agoAllow custom sync session class in ``AsyncSession``.
Federico Caselli [Fri, 27 Aug 2021 20:45:56 +0000 (22:45 +0200)] 
Allow custom sync session class in ``AsyncSession``.

The :class:`_asyncio.AsyncSession` now supports overriding which
:class:`_orm.Session` it uses as the proxied instance. A custom ``Session``
class can be passed using the :paramref:`.AsyncSession.sync_session_class`
parameter or by subclassing the ``AsyncSession`` and specifying a custom
:attr:`.AsyncSession.sync_session_class`.

Fixes: #6689
Change-Id: Idf9c24eae6c9f4e2fff292ed748feaa449a8deaa

3 years agoexclude typing_extensions 3.10.0.1 for aiosqlite install
Mike Bayer [Mon, 30 Aug 2021 14:51:56 +0000 (10:51 -0400)] 
exclude typing_extensions 3.10.0.1 for aiosqlite install

Change-Id: I7b35bc86a7b78f96d8006515341f7cc7a6b49dcc
References: https://github.com/python/typing/issues/865

3 years agoMerge "dont assume argument lists for column property"
mike bayer [Sat, 28 Aug 2021 14:51:24 +0000 (14:51 +0000)] 
Merge "dont assume argument lists for column property"

3 years agodont assume argument lists for column property
Mike Bayer [Fri, 27 Aug 2021 15:39:55 +0000 (11:39 -0400)] 
dont assume argument lists for column property

Fixed issue where mypy plugin would crash when interpreting a
``query_expression()`` construct.

Fixes: #6950
Change-Id: Ic1f28d135bf6eb05c92061430c0d5a3663b804ef

3 years agoHandle mappings passed to ``execution_options``.
Federico Caselli [Thu, 26 Aug 2021 20:00:33 +0000 (22:00 +0200)] 
Handle mappings passed to ``execution_options``.

Fixed a bug in :meth:`_asyncio.AsyncSession.execute` and
:meth:`_asyncio.AsyncSession.stream` that required ``execution_options``
to be an instance of ``immutabledict`` when defined. It now
correctly accepts any mapping.

Fixes: #6943
Change-Id: Ic09de480dc2da1b0bdce25acb60b8f01371971f9

3 years agoMerge "ensure "sqlalchemy" info set for all considered classes"
mike bayer [Wed, 25 Aug 2021 18:23:08 +0000 (18:23 +0000)] 
Merge "ensure "sqlalchemy" info set for all considered classes"

3 years agoMerge "standardizing docs #6821 (redo of 2999/I5609025feee8cfdecc09b55bfbf1bd13fa2e6602)"
mike bayer [Wed, 25 Aug 2021 17:18:04 +0000 (17:18 +0000)] 
Merge "standardizing docs #6821 (redo of 2999/I5609025feee8cfdecc09b55bfbf1bd13fa2e6602)"

3 years agoensure "sqlalchemy" info set for all considered classes
Mike Bayer [Wed, 25 Aug 2021 17:12:55 +0000 (13:12 -0400)] 
ensure "sqlalchemy" info set for all considered classes

Fixed issue in mypy plugin where columns on a mixin would not be correctly
interpreted if the mapped class relied upon a ``__tablename__`` routine
that came from a superclass.

Fixes: #6937
Change-Id: I74aed4862d0545008ee67f781aaa794ab6866926

3 years agoMerge "Qualify server version call in PostgreSQL"
mike bayer [Wed, 25 Aug 2021 14:47:18 +0000 (14:47 +0000)] 
Merge "Qualify server version call in PostgreSQL"

3 years agoMerge "Avoid mutable object as default values"
mike bayer [Wed, 25 Aug 2021 14:45:52 +0000 (14:45 +0000)] 
Merge "Avoid mutable object as default values"