]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
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 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"

3 years agoQualify server version call in PostgreSQL
arredond [Fri, 20 Aug 2021 16:05:42 +0000 (12:05 -0400)] 
Qualify server version call in PostgreSQL

Fixes: #6912
Closes: #6920
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6920
Pull-request-sha: 79af75dfddef25435afd9623698354d280d7c879

Change-Id: Ib6b472452f978378d9f511d17a26988323a89459

3 years agoAvoid mutable object as default values
tsimafeip [Tue, 24 Aug 2021 19:29:51 +0000 (15:29 -0400)] 
Avoid mutable object as default values

Fixes: #6915
Closes: #6916
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6916
Pull-request-sha: 6ec484d3d14b7dd7053d10a5d550bd74eb524c8b

Change-Id: I2c87fbed44870110e35a69ee9a9e678671eeb8f0

3 years agoUpdate PyPI URLs (#6699)
David Gilman [Tue, 24 Aug 2021 19:48:31 +0000 (15:48 -0400)] 
Update PyPI URLs (#6699)

Change-Id: I67d593caf9d35371f49cfcb5472cb9c72d4b4bbd

3 years agoadd example for ORM enabled ON CONFLICT
Mike Bayer [Tue, 24 Aug 2021 19:33:27 +0000 (15:33 -0400)] 
add example for ORM enabled ON CONFLICT

Change-Id: If7db5206ab4fdb04ceec9875c641c8c9eadc7849

3 years agofix spelling (#6926)
William Maio [Tue, 24 Aug 2021 19:12:49 +0000 (12:12 -0700)] 
fix spelling (#6926)

3 years agostandardizing docs #6821
jonathan vanasco [Mon, 23 Aug 2021 20:25:21 +0000 (16:25 -0400)] 
standardizing docs #6821
(redo of 2999/I5609025feee8cfdecc09b55bfbf1bd13fa2e6602)

This PR is designed to bring more clarity within the docs by renaming object
instances that may be consfusingly similar to class, method, and attribute names.

For example, instances of the class `MetaData` are available on some  objects as
`.metadata` property, and had appeared within the docs as both `meta` and
`metadata` which has confused some users in the past. By this PR, the docs now
utilize the following naming convention:

* MetaData - SQLAlchemy class
* .metadata - SQLAlchemy API attributes
* metadata_obj - developer instantiated metadata objects or references

Detailed Changes:

* standardized `meta` and `metadata` instances to `metadata_obj`. note: the docs were evenly split between 'meta' and 'metadata'.
* standardized 'cursor' to 'cursor_obj' to avoid confusion with the method.
* standardized a 'scalar_subquery = ' to 'scalar_subq' to avoid confusion with the method.
* standardized a 'cte = ' to 'cte_obj' to avoid confusion with the method

Change-Id: I79c98aee16c5fc6649289b2dd7d6dfc368222fb4

3 years agoFix has_table() to exclude other sessions' local temp tables
Gord Thompson [Fri, 20 Aug 2021 15:50:10 +0000 (09:50 -0600)] 
Fix has_table() to exclude other sessions' local temp tables

Fixes: #6910
Change-Id: I9986566e1195d42ad7e9a01f0f84ef2074576257

3 years agoMerge "Deprecate scoped_session usage with async sessions"
mike bayer [Mon, 23 Aug 2021 16:39:09 +0000 (16:39 +0000)] 
Merge "Deprecate scoped_session usage with async sessions"

3 years agoMerge "restore statement substitution to before_execute()"
mike bayer [Mon, 23 Aug 2021 16:37:10 +0000 (16:37 +0000)] 
Merge "restore statement substitution to before_execute()"

3 years agoMerge "qualify compile_state updates for non-current entities"
mike bayer [Mon, 23 Aug 2021 16:29:42 +0000 (16:29 +0000)] 
Merge "qualify compile_state updates for non-current entities"

3 years agofix typo
Mike Bayer [Mon, 23 Aug 2021 15:40:23 +0000 (11:40 -0400)] 
fix typo

Change-Id: I670d779a2103b3060c7eacb79cb4a803e3ecaadd

3 years agoqualify compile_state updates for non-current entities
Mike Bayer [Mon, 23 Aug 2021 15:24:48 +0000 (11:24 -0400)] 
qualify compile_state updates for non-current entities

Fixed issue in recently repaired ``Query.with_entities()`` method where the
flag that determines automatic uniquing for legacy ORM ``Query`` objects
only would be set to ``True`` inappropriately in cases where the
``with_entities()`` call would be setting the ``Query`` to return
column-only rows, which are not uniqued.

Fixes: #6924
Change-Id: I81120823914c989bb7a4d13ef2ec08809d8e5a4d

3 years agoupdate enable_baked_queries flag doc
Mike Bayer [Sun, 22 Aug 2021 18:52:50 +0000 (14:52 -0400)] 
update enable_baked_queries flag doc

this flag is not relevant for ORM internals
anymore and is overall legacy.

Change-Id: I58ef7870881ff00b88d552af5eae6af11be6026c

3 years agorestore statement substitution to before_execute()
Mike Bayer [Fri, 20 Aug 2021 15:47:26 +0000 (11:47 -0400)] 
restore statement substitution to before_execute()

Fixed issue where the ability of the
:meth:`_engine.ConnectionEvents.before_execute` method to alter the SQL
statement object passed, returning the new object to be invoked, was
inadvertently removed. This behavior has been restored.

The refactor in a1939719a652774a437f69f8d4788b3f08650089 removed this
feature for some reason and there were no tests in place to detect
it.  I don't see any indication this was planned.

Fixes: #6913
Change-Id: Ia77ca08aa91ab9403f19a8eb61e2a0e41aad138a

3 years agoheads up that execute(query).first() can't apply LIMIT 1
Mike Bayer [Fri, 20 Aug 2021 14:28:16 +0000 (10:28 -0400)] 
heads up that execute(query).first() can't apply LIMIT 1

Fixes: #6914
Change-Id: I5de9843dd3723c017b94b705fc009b883737ede1

3 years agoMerge remote-tracking branch 'origin/pr/6902'
Mike Bayer [Thu, 19 Aug 2021 17:09:48 +0000 (13:09 -0400)] 
Merge remote-tracking branch 'origin/pr/6902'

Change-Id: I73287795fdf0caafc8b29b1d837419e88ba15fe4

3 years agoMerge "CAST Oracle table_name, owner, others to VARCHAR(128)"
mike bayer [Thu, 19 Aug 2021 15:52:39 +0000 (15:52 +0000)] 
Merge "CAST Oracle table_name, owner, others to VARCHAR(128)"

3 years agomysql://user:pass@host/dbname instead of pass:host 6902/head
Jiayang [Thu, 19 Aug 2021 09:23:51 +0000 (02:23 -0700)] 
mysql://user:pass@host/dbname instead of pass:host

Summary:
Reading [1 sqlalchemy.future.Engine](https://docs.sqlalchemy.org/en/14/core/future.html#sqlalchemy.future.Engine) and [2 sqlalchemy.create_engine](https://docs.sqlalchemy.org/en/14/core/engines.html#sqlalchemy.create_engine). I fond @ should be used between pass & host.

Test Plan:
I checked with sqlalchemy 1.4.22 locally and I think @ should be used.

3 years agoVersion 1.4.24 placeholder
Mike Bayer [Wed, 18 Aug 2021 17:17:29 +0000 (13:17 -0400)] 
Version 1.4.24 placeholder

3 years ago- 1.4.23 rel_1_4_23
Mike Bayer [Wed, 18 Aug 2021 17:05:20 +0000 (13:05 -0400)] 
- 1.4.23

3 years agochangelog updates
Mike Bayer [Wed, 18 Aug 2021 16:05:27 +0000 (12:05 -0400)] 
changelog updates

Change-Id: I7c9a6abb85206c56423cfe70d807fc81ae89117e

3 years agoCAST Oracle table_name, owner, others to VARCHAR(128)
Mike Bayer [Wed, 18 Aug 2021 14:48:16 +0000 (10:48 -0400)] 
CAST Oracle table_name, owner, others to VARCHAR(128)

Added a CAST(VARCHAR2(128)) to the "table name", "owner", and other
DDL-name parameters as used in reflection queries against Oracle system
views such as ALL_TABLES, ALL_TAB_CONSTRAINTS, etc to better enable
indexing to take place against these columns, as they previously would be
implicitly handled as NVARCHAR2 due to Python's use of Unicode for strings;
these columns are documented in all Oracle versions as being VARCHAR2 with
lengths varying from 30 to 128 characters depending on server version.
Additionally, test support has been enabled for Unicode-named DDL
structures against Oracle databases.

Fixes: #4486
Change-Id: I2787e3f8de1f656318692bd535d6a7f1cef1a841

3 years agobump profiles a bit
Mike Bayer [Wed, 18 Aug 2021 14:05:47 +0000 (10:05 -0400)] 
bump profiles a bit

the change from lambdas in loader strategies as well
as the repair to caching for the Bundle construct has caused
a slight callcount bump.

Change-Id: I0b160c4a71efdb716f15ac3c128a8addbe10850d

3 years agoMerge "send user defined options from the current query"
mike bayer [Wed, 18 Aug 2021 04:58:45 +0000 (04:58 +0000)] 
Merge "send user defined options from the current query"

3 years agoMerge "rewrite _extra_criteria in selectinload; propagate correctly to Load"
mike bayer [Wed, 18 Aug 2021 04:56:41 +0000 (04:56 +0000)] 
Merge "rewrite _extra_criteria in selectinload; propagate correctly to Load"

3 years agoMerge "honor NO_CACHE in lambdas"
mike bayer [Wed, 18 Aug 2021 04:53:41 +0000 (04:53 +0000)] 
Merge "honor NO_CACHE in lambdas"

3 years agosend user defined options from the current query
Mike Bayer [Tue, 17 Aug 2021 19:03:57 +0000 (15:03 -0400)] 
send user defined options from the current query

Revised the means by which the
:attr:`_orm.ORMExecuteState.user_defined_options` accessor receives
:class:`_orm.UserDefinedOption` and related option objects from the
context, with particular emphasis on the "selectinload" on the loader
strategy where this previously was not working; other strategies did not
have this problem. The objects that are associated with the current query
being executed, and not that of a query being cached, are now propagated
unconditionally. This essentially separates them out from the "loader
strategy" options which are explicitly associated with the compiled state
of a query and need to be used in relation to the cached query.

The effect of this fix is that a user-defined option, such as those used
by the dogpile.caching example as well as for other recipes such as
defining a "shard id" for the horizontal sharing extension, will be
correctly propagated to eager and lazy loaders regardless of whether
a cached query was ultimately invoked.

Fixes: #6887
Change-Id: Ieaae5b01c85de26ea732ebd625e6e5823a470492

3 years agorewrite _extra_criteria in selectinload; propagate correctly to Load
Mike Bayer [Fri, 13 Aug 2021 15:07:17 +0000 (11:07 -0400)] 
rewrite _extra_criteria in selectinload; propagate correctly to Load

Fixed issue in :func:`_orm.selectinload` where use of the new
:meth:`_orm.PropComparator.and_` feature within options that were nested
more than one level deep would fail to update bound parameter values that
were in the nested criteria, as a side effect of SQL statement caching.

Implementation adds a new step that rewrites the parameters
inside of all _extra_criteria when invoking selectinload
as well as subqueryload.  Additionally, changed how Load()
gets "extra_criteria", in that it pulls it from
UnboundLoad._extra_criteria instead of re-fetching it from the
path elements, which are not updated by this new step.

This patch also builds upon the removal of lambda queries
for use in loader strategies in #6889.  lambdas made this issue
much more difficult to diagnose.  An attempt to reintroduce
lambdas here after finally identifying the "extra_criteria"
issue above showed that lambdas still impact the
assertsql fixture, meaning we have a statement structure that
upon calling .compile() still delivers stale data due to lambdas,
even if caching is turned off, and the non-cached test was still
failing due to stale data within the lambdas.

This is basically the complexity that #6889 fixes and as there's
no real performance gain to using lambdas in these strategies
on top of the existing statement caching that does most of the
work, it should be much less likely going forward to have as many
deeply confusing issues as we've had within selectinload/lazyload
in the 1.4 series.

Fixes: #6881
Change-Id: I919c079d2ed06125def5f8d6d81f3f305e158c04

3 years agohonor NO_CACHE in lambdas
Mike Bayer [Sun, 15 Aug 2021 22:12:42 +0000 (18:12 -0400)] 
honor NO_CACHE in lambdas

Fixed issue in lambda caching system where an element of a query that
produces no cache key, like a custom option or clause element, would still
populate the expression in the "lambda cache" inappropriately.

This was discovered as part of :ticket:`6887` but is a separate
issue.

References: #6887
Change-Id: I1665f4320254ddc63a0abf3088e9daeaffbd1840

3 years agoremove lambda caching from loader strategies
Mike Bayer [Mon, 16 Aug 2021 21:20:48 +0000 (17:20 -0400)] 
remove lambda caching from loader strategies

Adjusted ORM loader internals to no longer use the "lambda caching" system
that was added in 1.4, as well as repaired one location that was still
using the previous "baked query" system for a query. The lambda caching
system remains an effective way to reduce the overhead of building up
queries that have relatively fixed usage patterns. In the case of loader
strategies, the queries used are responsible for moving through lots of
arbitrary options and criteria, which is both generated and sometimes
consumed by end-user code, that make the lambda cache concept not any more
efficient than not using it, at the cost of more complexity. In particular
the problems noted by :ticket:`6881` and :ticket:`6887` are made
considerably less complicated by removing this feature internally.

Fixed an issue where the :class:`_orm.Bundle` construct would not create
proper cache keys, leading to inefficient use of the query cache.  This
had some impact on the "selectinload" strategy and was identified as
part of :ticket:`6889`.

Added a Select._create_raw_select() method which essentially
performs ``__new__`` and then populates ``__dict__`` directly,
with no coercions.  This saves most of the overhead time that
the lambda caching system otherwise seeks to avoid.

Includes removal of bakedquery from
mapper->_subclass_load_via_in() which was overlooked from
the 1.4 refactor.

Fixes: #6079
Fixes: #6889
Change-Id: Ieac2d9d709b71ec4270e5c121fbac6ac870e2bb1

3 years agoMerge "fix linter JOIN logic; fix PostgreSQL ARRAY op comparison"
mike bayer [Mon, 16 Aug 2021 14:35:49 +0000 (14:35 +0000)] 
Merge "fix linter JOIN logic; fix PostgreSQL ARRAY op comparison"

3 years agofix black check for correct files and update test_types
Mike Bayer [Mon, 16 Aug 2021 14:27:51 +0000 (10:27 -0400)] 
fix black check for correct files and update test_types

Change-Id: I5e21821ad203a91f9942fd8d29f516ed21824e50

3 years agofix linter JOIN logic; fix PostgreSQL ARRAY op comparison
Mike Bayer [Sun, 15 Aug 2021 16:21:13 +0000 (12:21 -0400)] 
fix linter JOIN logic; fix PostgreSQL ARRAY op comparison

Adjusted the "from linter" warning feature to accommodate for a chain of
joins more than one level deep where the ON clauses don't explicitly match
up the targets, such as an expression such as "ON TRUE". This mode of use
is intended to cancel the cartesian product warning simply by the fact that
there's a JOIN from "a to b", which was not working for the case where the
chain of joins had more than one element.

this incurs a bit more compiler overhead that comes out in profiling
but is not extensive.

Added the "is_comparison" flag to the PostgreSQL "overlaps",
"contained_by", "contains" operators, so that they work in relevant ORM
contexts as well as in conjunction with the "from linter" feature.

Fixes: #6886
Change-Id: I078dc3fe6d4f7871ffe4ebac3e71e62f3f213d12

3 years agoclarify with_polymorphic re: rows loaded
Mike Bayer [Sat, 14 Aug 2021 16:04:42 +0000 (12:04 -0400)] 
clarify with_polymorphic re: rows loaded

Change-Id: Iaec90932b5cb49e16ec95756f8c6129ba305c88d
References: #6878

3 years agoMerge "Unify native and non-native valid values for ``Enum``"
mike bayer [Fri, 13 Aug 2021 15:44:24 +0000 (15:44 +0000)] 
Merge "Unify native and non-native valid values for ``Enum``"

3 years agoModernize tests - remaining DML
Gord Thompson [Tue, 27 Jul 2021 22:15:19 +0000 (16:15 -0600)] 
Modernize tests - remaining DML

dialect_keyword_arguments
preserve_parameter_order

Change-Id: I92efce4689635ef4b68fc02100c0c10aff9a0edc

3 years agoadd all the machine names in uppercase
Mike Bayer [Wed, 11 Aug 2021 22:24:59 +0000 (18:24 -0400)] 
add all the machine names in uppercase

windows seems to be returning the name in uppercase,
we might have to revert this whole thing if things
continue to not work

Change-Id: I365a07e3521f9f43a3d9d5f93da7788a8a052ff0

3 years agoMerge "limit greenlet dependency to pypi-listed platforms"
mike bayer [Wed, 11 Aug 2021 20:22:59 +0000 (20:22 +0000)] 
Merge "limit greenlet dependency to pypi-listed platforms"

3 years agoMerge "cx_oracle patches"
mike bayer [Wed, 11 Aug 2021 17:41:41 +0000 (17:41 +0000)] 
Merge "cx_oracle patches"

3 years agolimit greenlet dependency to pypi-listed platforms
Mike Bayer [Mon, 26 Jul 2021 22:06:41 +0000 (18:06 -0400)] 
limit greenlet dependency to pypi-listed platforms

The setup requirements have been modified such ``greenlet`` is a default
requirement only for those platforms that are well known for ``greenlet``
to be installable and for which there is already a pre-built binary on
pypi; the current list is ``x86_64 aarch64 ppc64le amd64 win32``. For other
platforms, greenlet will not install by default, which should enable
installation and test suite running of SQLAlchemy 1.4 on platforms that
don't support ``greenlet``, excluding any asyncio features. In order to
install with the ``greenlet`` dependency included on a machine architecture
outside of the above list, the ``[asyncio]`` extra may be included by
running ``pip install sqlalchemy[asyncio]`` which will then attempt to
install ``greenlet``.

Additionally, the test suite has been repaired so that tests can complete
fully when greenlet is not installed, with appropriate skips for
asyncio-related tests.

Fixes: #6136
Change-Id: I8f3a1c00a4a8b6a273484af1da1f7aaadf588ae7

3 years agoFix example with deprecated code 6875/head
João Sampaio [Wed, 11 Aug 2021 14:36:49 +0000 (11:36 -0300)] 
Fix example with deprecated code

Just a few lines above, it is said that creating a mapping with `mapper()` is deprecated in favor of `mapper_registry.map_imperatively()`. This PR fixes an example in the documentation that still uses the old function.