Fixed bug where a call ``InstanceState.obj()`` could return None when
synchronizing the instance states of the objects in the session in case
they become out of scope but are not yet finalized by the gc. This
case does not happen in cPython, but it may present itself in pypy.
The approach is to allow None to be gracefully handled by the
evaluator itself, ensuring it returns None in all cases when None
is passed in.
Fixes: #5631
Change-Id: I53d38fbea2e72b2e677c6e7f70bf075a58e58945
this test was not actually working correctly against
mariadb and was "failing" (i.e. "passing") inappropriately
for pymysql, mysqlclient. it also started "passing" (i.e. "failing")
for mariadb as of 1.0.3.
modernize reqs here including for mssql bit behavior.
Change-Id: Ia88ee607ec8d59f6140a7e4a1174910382d53674
Repaired a function-level import that was not using SQLAlchemy's standard
late-import system within the sqlalchemy.exc module.
Moved preloaded to sqlalchemy.util.preloaded so that it
does not depend on langhelpers which depends on exc.
Fixes: #5632
Change-Id: I61b7ce9cd461071ce543714739f67aa5aeb47fd6
Add support to ``FETCH {FIRST | NEXT} [ count ] {ROW | ROWS}
{ONLY | WITH TIES}`` in the select for the supported backends,
currently PostgreSQL, Oracle and MSSQL.
Fixes: #5576
Change-Id: Ibb5871a457c0555f82b37e354e7787d15575f1f7
Fixed bug where an error was not raised for lower-case
:func:`_column` added to lower-case :func:`_table` object. This now raises
:class:`_exc.ArgumentError` which has always been the case for
upper-case :class:`_schema.Column` and :class:`_schema.Table`.
Fixes: #5618
Change-Id: Ifcbdf27c022fd2996a5b99559df71fc1c1e0f19c
Fixed bug where an UPDATE statement against a JOIN using MySQL multi-table
format would fail to include the table prefix for the target table if the
statement had no WHERE clause, as only the WHERE clause were scanned to
detect a "multi table update" at that particular point. The target
is now also scanned if it's a JOIN to get the leftmost table as the
primary table and the additional entries as additional FROM entries.
Fixes: #5617
Change-Id: I26d74afebe06e28af28acf960258f170a1627823
a recent rerun of profiles added more profiling data that's
failing over small differences. 15% variance is fine for these
tests that are looking for thousands of encode calls.
Change-Id: I33dac346b2ff07f86b4bc278a7309ca9b7efbaab
Added support for reflecting "identity" columns, which are now returned
as part of the structure returned by :meth:`_reflection.Inspector.get_columns`.
When reflecting full :class:`_schema.Table` objects, identity columns will
be represented using the :class:`_schema.Identity` construct.
Fixed compilation error on oracle for sequence and identity column
``nominvalue`` and ``nomaxvalue`` options that require no space in them.
Improved test compatibility with oracle 18.
As part of the support for reflecting :class:`_schema.Identity` objects,
the method :meth:`_reflection.Inspector.get_columns` no longer returns
``mssql_identity_start`` and ``mssql_identity_increment`` as part of the
``dialect_options``. Use the information in the ``identity`` key instead.
The mssql dialect will assume that at least MSSQL 2005 is used.
There is no hard exception raised if a previous version is detected,
but operations may fail for older versions.
Fixes: #5527Fixes: #5324
Change-Id: If039fe637c46b424499e6bac54a2cbc0dc54cb57
It's better, the majority of these changes look more readable to me.
also found some docstrings that had formatting / quoting issues.
Change-Id: I582a45fde3a5648b2f36bab96bad56881321899b
The :meth:`_sql.Join.alias` method is deprecated and will be removed in
SQLAlchemy 2.0. An explicit select + subquery, or aliasing of the inner
tables, should be used instead.
Fixes: #5010
Change-Id: Ic913afc31f0d70b0605f9a7af2742a0de1f9ad19
since 450f5c0d65 we've been seeing
errors during the uninstrument_class event where first
we saw an internal weakref being collected earlier than seen,
then fixing that we saw the listener collection changing during
iteration for similar reasons.
we would assume the issue is because of the interaction between
mapper / instrumentation/ registry during a test teardown
and the usage of the uninstrument_class event within this
interaction. this interaction is too fundamental to be
relying upon this event in any case and when I wrote this
new code i was planning on changing that part in any case,
I just forgot.
Change-Id: I15744e01bb4d3349bfd529593ebd23eae658eaab
the ORMSelectCompileState was trying to get away with
not building out the "froms" list of the state, but we need
this for select.froms. Build this out and add some tests
for select(), including some other state-oriented use cases.
Fixes: #5614
Change-Id: I29ca200f292cbae87c722bc97a89d7c453d7d27a
With pytest 6.1.0 the root directory calculation logic has
changed and is unreliable on our jenkins setup. make
sure this is set explicitly.
Change-Id: I1d48b887030c32d2f3361fc36e65e8a988d2ba81
References: https://github.com/pytest-dev/pytest/issues/7807
the change in 1e80028550 failed to fully
remove the "future" symbol which then got confused against the
import of the "future" package itself, which is also not needed.
remove it entirely.
pin pytest < 6.1 to see if new error condition may be avoided
Change-Id: Ibe45040120d3772c39faef4a61ed26f90b60c79e
Improved declarative inheritance scanning to not get tripped up when the
same base class appears multiple times in the base inheritance list.
Fixes: #4699
Change-Id: I932e735cd2e2c1efa935936c84219924225d10f1
This WIP is part of the final push for 1.4's docs
to fully "2.0-ize" what we can, and have it all ready.
So far this includes a rewrite of the 2.0 migration,
set up for the 1.4 /2.0 docs style, and a total redesign
of the index page using a new flex layout in zzzeeksphinx.
It also reworks some of the API reference sections
to have more subheaders. zzzeeksphinx is also enhanced
to provide automatic summaries for all api doc section.
Change-Id: I01d360cb9c8749520246b96ee6496143c6037918
Set default type codec for ``json`` and ``jsonb`` types when using
the asyncpg driver. By default asyncpg will not decode them and return
strings instead.
Fixes: #5584
Change-Id: I41348eff8096ccf87b952d7e797c0694c6c4b5c4
This will mark an issue with the "stale" label after
5 days and close after 7.
The goal is that it will mark "question" issues as stale
automatically.
it doesn't give us a way to link it to that label however,
and we have to define it in terms of labels to exclude.
Change-Id: I7c34f4e8fdf4ee0a15baa93b5831e5cdcf72dcc8
Provide support for multiple hosts in the PostgreSQL connection string.
A user requested for SQLAlchemy to support multiple hosts within a PostgreSQL URL string. The proposed fix allows this. In the event that the url contains multiple hosts the proposed code will convert the query["hosts"] tuple into a single string. This allows the hosts to then get converted into a valid dsn variable in the psycopg2 connect function.
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!**
Fixes: #4392Closes: #5554
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5554
Pull-request-sha: 3f7a0ab8df
Change-Id: I3f3768d51b8331de786ffdc025b7ecfc662eafe5
The "slice index" feature used by :class:`_orm.Query` as well as by the
dynamic relationship loader will no longer accept negative indexes in
SQLAlchemy 2.0. These operations do not work efficiently and load the
entire collection in, which is both surprising and undesirable. These
will warn in 1.4 unless the :paramref:`_orm.Session.future` flag is set in
which case they will raise IndexError.
Fixes: #5606
Change-Id: I5f5dcf984a8f41ab3d0e233ef7553e77fd99a771
CI is showing that this listener may be triggered
when the target, a mapped class, has been garbage collected.
I'm not able to reproduce this locally.
Change-Id: Iad96c088a9a3dc28c4bcd716e293c03d3b312efd
The automatic uniquing of rows on the client side is turned off for the new
:term:`2.0 style` of ORM querying. This improves both clarity and
performance. However, uniquing of rows on the client side is generally
necessary when using joined eager loading for collections, as there
will be duplicates of the primary entity for each element in the
collection because a join was used. This uniquing must now be manually
enabled and can be achieved using the new
:meth:`_engine.Result.unique` modifier. To avoid silent failure, the ORM
explicitly requires the method be called when the result of an ORM
query in 2.0 style makes use of joined load collections. The newer
:func:`_orm.selectinload` strategy is likely preferable for eager loading
of collections in any case.
This changeset also fixes an issue where ORM-style "single entity"
results would not apply unique() correctly if results were returned
as tuples.
Fixes: #4395
Change-Id: Ie62e0cb68ef2a6d2120e968b79575a70d057212e
Fixed issue where a non-string object sent to
:class:`_exc.SQLAlchemyError` or a subclass, as occurs with some third
party dialects, would fail to stringify correctly. Pull request
courtesy Andrzej Bartosiński.
Fixes: #5599Closes: #5600
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5600
Pull-request-sha: cdccccc42a
Change-Id: Icd710d9015abc80f61a84893d75fbb33ee0fe46e
Fixes: #5597
Fixes the issue where :meth:`_reflection.has_table` always returns
``False`` for temporary tables.
Change-Id: I03ab04c849a157ce8fd28c07ec3bf4407b0f2c94
For most from_self() tests, move them into
test/orm/test_deprecated.py and replace the existing
test with one that uses aliased() plus a subquery.
This then revealed a few more issues.
Related items:
* Added slice() method to GenerativeSelect, to match that
of orm.Query and to make possible migration of one of the
from_self() tests. moved the utility functions used for this
from orm/util into sql/util.
* repairs a caching issue related to subqueryload
where information being derived from the cached path info
was mixing up with query information based on the per-query
state, specifically an AliasedClass that is per query.
* for the above issue, it seemed like path_registry maybe
had to change so that it represents AliasedClass objects
as their cache key rather than on identity, but it wasn't
needed. still seems like it would be more correct.
* enhances the error message raised by coercions for a case
such as when an AliasedClass holds onto a select() object
and not a subquery(); will name the original and resolved
object for clarity (although how is AliasedClass able to
accept a Select() object in the first place?)
* Added _set_propagate_attrs() to Query so that again if
it's passed to AliasedClass, it doesn't raise an error
during coercion, but again maybe that should also be
rejected up front
Fixes: #5368
Change-Id: I5912aa611d899acc87a75eb5ee9f95990592f210