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

3 years agoMerge "create concise + deterministic cache key for unboundload.options"
mike bayer [Tue, 10 Aug 2021 01:36:24 +0000 (01:36 +0000)] 
Merge "create concise + deterministic cache key for unboundload.options"

3 years agoMerge "add columns_clause_froms and related use cases"
mike bayer [Mon, 9 Aug 2021 18:53:06 +0000 (18:53 +0000)] 
Merge "add columns_clause_froms and related use cases"

3 years agocreate concise + deterministic cache key for unboundload.options
Mike Bayer [Mon, 9 Aug 2021 18:43:53 +0000 (14:43 -0400)] 
create concise + deterministic cache key for unboundload.options

Fixed issue in loader strategies where the use of the
:meth:`_orm.Load.options` method, particularly when nesting multiple calls,
would generate an overly long and more importantly non-deterministic cache
key, leading to very large cache keys which were also not allowing
efficient cache usage, both in terms of total memory used as well as number
of entries used in the cache itself.

Fixes: #6869
Change-Id: I42bd3564d55a5fb95a21d0e7eef30d50c1274da0

3 years agoMerge "Dispatch independent ctes on compound select"
mike bayer [Sun, 8 Aug 2021 16:38:48 +0000 (16:38 +0000)] 
Merge "Dispatch independent ctes on compound select"

3 years agoDispatch independent ctes on compound select
Eric Masseran [Fri, 6 Aug 2021 08:11:09 +0000 (04:11 -0400)] 
Dispatch independent ctes on compound select

Fix issue in :class:`_sql.CTE` where new :meth:`_sql.HasCTE.add_cte` method
added in version 1.4.21 / :ticket:`6752` failed to function correctly for
"compound select" structures such as :func:`_sql.union`,
:func:`_sql.union_all`, :func:`_sql.except`, etc. Pull request courtesy
Eric Masseran.

Fixes: #6752
Closes: #6849
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6849
Pull-request-sha: 1c4b4d72b2789cf89ff5043ca964ebdd6c9a6617

Change-Id: I49a16a4fc2af8299502011f3a02d8a2ad93255e3

4 years agoMerge "dont qualify literal_binds with literal_execute"
mike bayer [Sat, 7 Aug 2021 18:56:11 +0000 (18:56 +0000)] 
Merge "dont qualify literal_binds with literal_execute"

4 years agoadd columns_clause_froms and related use cases
Mike Bayer [Fri, 23 Jul 2021 20:07:50 +0000 (16:07 -0400)] 
add columns_clause_froms and related use cases

Added new attribute :attr:`_sql.Select.columns_clause_froms` that will
retrieve the FROM list implied by the columns clause of the
:class:`_sql.Select` statement. This differs from the old
:attr:`_sql.Select.froms` collection in that it does not perform any ORM
compilation steps, which necessarily deannotate the FROM elements and do
things like compute joinedloads etc., which makes it not an appropriate
candidate for the :meth:`_sql.Select.select_from` method. Additionally adds
a new parameter
:paramref:`_sql.Select.with_only_columns.maintain_column_froms` that
transfers this collection to :meth:`_sql.Select.select_from` before
replacing the columns collection.

In addition, the :attr:`_sql.Select.froms` is renamed to
:meth:`_sql.Select.get_final_froms`, to stress that this collection is not
a simple accessor and is instead calculated given the full state of the
object, which can be an expensive call when used in an ORM context.

Additionally fixes a regression involving the
:func:`_orm.with_only_columns` function to support applying criteria to
column elements that were replaced with either
:meth:`_sql.Select.with_only_columns` or :meth:`_orm.Query.with_entities` ,
which had broken as part of :ticket:`6503` released in 1.4.19.

Fixes: #6808
Change-Id: Ib5d66cce488bbaca06dab4f68fb5cdaa73e8823e

4 years agoMerge "Refactor mypy plugin"
mike bayer [Sat, 7 Aug 2021 18:35:26 +0000 (18:35 +0000)] 
Merge "Refactor mypy plugin"

4 years agoRefactor mypy plugin
Bryan Forbes [Wed, 14 Jul 2021 19:00:11 +0000 (15:00 -0400)] 
Refactor mypy plugin

A major refactor of the mypy plugin

Closes: #6764
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6764
Pull-request-sha: 3e2295b2da7b57a6669f26db0df78f6409934184

Change-Id: I067d56dcfbc998ddd1b22a448f756859428b9e31

4 years agoMerge "Modernize tests - dml_values"
mike bayer [Sat, 7 Aug 2021 16:56:53 +0000 (16:56 +0000)] 
Merge "Modernize tests - dml_values"

