Mike Bayer [Fri, 11 Mar 2022 21:23:14 +0000 (16:23 -0500)]
restore quickstart to toc
this was coming out wrong due to the wrong header level
on the page. it needs to be in a visible toc so that
the inner elements show up on the sidebar / top mobile nav.
Mike Bayer [Fri, 11 Mar 2022 21:01:09 +0000 (16:01 -0500)]
further simplify pool-sharing doc
1. the event based approach doesn't require dispose() to be
called at all, and the note that the "pool will hang" makes
no sense. I have no idea what that refers towards
2. the subsequent paragraph about connections and sessions
is unintelligible. old paragraphs like these are likely
why people complain about the docs so much. try to just
say "don't do this", as that is easier than trying to
explain to use connection.invalidate() etc.
Mike Bayer [Fri, 11 Mar 2022 18:40:16 +0000 (13:40 -0500)]
add copybutton
works great, including for plain code plus prompt code
with SQL (copies only the prompt code when prompts are present).
added some styling to zzzeeksphinx
Mike Bayer [Fri, 11 Mar 2022 15:08:36 +0000 (10:08 -0500)]
ORM quickstart
This is done in 1.4 style so it can be backported to 1.4.
Will put this up as is, we can work on it. For 2.0, the
ORM mapping will be updated to mapped_column() style when
we do the full pass.
Mike Bayer [Tue, 8 Mar 2022 14:34:09 +0000 (09:34 -0500)]
support adapt_on_names for with_polymorphic
Added :paramref:`_orm.with_polymorphic.adapt_on_names` to the
:func:`_orm.with_polymorphic` function, which allows a polymorphic load
(typically with concrete mapping) to be stated against an alternative
selectable that will adapt to the original mapped selectable on column
names alone.
Mike Bayer [Tue, 8 Mar 2022 18:40:12 +0000 (13:40 -0500)]
pop the stack that we pushed
Fixed regression caused by :ticket:`7760` where the new capabilities of
:class:`.TextualSelect` were not fully implemented within the compiler
properly, leading to issues with composed INSERT constructs such as "INSERT
FROM SELECT" and "INSERT...ON CONFLICT" when combined with CTE and textual
statements.
Mike Bayer [Mon, 7 Mar 2022 20:11:29 +0000 (15:11 -0500)]
support selectin_polymorphic w/ no fixed polymorphic_on
Fixed issue where the :func:`_orm.polymorphic_selectin` loader option would
not work with joined inheritance mappers that don't have a fixed
"polymorphic_on" column. Additionally added test support for a wider
variety of usage patterns with this construct.
Fixed bug where :func:`_orm.composite` attributes would not work in
conjunction with the :func:`_orm.selectin_polymorphic` loader strategy for
joined table inheritance.
Mike Bayer [Fri, 4 Mar 2022 23:27:24 +0000 (18:27 -0500)]
warn for enum length silently ignored
the "length" parameter is silently ignored when native_enum
is not passed as False. if native_enum is True, a non-native
VARCHAR can still be generated. Warn for this silent ignore
right now, consider having "length" used in all cases where
non-native enum is rendered likely in 2.0.
Mike Bayer [Fri, 4 Mar 2022 22:17:53 +0000 (17:17 -0500)]
fix type string formatting calls
Fixed type-related error messages that would fail for values that were
tuples, due to string formatting syntax, including compile of unsupported
literal values and invalid boolean values.
Mike Bayer [Fri, 4 Mar 2022 21:28:31 +0000 (16:28 -0500)]
correct for pytest discovery
Made corrections to the default pytest configuration so that test discovery
runs correctly; previously, a configuration error had the effect of
discovery locating the wrong files if a super-directory of the current
directory were named "test".
petit87 [Sat, 26 Feb 2022 21:46:32 +0000 (16:46 -0500)]
Fix repr for MySQL SET, generic Enum
Fixed issues in :class:`_mysql.SET` datatype as well as :class:`.Enum`
where the ``__repr__()`` method would not render all optional parameters in
the string output, impacting the use of these types in Alembic
autogenerate. Pull request for MySQL courtesy Yuki Nishimine.
Mike Bayer [Thu, 3 Mar 2022 02:43:53 +0000 (21:43 -0500)]
improve error raise for dialect/pool events w/ async engine
Fixed issues where a descriptive error message was not raised for some
classes of event listening with an async engine, which should instead be a
sync engine instance.
Mike Bayer [Sun, 27 Feb 2022 19:27:54 +0000 (14:27 -0500)]
remove incorrect deprecation message
this message likely referred to ResultProxy,
no idea how it referred to CursorResult, that's a very confusing
issue. ResultProxy -> CursorResult is mostly a name
change as far as backwards compat is concerned so there's
not much "deprecated" here.
Mike Bayer [Fri, 25 Feb 2022 17:40:21 +0000 (12:40 -0500)]
block pypy for now
the most recent pypy 7.3.8 series (3.7 and 3.9 included, likely
3.8 as well) have installed a 9 year old version of SQLite,
and additionally seem to have some other behavioral changes
like formatting of exception messages that is breaking
some tests. as we are waiting on a response at [1]
remove pypy testing for now.
Mike Bayer [Wed, 23 Feb 2022 18:43:03 +0000 (13:43 -0500)]
support cx_Oracle DPI disconnect codes
Added support to parse "DPI" error codes from cx_Oracle exception objects
such as ``DPI-1080`` and ``DPI-1010``, both of which now indicate a
disconnect scenario as of cx_Oracle 8.3.
Mike Bayer [Wed, 23 Feb 2022 17:50:36 +0000 (12:50 -0500)]
support add_cte() for TextualSelect
Fixed issue where the :meth:`.HasCTE.add_cte` method as called upon a
:class:`.TextualSelect` instance was not being accommodated by the SQL
compiler. The fix additionally adds more "SELECT"-like compiler behavior to
:class:`.TextualSelect` including that DML CTEs such as UPDATE and INSERT
may be accommodated.
Mike Bayer [Sun, 20 Feb 2022 14:51:22 +0000 (09:51 -0500)]
improve reflection of inline UNIQUE constraints
Fixed issue where SQLite unique constraint reflection would not work
for an inline UNIQUE constraint where the column name had an underscore
in its name.
Added support for reflecting SQLite inline unique constraints where
the column names are formatted with SQLite "escape quotes" ``[]``
or `` ` ``, which are discarded by the database when producing the
column name.
This method I would assume got committed during the
1.4 engine refactor, where we moved from different kinds of
ResultProxy implementations to different strategy
classes instead. These strategies are set up by
dialects by setting "self.cursor_fetch_strategy"
in the execution context. The method here was
likely a previous iteration of that which got merged
but was never used.
Mike Bayer [Sat, 19 Feb 2022 19:11:19 +0000 (14:11 -0500)]
updates for mariadb connector 1.0.10
Fixed regression in mariadbconnector dialect as of mariadb connector 1.0.10
where the DBAPI no longer pre-buffers cursor.lastrowid. The dialect now
fetches this value proactively for situations where it applies.
test_invalidate_on_results seems to pass for mariadbconnector now.
the driver has likely changed how it buffers result sets. This is
a major change for them to make in a point release so we might
want to watch this in case they reverse course again.
Mike Bayer [Tue, 15 Feb 2022 15:53:07 +0000 (10:53 -0500)]
correct for non-deterministic gc artifacts
Observed the tests here have different profiling
counts when run individually vs. as a group, and
this seems to be due to whether or not results of
each query are garbage collected or not. for
all but one test, ensuring results stay between
query runs seems to meet the current profiling
counts.
Mike Bayer [Sat, 12 Feb 2022 15:50:45 +0000 (10:50 -0500)]
Raise and re-catch NameError from _ModNS
Fixed issue where using a fully qualified path for the classname in
:func:`_orm.relationship` that nonetheless contained an incorrect name for
path tokens that were not the first token, would fail to raise an
informative error and would instead fail randomly at a later step.
Mike Bayer [Tue, 8 Feb 2022 15:12:33 +0000 (10:12 -0500)]
Accommodate escaped_bind_names for defaults/insert params
Fixed issue in Oracle dialect where using a column name that requires
quoting when written as a bound parameter, such as ``"_id"``, would not
correctly track a Python generated default value due to the bound-parameter
rewriting missing this value, causing an Oracle error to be raised.
Mike Bayer [Fri, 4 Feb 2022 14:04:49 +0000 (09:04 -0500)]
ensure exception raised for all stream w/ sync result
Fixed issue where the :meth:`_asyncio.AsyncSession.execute` method failed
to raise an informative exception if the ``stream_results`` execution
option were used, which is incompatible with a sync-style
:class:`_result.Result` object. An exception is now raised in this scenario
in the same way one is already raised when using ``stream_results`` in
conjunction with the :meth:`_asyncio.AsyncConnection.execute` method.
Additionally, for improved stability with state-sensitive dialects such as
asyncmy, the cursor is now closed when this error condition is raised;
previously with the asyncmy dialect, the connection would go into an
invalid state with unconsumed server side results remaining.
Mike Bayer [Fri, 4 Feb 2022 02:58:14 +0000 (21:58 -0500)]
fall back to SHOW VARIABLES for MySQL < 5.6
Fixed regression caused by :ticket:`7518` where changing the syntax "SHOW
VARIABLES" to "SELECT @@" broke compatibility with MySQL versions older
than 5.6, including early 5.0 releases. While these are very old MySQL
versions, a change in compatibility was not planned, so version-specific
logic has been restored to fall back to "SHOW VARIABLES" for MySQL server
versions < 5.6.
includes unrelated orm/test_expire ordering issue , only showing
up on 1.4 / py2.7 but seems to be passing by luck otherwise
Mike Bayer [Sun, 30 Jan 2022 19:25:36 +0000 (14:25 -0500)]
split out declarative varieties into the declarative mapping section
specific declarative styles like those for dataclasses and attrs
should be in the more reference-oriented "declarative_mapping"
section rather than the more introduction-oriented mapping_styles.
this will also make it easier for us to add still more ways of
mapping declaratively for 2.0.
for the cherry-pick, also remove the misleading line about
stubs.
Markus Gerstel [Wed, 26 Jan 2022 09:56:40 +0000 (04:56 -0500)]
Fix up Python logging metadata
Adjusted the logging for key SQLAlchemy components including
:class:`_engine.Engine`, :class:`_engine.Connection` to establish an
appropriate stack level parameter, so that the Python logging tokens
``funcName`` and ``lineno`` when used in custom logging formatters will
report the correct information, which can be useful when filtering log
output; supported on Python 3.8 and above. Pull request courtesy Markus
Gerstel.
Gilbert Gilb's [Sun, 23 Jan 2022 18:00:35 +0000 (13:00 -0500)]
Add compiler support for PostgreSQL "NOT VALID" constraints.
Added compiler support for the PostgreSQL ``NOT VALID`` phrase when rendering
DDL for the :class:`.CheckConstraint`, :class:`.ForeignKeyConstraint`
and :class:`.ForeignKey` schema constructs. Pull request courtesy
Gilbert Gilb's.
Mike Bayer [Sun, 23 Jan 2022 14:28:22 +0000 (09:28 -0500)]
dont test squelched warnings against the filter
I spent days on Ibcf09af25228d39ee5a943fda82d8a9302433726
reading it over and over again and noticed this slight inaccuracy
10 seconds after I merged it.
the assert_warns_message() and assert_warns() functions should
not consider a mismatched warning class as valid for a match.
Mike Bayer [Sun, 23 Jan 2022 14:14:00 +0000 (09:14 -0500)]
make the autoincrement doc a lot more clear
I saw it saying "this parameter has no effect when
Identity is in use", which is not accurate, so I've expanded
this way out with bullets to make the current situation
as clear as possible.
Mike Bayer [Fri, 21 Jan 2022 23:46:37 +0000 (18:46 -0500)]
dont use exception catches for warnings; modernize xdist detection
Improvements to the test suite's integration with pytest such that the
"warnings" plugin, if manually enabled, will not interfere with the test
suite, such that third parties can enable the warnings plugin or make use
of the ``-W`` parameter and SQLAlchemy's test suite will continue to pass.
Additionally, modernized the detection of the "pytest-xdist" plugin so that
plugins can be globally disabled using PYTEST_DISABLE_PLUGIN_AUTOLOAD=1
without breaking the test suite if xdist were still installed. Warning
filters that promote deprecation warnings to errors are now localized to
SQLAlchemy-specific warnings, or within SQLAlchemy-specific sources for
general Python deprecation warnings, so that non-SQLAlchemy deprecation
warnings emitted from pytest plugins should also not impact the test suite.
Identified a bit of cleanup for the PostgreSQL provisioning
as a result.
Mike Bayer [Fri, 21 Jan 2022 15:19:02 +0000 (10:19 -0500)]
Skip PK returned as None for RETURNING, server side default
Fixed regression where the ORM exception that is to be raised when an
INSERT silently fails to actually insert a row (such as from a trigger)
would not be reached, due to a runtime exception raised ahead of time due
to the missing primary key value, thus raising an uninformative exception
rather than the correct one. For 1.4 and above, a new ``FlushError`` is
added for this case that's raised earlier than the previous "null identity"
exception was for 1.3, as a situation where the number of rows actually
INSERTed does not match what was expected is a more critical situation in
1.4 as it prevents batching of multiple objects from working correctly.
This is separate from the case where a newly fetched primary key is
fetched as NULL, which continues to raise the existing "null identity"
exception.
Mike Bayer [Thu, 20 Jan 2022 20:21:17 +0000 (15:21 -0500)]
re-enable tests for asyncmy; fix Binary
Fixed regression in asyncmy dialect caused by :ticket:`7567` where removal
of the PyMySQL dependency broke binary columns, due to the asyncmy dialect
not being properly included within CI tests.
Mike Bayer [Thu, 20 Jan 2022 20:01:47 +0000 (15:01 -0500)]
restore empty list logic to ARRAY of ENUM parsing
Fixed regression where the change in :ticket:`7148` to repair ENUM handling
in PostgreSQL broke the use case of an empty ARRAY of ENUM, preventing rows
that contained an empty array from being handled correctly when fetching
results.
Mike Bayer [Thu, 20 Jan 2022 14:31:42 +0000 (09:31 -0500)]
repair mapper sort
Fixed issue in :meth:`_orm.Session.bulk_save_mappings` where the sorting
that takes place when the ``preserve_order`` parameter is set to False
would sort partially on ``Mapper`` objects, which is rejected in Python
3.11.
Also uses typing_extensions for NotRequired as this symbol
does not seem to be in Python 3.11.0a4 yet. (2.0 only)
Mike Bayer [Wed, 19 Jan 2022 19:31:52 +0000 (14:31 -0500)]
Add AdaptedConnection.run_async
Added new method :meth:`.AdaptedConnection.run_async` to the DBAPI
connection interface used by asyncio drivers, which allows methods to be
called against the underlying "driver" connection directly within a
sync-style function where the ``await`` keyword can't be used, such as
within SQLAlchemy event handler functions. The method is analogous to the
:meth:`_asyncio.AsyncConnection.run_sync` method which translates
async-style calls to sync-style. The method is useful for things like
connection-pool on-connect handlers that need to invoke awaitable methods
on the driver connection when it's first created.
Mike Bayer [Tue, 18 Jan 2022 22:19:24 +0000 (17:19 -0500)]
reject methods as lambda SQL callables
Added an informative error message when a method object is passed to a SQL
construct. Previously, when such a callable were passed, as is a common
typographical error when dealing with method-chained SQL constructs, they
were interpreted as "lambda SQL" targets to be invoked at compilation time,
which would lead to silent failures. As this feature was not intended to be
used with methods, method objects are now rejected.
Mike Bayer [Sun, 16 Jan 2022 15:21:45 +0000 (10:21 -0500)]
enhance double-aliased table logic to handle more cases
Fixed ORM regression where calling the :func:`_orm.aliased` function
against an existing :func:`_orm.aliased` construct would fail to produce
correct SQL if the existing construct were against a fixed table. The fix
allows that the original :func:`_orm.aliased` construct is disregarded if
it were only against a table that's now being replaced. It also allows for
correct behavior when constructing a :func:`_orm.aliased` without a
selectable argument against a :func:`_orm.aliased` that's against a
subuquery, to create an alias of that subquery (i.e. to change its name).
The nesting behavior of :func:`_orm.aliased` remains in place for the case
where the outer :func:`_orm.aliased` object is against a subquery which in
turn refers to the inner :func:`_orm.aliased` object. This is a relatively
new 1.4 feature that helps to suit use cases that were previously served by
the deprecated ``Query.from_self()`` method.
Mike Bayer [Tue, 18 Jan 2022 16:02:57 +0000 (11:02 -0500)]
detect map_imperatively() called twice
Fixed issue where calling upon :meth:`_orm.regsitry.map_imperatively` more
than once for the same class would produce an unexpected error, rather than
an informative error that the target class is already mapped. This behavior
differed from that of the :func:`_orm.mapper` function which does report an
informative message already.
For 2.0, this change also cleans up the logic that detects against
`Mapper()` or `_mapper()` being invoked directly. 1.4's backport will
take on a different format as `mapper()` is still public API in that
release.
José Duarte [Thu, 13 Jan 2022 22:20:06 +0000 (17:20 -0500)]
Fixes(#7561) Add support for postgres.UUID literal_binds compilation
Added string rendering to the :class:`.postgresql.UUID` datatype, so that
stringifying a statement with "literal_binds" that uses this type will
render an appropriate string value for the PostgreSQL backend. Pull request
courtesy José Duarte.
Mike Bayer [Wed, 5 Jan 2022 17:20:46 +0000 (12:20 -0500)]
implement second-level type resolution for literals
Added additional rule to the system that determines ``TypeEngine``
implementations from Python literals to apply a second level of adjustment
to the type, so that a Python datetime with or without tzinfo can set the
``timezone=True`` parameter on the returned :class:`.DateTime` object, as
well as :class:`.Time`. This helps with some round-trip scenarios on
type-sensitive PostgreSQL dialects such as asyncpg, psycopg3 (2.0 only).
Improved support for asyncpg handling of TIME WITH TIMEZONE, which
was not fully implemented.
Mike Bayer [Mon, 10 Jan 2022 19:59:59 +0000 (14:59 -0500)]
ensure with_options not switched to a list
Fixed regression which appeared in 1.4.23 which could cause loader options
to be mis-handled in some cases, in particular when using joined table
inheritance in combination with the ``polymorphic_load="selectin"`` option
as well as relationship lazy loading, leading to a ``TypeError``.