Mike Bayer [Tue, 26 Oct 2021 19:52:25 +0000 (15:52 -0400)]
add additional "oracle mode" reserved words
despite mariadb's docs, the word "system" must be
quoted in plain mariadb 10.5, not sure if that's
"oracle mode" but it is > 10.3. observed keystone
tests failing on a column of this name.
Mike Bayer [Tue, 26 Oct 2021 15:28:42 +0000 (11:28 -0400)]
dont pull filter_by from from_obj, entity is hopefully sufficient
Fixed 1.4 regression where :meth:`_orm.Query.filter_by` would not function
correctly on a :class:`_orm.Query` that was produced from
:meth:`_orm.Query.union`, :meth:`_orm.Query.from_self` or similar.
Mike Bayer [Wed, 20 Oct 2021 16:50:53 +0000 (12:50 -0400)]
deprecation warnings: strings in loader options, join, with_parent
Repairs one in-library deprecation warning regarding
mapper propagation of options
raises maxfail to 250, as 25 is too low when we are trying
to address many errors at once. the 25 was originally
due to the fact that our fixtures would be broken after
that many failures in most cases, which today should not
be the case nearly as often.
Mike Bayer [Sun, 24 Oct 2021 00:36:41 +0000 (20:36 -0400)]
add full docs/notes for all TypeEngine/TypeDecorator interactions
Added notes to all TypeEngine methods as to which should be
overridden by TypeDecorator implementations. Made sure
docstrings are present for all TypeDecorator methods as some
were missing, and clarified which should be overridden, which
should not, as well as what phase each method is called within.
Mike Bayer [Fri, 22 Oct 2021 16:31:06 +0000 (12:31 -0400)]
use correct entity in path for aliased class relationship
Fixed bug in "relationship to aliased class" feature introduced at
:ref:`relationship_aliased_class` where it was not possible to create a
loader strategy option targeting an attribute on the target using the
:func:`_orm.aliased` construct directly in a second loader option, such as
``selectinload(A.aliased_bs).joinedload(aliased_b.cs)``, without explicitly
qualifying using :meth:`_orm.PropComparator.of_type` on the preceding
element of the path. Additionally, targeting the non-aliased class directly
would be accepted (inappropriately), but would silently fail, such as
``selectinload(A.aliased_bs).joinedload(B.cs)``; this now raises an error
referring to the typing mismatch.
Gord Thompson [Wed, 20 Oct 2021 21:15:37 +0000 (15:15 -0600)]
Apply minor update to async_orm example
- Fixed import to avoid MovedIn20Warning.
- Separated drop_all() and create_all() into separate
context managers to avoid dropping and creating the
same table within the same transaction. Apparently
some databases (e.g., CockroachDB) don't allow that.
Kevin Kirsche [Tue, 19 Oct 2021 21:22:03 +0000 (17:22 -0400)]
fix: Update reserved words list of MySQL / MariaDB dialect
Reorganized the list of reserved words into two separate lists, one for
MySQL and one for MariaDB, so that these diverging sets of words can be
managed more accurately; adjusted the MySQL/MariaDB dialect to switch among
these lists based on either explicitly configured or
server-version-detected "MySQL" or "MariaDB" backend. Added all current
reserved words through MySQL 8 and current MariaDB versions including
recently added keywords like "lead" . Pull request courtesy Kevin Kirsche.
1. Move reserved words to it's own file.
2. Add missing reserved words from https://mariadb.com/kb/en/reserved-words/
* Note: this only adds MariaDB though links to MySQL, it also does not
include the reserved words for Oracle mode, as listed in the link.
Mike Bayer [Mon, 18 Oct 2021 20:35:21 +0000 (16:35 -0400)]
remove _resolve_label and related attributes
these seem to date back to 0.9 and revs like #3148 but none
of it seems to be affecting things now, try removing it all
and seeing what fails.
we've noted that _resolve_label does not appear to be
needed, however allow_label_resolve remains relevant both
for non-column elements like text() as well as that it is
used explicitly by the joined eager loader.
Mike Bayer [Tue, 19 Oct 2021 18:07:32 +0000 (14:07 -0400)]
process bulk_update_tuples before cache key or compilation
Fixed regression where the use of a :class:`_orm.hybrid_property` attribute
or a mapped :func:`_orm.composite` attribute as a key passed to the
:meth:`_dml.Update.values` method for an ORM-enabled :class:`_dml.Update`
statement, as well as when using it via the legacy
:meth:`_orm.Query.update` method, would be processed for incoming
ORM/hybrid/composite values within the compilation stage of the UPDATE
statement, which meant that in those cases where caching occurred,
subsequent invocations of the same statement would no longer receive the
correct values. This would include not only hybrids that use the
:meth:`_orm.hybrid_property.update_expression` method, but any use of a
plain hybrid attribute as well. For composites, the issue instead caused a
non-repeatable cache key to be generated, which would break caching and
could fill up the statement cache with repeated statements.
The :class:`_dml.Update` construct now handles the processing of key/value
pairs passed to :meth:`_dml.Update.values` and
:meth:`_dml.Update.ordered_values` up front when the construct is first
generated, before the cache key has been generated so that the key/value
pairs are processed each time, and so that the cache key is generated
against the individual column/value pairs that will ultimately be
used in the statement.
Mike Bayer [Mon, 18 Oct 2021 19:43:27 +0000 (15:43 -0400)]
use coercions for label element, ensure propagate_attrs
Fixed bug where the ORM "plugin", necessary for features such as
:func:`_orm.with_loader_criteria` to work correctly, would not be applied
to a :func:`_sql.select` which queried from an ORM column expression if it
made use of the :meth:`_sql.ColumnElement.label` modifier.
Mike Bayer [Fri, 15 Oct 2021 15:03:46 +0000 (11:03 -0400)]
fix with_loader_criteria for select(A).join(B)
Also revise the contains_eager() note that was just
added in fec2b6560c14bb28ee7f, as I mistakenly forgot that
WLC also affects elements of the query that are there
as part of the normal entites/criteria.
Mike Bayer [Wed, 13 Oct 2021 19:52:12 +0000 (15:52 -0400)]
support bind expressions w/ expanding IN; apply to psycopg2
Fixed issue where "expanding IN" would fail to function correctly with
datatypes that use the :meth:`_types.TypeEngine.bind_expression` method,
where the method would need to be applied to each element of the
IN expression rather than the overall IN expression itself.
Fixed issue where IN expressions against a series of array elements, as can
be done with PostgreSQL, would fail to function correctly due to multiple
issues within the "expanding IN" feature of SQLAlchemy Core that was
standardized in version 1.4. The psycopg2 dialect now makes use of the
:meth:`_types.TypeEngine.bind_expression` method with :class:`_types.ARRAY`
to portably apply the correct casts to elements. The asyncpg dialect was
not affected by this issue as it applies bind-level casts at the driver
level rather than at the compiler level.
as part of this commit the "bind translate" feature has been
simplified and also applies to the names in the POSTCOMPILE tag to
accommodate for brackets.
Mike Bayer [Thu, 14 Oct 2021 22:24:26 +0000 (18:24 -0400)]
clarify that with_loader_criteria does not affect contains_eager()
The ORM contains_eager() option does not affect the rendering
of a SQL query in any way except that it adds additional columns
to the columns clause of the SELECT. Therefore the
with_loader_criteria() function has no interaction with this
loader option.
Sumit Khanna [Mon, 4 Oct 2021 15:14:38 +0000 (11:14 -0400)]
Reflect table can reflect table with no columns
The :meth:`_engine.Inspector.reflect_table` method now supports reflecting
tables that do not have user defined columns. This allows
:meth:`_schema.MetaData.reflect` to properly complete reflection on
databases that contain such tables. Currently, only PostgreSQL is known
to support such a construct among the common database backends.
Mike Bayer [Wed, 13 Oct 2021 16:00:52 +0000 (12:00 -0400)]
Pickling fixes for ORM / Core
Fixed regression where ORM loaded objects could not be pickled in cases
where loader options making use of ``"*"`` were used in certain
combinations, such as combining the :func:`_orm.joinedload` loader strategy
with ``raiseload('*')`` of sub-elements.
Fixes: #7134
Fixed issue where SQL queries using the
:meth:`_functions.FunctionElement.within_group` construct could not be
pickled, typically when using the ``sqlalchemy.ext.serializer`` extension
but also for general generic pickling.
Eric Masseran [Fri, 8 Oct 2021 14:02:58 +0000 (10:02 -0400)]
Fix recursive CTE to support nesting
Repaired issue in new :paramref:`_sql.HasCTE.cte.nesting` parameter
introduced with :ticket:`4123` where a recursive :class:`_sql.CTE` using
:paramref:`_sql.HasCTE.cte.recursive` in typical conjunction with UNION
would not compile correctly. Additionally makes some adjustments so that
the :class:`_sql.CTE` construct creates a correct cache key.
Pull request courtesy Eric Masseran.
Fixes: #4123
> This has not been caught by the tests because the nesting recursive
queries there did not union against itself, eg there was only the i
root clause...
- Now tests are real recursive queries
- Add tests on aliased nested CTEs (recursive or not)
- Adapt the `_restates` attribute to use it as a reference
- Add some docs around to explain some variables usage
Gord Thompson [Sat, 9 Oct 2021 22:44:57 +0000 (16:44 -0600)]
Fix has_table() false negative for #temp tables
Fixed issue with :meth:`.Inspector.has_table` where it would return False
if a local temp table with the same name from a different session happened
to be returned first when querying tempdb. This is a continuation of
:ticket:`6910` which accounted for the temp table existing only in the
alternate session and not the current one.
Federico Caselli [Mon, 11 Oct 2021 19:47:18 +0000 (15:47 -0400)]
Add support for Python 3.10
<!-- Provide a general summary of your proposed changes in the Title field above -->
### Description
<!-- Describe your changes in detail -->
Python 3.10 was released last week.
Test on Python 3.10 and add the Trove classifier.
### 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!**
^ Which checklist option should I use?
Should I do something to trigger/test all the workflows?
Mike Bayer [Sat, 9 Oct 2021 22:56:25 +0000 (18:56 -0400)]
update versioned rows examples for 1.4
Repaired the examples in examples/versioned_rows to use SQLAlchemy 1.4 APIs
correctly; these examples had been missed when API changes like removing
"passive" from ``Session.is_modified()`` were made as well as the
``do_orm_execute()`` event hook were added.
Mike Bayer [Wed, 6 Oct 2021 22:51:08 +0000 (18:51 -0400)]
fixes for usage of the null() and similar constants
Adjusted the "column disambiguation" logic that's new in 1.4, where the
same expression repeated gets an "extra anonymous" label, so that the logic
more aggressively deduplicates those labels when the repeated element
is the same Python expression object each time, as occurs in cases like
when using "singleton" values like :func:`_sql.null`. This is based on
the observation that at least some databases (e.g. MySQL, but not SQLite)
will raise an error if the same label is repeated inside of a subquery.
Related to :ticket:`7153`, fixed an issue where result column lookups
would fail for "adapted" SELECT statements that selected for
"constant" value expressions most typically the NULL expression,
as would occur in such places as joined eager loading in conjunction
with limit/offset. This was overall a regression due to issue
:ticket:`6259` which removed all "adaption" for constants like NULL,
"true", and "false", but this broke the case where the same adaption
logic were used to match the constant to a labeled expression referring
to the constant in a subquery.
Bugfix: MySQL expression: may be bindparam or other expression
Fixed issue in MySQL :func:`_mysql.match` construct where passing a clause
expression such as :func:`_sql.bindparam` or other SQL expression for the
"against" parameter would fail. Pull request courtesy Anton Kovalevich.
Mike Bayer [Tue, 5 Oct 2021 15:46:54 +0000 (11:46 -0400)]
Add new section clarifying DBAPI autocommit more fully
Make sure it's documented that autocommit isolation level
is not a connection-level setting, and does not interact with
the connection's notion of a transaction.
Mike Bayer [Fri, 1 Oct 2021 22:04:46 +0000 (18:04 -0400)]
disallow adding to identity map that's been discarded
Fixed bug where iterating a :class:`.Result` from a :class:`_orm.Session`
after that :class:`_orm.Session` were closed would partially attach objects
to that session in an essentially invalid state. It now raises an exception
with a link to new documentation if an **un-buffered** result is iterated
from a :class:`_orm.Session` that was closed or otherwise had the
:meth:`_orm.Session.expunge_all` method called after that :class:`.Result`
was generated. The "prebuffer_rows" execution option, as is used by the
asyncio extension, may be used to produce a :class:`.Result` where the ORM
objects are prebuffered, and in this case iterating the result will produce
a series of detached objects.
Mike Bayer [Mon, 4 Oct 2021 15:21:35 +0000 (11:21 -0400)]
repair any_() / all_() "implicit flip" behavior for None
Fixed an inconsistency in the any_() / all_() functions / methods where the
special behavior these functions have of "flipping" the expression such
that the "ANY" / "ALL" expression is always on the right side would not
function if the comparison were against the None value, that is,
"column.any_() == None" should produce the same SQL expression as "null()
== column.any_()". Added more docs to clarify this as well, plus mentions
that any_() / all_() generally supersede the ARRAY version "any()" /
"all()".
Mike Bayer [Sat, 2 Oct 2021 15:53:55 +0000 (11:53 -0400)]
support utf8mb3 char encoding fully for mysqlclient, others
Fixes to accommodate for the MariaDB 10.6 series, including backwards
incompatible changes in both the mariadb-connector Python driver (supported
on SQLAlchemy 1.4 only) as well as the native 10.6 client libraries that
are used automatically by the mysqlclient DBAPI (applies to both 1.3 and
1.4). The "utf8mb3" encoding symbol is now reported by these client
libraries when the encoding is stated as "utf8", leading to lookup and
encoding errors within the MySQL dialect that does not expect this symbol.
Updates to both the MySQL base library to accommodate for this utf8mb3
symbol being reported as well as to the test suite. Thanks to Georg Richter
for support.
Ensure all SQLAlchemy exception can be properly pickled
Implemented proper ``__reduce__()`` methods for all SQLAlchemy exception
objects to ensure they all support clean round trips when pickling, as
exception objects are often serialized for the purposes of various
debugging tools.
Mike Bayer [Fri, 1 Oct 2021 16:53:40 +0000 (12:53 -0400)]
organize datetime types for correct impls
Fixed bug in SQL Server ``DATETIMEOFFSET`` where the ODBC implementation
would not generate the correct DDL, for cases where the type were converted
using the ``dialect.type_descriptor()`` method, the usage of which is
illustrated in some documented examples for :class:`.TypeDecorator`, though
not necessary for most datatypes. Regression was introduced by
:ticket:`6366`. As part of this change, the full list of SQL Server date
types have been amended to return a "dialect impl" that generates the same
DDL name as the supertype.
Mike Bayer [Fri, 1 Oct 2021 17:18:41 +0000 (13:18 -0400)]
indicate private use of URL.__new__ privately only
Fixed issue where the deprecation warning for the :class:`.URL` constructor
which indicates that the :meth:`.URL.create` method should be used would
not emit if a full positional argument list of seven arguments were passed;
additionally, validation of URL arguments will now occur if the constructor
is called in this way, which was being skipped previously.
Georg Richter [Thu, 30 Sep 2021 22:13:49 +0000 (18:13 -0400)]
correct charset for mariadb connector with mdb 10.6
Updated test suite to pass correctly for MariaDB 10.6 when using the
mariadb-connector driver, which made some adjustments to default encoding.
Pull request courtesy Georg Richter.
Use character set utf8mb4 instead of utf8:
1) Character set for mariadb connector is utf8mb4 and
cannot be changed.
2) Since MariaDB 10.6.1 utf8 is mapped to utf8mb3, and
will be mapped to utf8mb4 in 10.7, see [MDEV-8334](https://jira.mariadb.org/browse/MDEV-8334) (rename
utf8 to utf8mb3)
utf8mb4 character set support was added 12 years ago and
will work with all non eoled MariaDB server versions.
Gord Thompson [Thu, 12 Aug 2021 19:04:28 +0000 (13:04 -0600)]
Modernize tests - calling_mapper_directly
a few changes for py2k:
* map_imperatively() includes the check that a class
is being sent, this was only working for mapper() before
* the test suite didn't place the py2k "autouse" workaround
in the correct order, seemingly, tried to adjust the
per-test ordering setup in pytestplugin.py