4 years agoMerge "Add count example to 2.0 migration table"
mike bayer [Sat, 7 Aug 2021 16:52:52 +0000 (16:52 +0000)] 
Merge "Add count example to 2.0 migration table"

4 years agoMerge "Modernize tests - remaining core SQL"
mike bayer [Sat, 7 Aug 2021 16:48:06 +0000 (16:48 +0000)] 
Merge "Modernize tests - remaining core SQL"

4 years agoMerge "accommodate for untracked boundparam lambda in offline_string"
mike bayer [Sat, 7 Aug 2021 16:45:43 +0000 (16:45 +0000)] 
Merge "accommodate for untracked boundparam lambda in offline_string"

4 years agoMerge "Provide default for implicitly_named_constraints"
mike bayer [Sat, 7 Aug 2021 16:45:03 +0000 (16:45 +0000)] 
Merge "Provide default for implicitly_named_constraints"

4 years agodont qualify literal_binds with literal_execute
Mike Bayer [Sat, 7 Aug 2021 15:02:59 +0000 (11:02 -0400)] 
dont qualify literal_binds with literal_execute

this appears to be unnecessary and prevents end-user
literal_binds case from working.

Fixed issue where the ``literal_binds`` compiler flag, as used externally
to render bound parameters inline, would fail to work when used with a
certain class of parameters known as "literal_execute", which covers things
like LIMIT and OFFSET values for dialects where the drivers don't allow a
bound parameter, such as SQL Server's "TOP" clause.  The issue locally
seemed to affect only the MSSQL dialect.

Fixes: #6863
Change-Id: Ia74cff5b0107b129a11b9b965883552b2962e449

4 years agoaccommodate for untracked boundparam lambda in offline_string
Mike Bayer [Thu, 5 Aug 2021 23:17:07 +0000 (19:17 -0400)] 
accommodate for untracked boundparam lambda in offline_string

Fixed an issue in the ``CacheKey.to_offline_string()`` method used by the
dogpile.caching example where attempting to create a proper cache key from
the special "lambda" query generated by the lazy loader would fail to
include the parameter values, leading to an incorrect cache key.

Fixes: #6858
Change-Id: Ice27087583c6f3ff79cf7d5b879e5dd0a4e58158

4 years agoupdate local_session_caching.py example for 1.4
Mike Bayer [Thu, 5 Aug 2021 17:54:06 +0000 (13:54 -0400)] 
update local_session_caching.py example for 1.4

Fixes: #6858
Change-Id: I9b4113243f9ef32f27dcd1f7e9751923283eba2d

4 years agoProvide default for implicitly_named_constraints
Gord Thompson [Tue, 3 Aug 2021 21:55:52 +0000 (15:55 -0600)] 
Provide default for implicitly_named_constraints

… so third-party dialect testing won't fail with:

"AttributeError: 'Requirements' object has no
attribute 'implicitly_named_constraints'"

Change-Id: Iafa3e36f3dd169c338dd6eaee21c73aa35e854cc

4 years agocx_oracle patches
Mike Bayer [Thu, 29 Jul 2021 18:55:37 +0000 (14:55 -0400)] 
cx_oracle patches

provided by cx_oracle developers

Change-Id: Ie30b0993d0da2ee1359042816d77d08f762c6b13

4 years agoMerge "accommodate for cloned bindparams w/ maintain_key"
mike bayer [Thu, 29 Jul 2021 15:16:41 +0000 (15:16 +0000)] 
Merge "accommodate for cloned bindparams w/ maintain_key"

4 years agoMerge "Fix type"
mike bayer [Thu, 29 Jul 2021 15:15:44 +0000 (15:15 +0000)] 
Merge "Fix type"

4 years agoMerge "Support generics in code to allow Column[int] etc"
mike bayer [Thu, 29 Jul 2021 15:15:01 +0000 (15:15 +0000)] 
Merge "Support generics in code to allow Column[int] etc"

4 years agoaccommodate for cloned bindparams w/ maintain_key
Mike Bayer [Thu, 29 Jul 2021 14:10:28 +0000 (10:10 -0400)] 
accommodate for cloned bindparams w/ maintain_key

Fixed issue where a bound parameter object that was "cloned" would cause a
name conflict in the compiler, if more than one clone of this parameter
were used at the same time in a single statement. This could occur in
particular with things like ORM single table inheritance queries that
indicated the same "discriminator" value multiple times in one query.

