Mike Bayer [Sat, 9 Dec 2023 15:43:37 +0000 (10:43 -0500)]
ensure test suite runs w/o greenlet
This is a reopen of #6136 essentially that repaired the
test suite to run without greenlet but now this has regressed.
add a tox target that explicitly uninstalls greenlet, will
add to CI.
This also changes 2.0 in that the full tox target will
omit dbdrivers that require greenlet.
Michael Oliver [Tue, 5 Dec 2023 22:24:17 +0000 (17:24 -0500)]
Forward `**kw` in `__init_subclass__()` to super
Modified the ``__init_subclass__()`` method used by
:class:`_orm.MappedAsDataclass`, :class:`_orm.DeclarativeBase`` and
:class:`_orm.DeclarativeBaseNoMeta` to accept arbitrary ``**kw`` and to
propagate them to the ``super()`` call, allowing greater flexibility in
arranging custom superclasses and mixins which make use of
``__init_subclass__()`` keyword arguments. Pull request courtesy Michael
Oliver.
eXenon [Mon, 4 Dec 2023 17:39:25 +0000 (12:39 -0500)]
Replace custom URL-encoding method with quote_plus
Fixed URL-encoding of the username and password components of
:class:`.engine.URL` objects when converting them to string using the
:meth:`_engine.URL.render_as_string` method, by using Python standard
library ``urllib.parse.quote_plus``, rather than the legacy home-grown
routine from many years ago. Pull request courtesy of Xavier NUNN.
> A [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime) object `d` is aware if both of the following hold:
>
> `d.tzinfo is not None`
>
> `d.tzinfo.utcoffset(d)` does not return `None`
>
> Otherwise, `d` is naive.
Federico Caselli [Thu, 30 Nov 2023 21:45:36 +0000 (22:45 +0100)]
Remove legacy signatures from session events
Removed legacy signatures dating back to 0.9 release from the
:meth:`_orm.SessionEvents.after_bulk_update` and
:meth:`_orm.SessionEvents.after_bulk_delete`.
Mike Bayer [Thu, 30 Nov 2023 14:11:25 +0000 (09:11 -0500)]
try to gracefully close even in terminate
Adjusted the asyncpg dialect such that when the ``terminate()`` method is
used to discard an invalidated connection, the dialect will first attempt
to gracefully close the conneciton using ``.close()`` with a timeout, if
the operation is proceeding within an async event loop context only. This
allows the asyncpg driver to attend to finalizing a ``TimeoutError``
including being able to close a long-running query server side, which
otherwise can keep running after the program has exited.
Federico Caselli [Wed, 16 Aug 2023 20:18:10 +0000 (22:18 +0200)]
Change Sequence and Identity oracle only kwargs.
Deprecate Oracle only parameters :paramref:`_schema.Sequence.order`,
paramref:`_schema.Identity.order` and :paramref:`_schema.Identity.on_null`.
They should be configured using the dialect kwargs ``oracle_order`` and
oracle_on_null``.
Mike Bayer [Sun, 26 Nov 2023 15:02:47 +0000 (10:02 -0500)]
add MARS connection for aioodbc
on jenkins main we are getting a lot of connection busy with
other results, which we assume is due to the thread-pool based approach
of aioodbc not being very solid.
not clear why the name of the parameter is different in those two
articles. using a totally made up parameter doesn't raise any error,
so it's not clear if this works at all.
Martijn Pieters [Sat, 18 Nov 2023 21:36:08 +0000 (16:36 -0500)]
Add type annotations for Function.filter
This includes all methods / properties on the returned FunctionFilter
object.
This contributes towards #6810
This pull request is:
- [x] A documentation / typographical / small typing 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.
Mike Bayer [Fri, 24 Nov 2023 20:20:31 +0000 (15:20 -0500)]
fully type functions.py
Completed pep-484 typing for the ``sqlalchemy.sql.functions`` module.
:func:`_sql.select` constructs made against ``func`` elements should now
have filled-in return types.
Gerald Venzl [Thu, 23 Nov 2023 19:42:52 +0000 (14:42 -0500)]
Upgrade to Oracle Database 23c Free
### Description
This PR updates the unittest ReadMe and `setup.cfg` to use Oracle Database Free, the successor to Oracle Database XE.
### Checklist
This pull request is:
- [ ] A documentation / typographical / small typing 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.
François Voron [Thu, 23 Nov 2023 15:53:07 +0000 (10:53 -0500)]
docs: fix type annotation in Self-Referential Many-to-Many Relationsh…
A type annotation was wrong in the [Self-Referential Many-to-Many Relationship](https://docs.sqlalchemy.org/en/20/orm/join_conditions.html#self-referential-many-to-many-relationship) code example.
<!-- Provide a general summary of your proposed changes in the Title field above -->
### Description
The type annotation was `right_nodes: Mapped[List["None"]]`. I changed it to `Node` since we refer to the ORM class we're looking at.
### 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:
- [x] A documentation / typographical / small typing 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.
Jan Vollmer [Wed, 22 Nov 2023 18:16:27 +0000 (13:16 -0500)]
add local column to dependency rule error message
Improved the error message produced when the unit of work process sets the
value of a primary key column to NULL due to a related object with a
dependency rule on that column being deleted, to include not just the
destination object and column name but also the source column from which
the NULL value is originating. Pull request courtesy Jan Vollmer.
Mike Bayer [Sat, 18 Nov 2023 15:22:19 +0000 (10:22 -0500)]
update all errors / warnings in schema to use f strings
Fixed issue where error reporting for unexpected schema item when creating
objects like :class:`_schema.Table` would incorrectly handle an argument
that was itself passed as a tuple, leading to a formatting error. The
error message has been modernized to use f-strings.
this change necessitated an update to flake8 as version 5 was
mis-interpreting f-strings that had semicolons in them.
Black is also unable to format some of these f-strings which had
to be broken out, unclear if there is a newer Black available.
Mike Bayer [Mon, 13 Nov 2023 20:52:43 +0000 (15:52 -0500)]
adapt all asyncio dialects to asyncio connector
Adapted all asyncio dialects, including aiosqlite, aiomysql, asyncmy,
psycopg, asyncpg to use the generic asyncio connection adapter first added
in :ticket:`6521` for the aioodbc DBAPI, allowing these dialects to take
advantage of a common framework.
Update type annotation for DBAPI Cursor's executemany()
### Description
As per https://groups.google.com/g/sqlalchemy/c/DkyffAgDmwM, fixes an issue with the DBAPI cursor's executemany() type signature.
### Checklist
This pull request is:
- [x] A documentation / typographical / small typing 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.
Added an initialize step to the import of
``sqlalchemy.ext.asyncio`` so that ``greenlet`` will
be imported only when the asyncio extension is first imported.
Alternatively, the ``greenlet`` library is still imported lazily on
first use to support use case that don't make direct use of the
SQLAlchemy asyncio extension.
Fix typo in exported class in init. #10578
Improve warning for loaderes. #10579
Properly document ARRAY.contains. #10587
Mention how to set a schema to the automatically generated enums. #10583
Improve type of cache key dispatcher
Mike Bayer [Mon, 6 Nov 2023 22:46:14 +0000 (17:46 -0500)]
always derive type from element in annotated case
Fixed issue where use of :func:`_orm.foreign` annotation on a
non-initialized :func:`_orm.mapped_column` construct would produce an
expression without a type, which was then not updated at initialization
time of the actual column, leading to issues such as relationships not
determining ``use_get`` appropriately.
Mike Bayer [Wed, 1 Nov 2023 22:06:49 +0000 (18:06 -0400)]
implement render_nulls for new style bulk ORM INSERT
Implemented the :paramref:`_orm.Session.bulk_insert_mappings.render_nulls`
parameter for new style bulk ORM inserts, allowing ``render_nulls=True`` as
an execution option. This allows for bulk ORM inserts with a mixture of
``None`` values in the parameter dictionaries to use a single batch of rows
for a given set of dicationary keys, rather than breaking up into batches
that omit the NULL columns from each INSERT.
Mike Bayer [Tue, 31 Oct 2023 18:56:37 +0000 (14:56 -0400)]
use _extra_criteria to store with_expression() expression
this is an alternate version of the first patch, which adds extra
handling for the "expression" in local_opts. this patch has
with_expression() use _extra_criteria directly, as this attribute
is currently unpurposed for column-based attributes.
Fixed caching bug where using the :func:`_orm.with_expression` construct in
conjunction with loader options :func:`_orm.selectinload`,
:func:`_orm.lazyload` would fail to substitute bound parameter values
correctly on subsequent caching runs.
Mike Bayer [Tue, 31 Oct 2023 02:14:21 +0000 (22:14 -0400)]
add note that secondary string is Python eval re: identifier names
im not exactly sure why "secondary" string is a Python eval
as I dont know what kind of Python eval someone might put there.
Add explicit note about this referring to table names that have
non-Python identifier characters.
Sören Oldag [Thu, 26 Oct 2023 13:17:41 +0000 (09:17 -0400)]
Add bind casts for BIT on asyncpg
Fixed SQL handling for "insertmanyvalues" when using the
:class:`.postgresql.BIT` datatype with the asyncpg backend. The
:class:`.postgresql.BIT` on asyncpg apparently requires the use of an
asyncpg-specific `BitString` type which is currently exposed when using
this DBAPI, making it incompatible with other PostgreSQL DBAPIs that all
work with plain bitstrings here. A future fix in version 2.1 will
normalize this datatype across all PG backends. Pull request courtesy
Sören Oldag.
Mike Bayer [Tue, 24 Oct 2023 20:05:48 +0000 (16:05 -0400)]
remove type check decorators
in 598ae1d120a35ee9e19cf7f953c7dd51047954d6, we erroneously
merged "no_type_check" decorators. we only merge typing that works
or requires "type: ignore", so remove these
add literal_processors for interval, PG and Oracle
Implemented "literal value processing" for the :class:`.Interval` datatype
for both the PostgreSQL and Oracle dialects, allowing literal rendering of
interval values. Pull request courtesy Indivar Mishra.
Mike Bayer [Tue, 24 Oct 2023 16:06:24 +0000 (12:06 -0400)]
accommodate NULL at the compiler level for literal_render
Added compiler-level None/NULL handling for the "literal processors" of all
datatypes that include literal processing, that is, where a value is
rendered inline within a SQL statement rather than as a bound parameter,
for all those types that do not feature explicit "null value" handling.
Previously this behavior was undefined and inconsistent.
indivar [Fri, 20 Oct 2023 15:25:38 +0000 (11:25 -0400)]
use oracle.INTERVAL for generic interval
Fixed issue in :class:`.Interval` datatype where the Oracle implementation
was not being used for DDL generation, leading to the ``day_precision`` and
``second_precision`` parameters to be ignored, despite being supported by
this dialect. Pull request courtesy Indivar.
Mike Bayer [Fri, 20 Oct 2023 14:19:35 +0000 (10:19 -0400)]
run declarative scan for non-mapped annotated if allow_unmapped
Fixed issue where the ``__allow_unmapped__`` directive failed to allow for
legacy :class:`.Column` / :func:`.deferred` mappings that nonetheless had
annotations such as ``Any`` or a specific type without ``Mapped[]`` as
their type, without errors related to locating the attribute name.
Mike Bayer [Thu, 19 Oct 2023 16:14:14 +0000 (12:14 -0400)]
manufacture empty result for DELETE..RETURNING w/ no description
Established a workaround for what seems to be an intrinsic issue across
MySQL/MariaDB drivers where a RETURNING result for DELETE DML which returns
no rows using SQLAlchemy's "empty IN" criteria fails to provide a
cursor.description, which then yields result that returns no rows,
leading to regressions for the ORM that in the 2.0 series uses RETURNING
for bulk DELETE statements for the "synchronize session" feature. To
resolve, when the specific case of "no description when RETURNING was
given" is detected, an "empty result" with a correct cursor description is
generated and used in place of the non-working cursor.
Mike Bayer [Thu, 19 Oct 2023 15:21:26 +0000 (11:21 -0400)]
dont mis-render value from previous loop iteration
Fixed issue where using the same bound parameter more than once with
``literal_execute=True`` in some combinations with other literal rendering
parameters would cause the wrong values to render due to an iteration
issue.
Mike Bayer [Tue, 17 Oct 2023 22:54:23 +0000 (18:54 -0400)]
revise argument to mysqlclient/pymysql ping
Repaired a new incompatibility in the MySQL "pre-ping" routine where the
``False`` argument passed to ``connection.ping()``, which is intended to
disable an unwanted "automatic reconnect" feature, is being deprecated in
MySQL drivers and backends, and is producing warnings for some versions of
MySQL's native client drivers. It's removed for mysqlclient, whereas for
PyMySQL and drivers based on PyMySQL, the parameter will be deprecated and
removed at some point, so API introspection is used to future proof against
these various stages of removal.
Bryan不可思议 [Wed, 18 Oct 2023 20:31:45 +0000 (16:31 -0400)]
fix AsyncSession.close_all()
Fixed bug with method :meth:`_asyncio.AsyncSession.close_all`
that was not working correctly.
Also added function :func:`_asyncio.close_all_sessions` that's
the equivalent of :func:`_orm.close_all_sessions`.