Fixes: #6824
Change-Id: Iba7a786fc5a2341ff7d07fc666d24ed790ad4fe8

4 years agoDeprecate scoped_session usage with async sessions
Federico Caselli [Tue, 27 Jul 2021 20:30:06 +0000 (22:30 +0200)] 
Deprecate scoped_session usage with async sessions

Deprecate usage of :class:`_orm.scoped_session` with asyncio drivers.
When using Asyncio the :class:`_asyncio.async_scoped_session` should
be used instead.

Fixes: #6746
Change-Id: I540d57a406f59efc37fc61f0e9dfe03f32fe2904

4 years agoSupport generics in code to allow Column[int] etc
Federico Caselli [Sat, 24 Jul 2021 17:17:49 +0000 (19:17 +0200)] 
Support generics in code to allow Column[int] etc

Fixes: #6804
Fixes: #6759
Change-Id: Ie7f32c38a22dbfa059b5709b883ff464b16031ae

4 years agoaccommodate plain core textual statements
Mike Bayer [Tue, 27 Jul 2021 15:35:41 +0000 (11:35 -0400)] 
accommodate plain core textual statements

Fixed issue where the horizontal sharding extension would not correctly
accommodate for a plain textual SQL statement passed to
:meth:`_orm.Session.execute`.

Fixes: #6816
Change-Id: Ie2b71b06d10793443dbd5e1b271c56cbf9431bb3

4 years agoModernize tests - dml_values
Gord Thompson [Mon, 26 Jul 2021 18:52:23 +0000 (12:52 -0600)] 
Modernize tests - dml_values

Change-Id: Ida86ed40c43d91813151621b847376976773a5f9

4 years agoModernize tests - dml_whereclause
Gord Thompson [Sun, 25 Jul 2021 19:16:31 +0000 (13:16 -0600)] 
Modernize tests - dml_whereclause

Fixed issue where the unit of work would internally use a 2.0-deprecated
SQL expression form, emitting a deprecation warning when SQLALCHEMY_WARN_20
were enabled.

Fixes: #6812
Change-Id: I0a031e728527a1c3382848b6ddc793939362b128

4 years agoNew issue templates forms
Federico Caselli [Mon, 26 Jul 2021 14:00:23 +0000 (10:00 -0400)] 
New issue templates forms

Noting fancy. we could add checkbox and/or dropdowns if needed

**To test**: to go my fork. Link https://github.com/CaselIT/sqlalchemy/issues/new/choose

See docs at
https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-issue-forms
https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema

Closes: #6809
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6809
Pull-request-sha: 21beb5a44104ced9e43bb5342a4cdf5f5efcb02a

Change-Id: I74c671aa2790b9f08c20b0659625c8a91b5b9c72

4 years agoAdd count example to 2.0 migration table
Federico Caselli [Sat, 24 Jul 2021 16:56:15 +0000 (18:56 +0200)] 
Add count example to 2.0 migration table

Also update some further load_only(str) left in the docs

Fixes: #6794
Change-Id: If3f0ef82a4cdcc8adceef55ab1b1a6a99f4f2a08

4 years agoModernize tests - remaining core SQL
Gord Thompson [Fri, 23 Jul 2021 17:54:14 +0000 (11:54 -0600)] 
Modernize tests - remaining core SQL

Change-Id: I7d8c1f451c32dea28173b2206e66db1d0927fccf

4 years agoAdd mypy tests on github.
Federico Caselli [Thu, 22 Jul 2021 20:32:28 +0000 (22:32 +0200)] 
Add mypy tests on github.

Support skipping mypy tests based on interpreter version

Change-Id: I98963318dbb2e7e097ad5518e0e4022349ca9779

4 years agoFix type
Kazantcev Andrey [Tue, 20 Jul 2021 10:56:02 +0000 (06:56 -0400)] 
Fix type

https://github.com/sqlalchemy/sqlalchemy2-stubs/pull/132#issuecomment-883159494

Closes: #6789
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6789
Pull-request-sha: 36e9075a8ee0ff699deea8ceef6e72ed4bc1d854

Change-Id: I87fe210b5d69c1e2500fb8e1440592ff44ceaacf

4 years agoVersion 1.4.23 placeholder
Mike Bayer [Thu, 22 Jul 2021 00:14:13 +0000 (20:14 -0400)] 
Version 1.4.23 placeholder

4 years ago- 1.4.22 rel_1_4_22
Mike Bayer [Wed, 21 Jul 2021 22:53:27 +0000 (18:53 -0400)] 
- 1.4.22

4 years agoApply new uniquing rules for future ORM selects
Mike Bayer [Wed, 21 Jul 2021 19:44:27 +0000 (15:44 -0400)] 
Apply new uniquing rules for future ORM selects

Fixed issue where usage of the :meth:`_result.Result.unique` method with an
ORM result that included column expressions with unhashable types, such as
``JSON`` or ``ARRAY`` using non-tuples would silently fall back to using
the ``id()`` function, rather than raising an error. This now raises an
error when the :meth:`_result.Result.unique` method is used in a 2.0 style
ORM query. Additionally, hashability is assumed to be True for result
values of unknown type, such as often happens when using SQL functions of
unknown return type; if values are truly not hashable then the ``hash()``
itself will raise.

For legacy ORM queries, since the legacy :class:`_orm.Query` object
uniquifies in all cases, the old rules remain in place, which is to use
``id()`` for result values of unknown type as this legacy uniquing is
mostly for the purpose of uniquing ORM entities and not column values.

Fixes: #6769
Change-Id: I5747f706f1e97c78867b5cf28c73360497273808

4 years agoMerge "Modernize tests - legacy_select"
mike bayer [Wed, 21 Jul 2021 21:23:37 +0000 (21:23 +0000)] 
Merge "Modernize tests - legacy_select"

4 years agoMerge "dont warn for dictionary passed positionally"
mike bayer [Wed, 21 Jul 2021 21:22:46 +0000 (21:22 +0000)] 
Merge "dont warn for dictionary passed positionally"

4 years agoModernize tests - legacy_select
Gord Thompson [Wed, 14 Jul 2021 15:56:18 +0000 (09:56 -0600)] 
Modernize tests - legacy_select

Change-Id: I04057cc3d3f93de60b02999803e2ba6a23cdf68d

4 years agodont warn for dictionary passed positionally
Mike Bayer [Tue, 20 Jul 2021 15:03:08 +0000 (11:03 -0400)] 
dont warn for dictionary passed positionally

Fixed issue where use of the :paramref:`_sql.case.whens` parameter passing
a dictionary positionally and not as a keyword argument would emit a 2.0
deprecation warning, referring to the deprecation of passing a list
positionally. The dictionary format of "whens", passed positionally, is
still supported and was accidentally marked as deprecated.

Removes warning filter for case statement.

Fixes: #6786
Change-Id: I8efd1882563773bec89ae5e34f0dfede77fc4683

4 years agoimplement cache key for return_defaults token
Mike Bayer [Wed, 21 Jul 2021 15:18:01 +0000 (11:18 -0400)] 
implement cache key for return_defaults token

Fixed critical caching issue where the ORM's persistence feature using
INSERT..RETURNING would cache an incorrect query when mixing the "bulk
save" and standard "flush" forms of INSERT.

Fixes: #6793
Change-Id: Ifeb61c1226d3fa6d5e1c2e29b6f5ff77a27d6a2d

4 years agoMerge "Documentation improvements"
mike bayer [Tue, 20 Jul 2021 19:19:26 +0000 (19:19 +0000)] 
Merge "Documentation improvements"

4 years agoDocumentation improvements
Federico Caselli [Tue, 13 Jul 2021 19:47:28 +0000 (21:47 +0200)] 
Documentation improvements

Also remove deprecated usage:
- load_only does not accept strings
- case.whens is positional only

Ref #6712
Ref #5994
Ref #6121
Ref #6785
Ref https://groups.google.com/g/sqlalchemy/c/-cnhThEu3kk

Change-Id: I5db49a075b9d3d332518b9d189a24b13b502e2af

4 years agoEncourage primary_key for secondary tables
Mike Bayer [Tue, 20 Jul 2021 13:17:17 +0000 (09:17 -0400)] 
Encourage primary_key for secondary tables

Change-Id: Ied56e52eaccf5d6dcb2729bdcf829f3ac4632f4c

4 years agoguard against unexpected weakref cleanups
Mike Bayer [Fri, 16 Jul 2021 15:34:13 +0000 (11:34 -0400)] 
guard against unexpected weakref cleanups

Added some guards against ``KeyError`` in the event system to accommodate
the case that the interpreter is shutting down at the same time
:meth:`_engine.Engine.dispose` is being called, which would cause stack
trace warnings.

Fixes: #6740
Change-Id: I2c42e9edac2371e68b39d8360494c5fddfd6cd8c

4 years agoMerge "apply list() around weakkeydictionary iteration"
mike bayer [Fri, 16 Jul 2021 15:17:23 +0000 (15:17 +0000)] 
Merge "apply list() around weakkeydictionary iteration"