]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
4 years agoRevert "Use monotonic time for pool age measurement"
Mike Bayer [Wed, 7 Oct 2020 14:09:41 +0000 (10:09 -0400)] 
Revert "Use monotonic time for pool age measurement"

This reverts commit 0220b58917b5a979891b5765f6ac5095e0368489.

I completely misread https://www.python.org/dev/peps/pep-0418/#rationale
and the accuracy of monotonic() is *worse* on windows than time.time(),
which is bizarre.

Change-Id: I2d571e268a2051bea68736507773d3904403af9e

4 years agoforce a sleep for test_reconnect
Mike Bayer [Wed, 7 Oct 2020 13:47:46 +0000 (09:47 -0400)] 
force a sleep for test_reconnect

as I dont have a windows machine to test I don't really know
how to get a millisecond-accurate timer for windows,
Python documentation claimed time.monotonic() did this however
the continued failure of test_reconnect indicates this is not the case
and that the timer is still bumping up by multi-millisecond
granularity.   force a delay instead.

Change-Id: I237b223eabc55c1d47ecece13873be1f7be20e47

4 years agoUse monotonic time for pool age measurement
Mike Bayer [Wed, 7 Oct 2020 12:42:48 +0000 (08:42 -0400)] 
Use monotonic time for pool age measurement

The internal clock used by the :class:`_pool.Pool` object is now
time.monotonic_time() under Python 3.  Under Python 2, time.time() is still
used, which is legacy. This clock is used to measure the age of a
connection against its starttime, and used in comparisons against the
pool_timeout setting as well as the last time the pool was marked as
invalid to determine if the connection should be recycled. Previously,
time.time() was used which was subject to inaccuracies as a result of
system clock changes as well as poor time resolution on windows.

Change-Id: I94f90044c1809508e26a5a00134981c2a00d0405

4 years agoMerge "limit "no identity" test to a hardcoded dialect"
mike bayer [Wed, 7 Oct 2020 11:42:57 +0000 (11:42 +0000)] 
Merge "limit "no identity" test to a hardcoded dialect"

4 years agoMerge "add --notimingintensive; block from github jobs"
mike bayer [Wed, 7 Oct 2020 04:59:10 +0000 (04:59 +0000)] 
Merge "add --notimingintensive; block from github jobs"

4 years agolimit "no identity" test to a hardcoded dialect
Mike Bayer [Wed, 7 Oct 2020 04:50:53 +0000 (00:50 -0400)] 
limit "no identity" test to a hardcoded dialect

this test can't require "skip identity_columns" because
older Postgresql and Oracle report false for "identity_columns",
but their dialects won't skip actually rendering.

for now the only option is to hardcode to a non-identity
dialect.

Change-Id: Ia4f39f393b4ba10b3e82601a22ab75200cd52909

4 years agoMerge "Handle case where InstanceState.obj returns None"
mike bayer [Wed, 7 Oct 2020 04:50:29 +0000 (04:50 +0000)] 
Merge "Handle case where InstanceState.obj returns None"

4 years agoadd --notimingintensive; block from github jobs
Mike Bayer [Wed, 7 Oct 2020 03:48:47 +0000 (23:48 -0400)] 
add --notimingintensive; block from github jobs

this provides a front-end option to disable tests marked
as timing_intensive, all of which are in test_pool, which are more
fragile and aren't consistent on the
github runners.   also remove /reduce unnecessary time.sleep()
from two other pool tests that are not timing intensive.

note that this removes test_hanging_connect_within_overflow
from the github runs via the timing_intensive requirement.

I've also removed MockReconnectTest from exclusions as those are
really important tests and they use mocks so should not have
platform dependent issues.   Need to see what the
windows failures are.

Closes: #5633
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5633
Pull-request-sha: 166833e16ec342dfa10edb287d7aa495ddd1b59d

Change-Id: Icb3d284a2a952e2495d80fa91e22e0b32a54340f

4 years agoMerge "Address minor comments from previous changes"
mike bayer [Wed, 7 Oct 2020 04:15:58 +0000 (04:15 +0000)] 
Merge "Address minor comments from previous changes"

4 years agoHandle case where InstanceState.obj returns None
Federico Caselli [Tue, 6 Oct 2020 19:21:46 +0000 (21:21 +0200)] 
Handle case where InstanceState.obj returns None

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

4 years agomodernize requirements for boolean constraint test
Mike Bayer [Wed, 7 Oct 2020 03:46:03 +0000 (23:46 -0400)] 
modernize requirements for boolean constraint test

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

4 years agoUse preloaded for sql.util import in exc
Mike Bayer [Wed, 7 Oct 2020 01:46:03 +0000 (21:46 -0400)] 
Use preloaded for sql.util import in exc

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

4 years agoAddress minor comments from previous changes
Federico Caselli [Tue, 6 Oct 2020 18:19:49 +0000 (20:19 +0200)] 
Address minor comments from previous changes

Change how pypy is detected. From I0952e54ed9af2952ea340be1945311376ffc1ad2
Fix typos. From Ibb5871a457c0555f82b37e354e7787d15575f1f7

Change-Id: I9657e602267590f10a74df27a84e4292da94c30a

4 years agoMerge "Fetch first support"
mike bayer [Mon, 5 Oct 2020 13:55:55 +0000 (13:55 +0000)] 
Merge "Fetch first support"

4 years agoMerge "Improve some documentations"
mike bayer [Mon, 5 Oct 2020 13:35:47 +0000 (13:35 +0000)] 
Merge "Improve some documentations"

4 years agoFetch first support
Federico Caselli [Tue, 29 Sep 2020 20:49:09 +0000 (22:49 +0200)] 
Fetch first support

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

4 years agoEnable pypy tests on github workflow
Federico Caselli [Sat, 18 Apr 2020 16:10:59 +0000 (18:10 +0200)] 
Enable pypy tests on github workflow

Fixes: #5223
Change-Id: I0952e54ed9af2952ea340be1945311376ffc1ad2

4 years agoMerge "use execute_20 to preserve compiled cache"
mike bayer [Fri, 2 Oct 2020 16:07:30 +0000 (16:07 +0000)] 
Merge "use execute_20 to preserve compiled cache"

4 years agouse execute_20 to preserve compiled cache
Mike Bayer [Thu, 1 Oct 2020 22:39:42 +0000 (18:39 -0400)] 
use execute_20 to preserve compiled cache

Fixes: #5420
Change-Id: I3e5a255207da752b7b7cc9b8f41ad5e2ccd0b447

4 years agoaccommodate for null in sqlite regex handler
Mike Bayer [Fri, 2 Oct 2020 12:15:41 +0000 (08:15 -0400)] 
accommodate for null in sqlite regex handler

Fixes: #5624
Change-Id: Ic20dcde0a1e96b9981c63cac3cd34c7fdc7bd395

4 years agoMerge "raise on lower-case column shared to multiple tables"
mike bayer [Wed, 30 Sep 2020 13:56:55 +0000 (13:56 +0000)] 
Merge "raise on lower-case column shared to multiple tables"

4 years agoraise on lower-case column shared to multiple tables
Mike Bayer [Wed, 30 Sep 2020 12:37:57 +0000 (08:37 -0400)] 
raise on lower-case column shared to multiple tables

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

4 years agofix too-short underline
Mike Bayer [Wed, 30 Sep 2020 13:01:32 +0000 (09:01 -0400)] 
fix too-short underline

Change-Id: Id9ac0b45f0859199e7db61ef5d4fac956b74b2ba

4 years agoMerge "Support for multiple hosts in PostgreSQL connection string"
mike bayer [Wed, 30 Sep 2020 12:07:25 +0000 (12:07 +0000)] 
Merge "Support for multiple hosts in PostgreSQL connection string"

4 years agoScan for tables without relying upon whereclause
Mike Bayer [Tue, 29 Sep 2020 18:17:42 +0000 (14:17 -0400)] 
Scan for tables without relying upon whereclause

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

4 years agobump variance on test_string, test_unicode
Mike Bayer [Tue, 29 Sep 2020 19:44:33 +0000 (15:44 -0400)] 
bump variance on test_string, test_unicode

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

4 years agoImprove some documentations
Federico Caselli [Sat, 26 Sep 2020 14:02:05 +0000 (16:02 +0200)] 
Improve some documentations

Change-Id: Ibcb0da3166b94aa58fa92d544c3e5cf75844546e

4 years agoAdd reflection for Identity columns
Federico Caselli [Sat, 19 Sep 2020 20:29:38 +0000 (22:29 +0200)] 
Add reflection for Identity columns

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: #5527
Fixes: #5324
Change-Id: If039fe637c46b424499e6bac54a2cbc0dc54cb57

4 years agoupgrade to black 20.8b1
Mike Bayer [Mon, 28 Sep 2020 18:08:59 +0000 (14:08 -0400)] 
upgrade to black 20.8b1

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

4 years agoAdd deprecation warning for .join().alias()
Gord Thompson [Sun, 13 Sep 2020 18:37:40 +0000 (12:37 -0600)] 
Add deprecation warning for .join().alias()

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

4 years agoMerge "build the full compilestate every time"
mike bayer [Mon, 28 Sep 2020 13:56:58 +0000 (13:56 +0000)] 
Merge "build the full compilestate every time"

4 years agoMerge "dont use uninstrument event to dispose registry entry"
mike bayer [Mon, 28 Sep 2020 13:54:25 +0000 (13:54 +0000)] 
Merge "dont use uninstrument event to dispose registry entry"

4 years agodont use uninstrument event to dispose registry entry
Mike Bayer [Mon, 28 Sep 2020 02:40:09 +0000 (22:40 -0400)] 
dont use uninstrument event to dispose registry entry

since 450f5c0d6519a439f4025c3892fe4c 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

4 years agobuild the full compilestate every time
Mike Bayer [Mon, 28 Sep 2020 03:18:57 +0000 (23:18 -0400)] 
build the full compilestate every time

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

4 years agoset pytest rootdir
Mike Bayer [Mon, 28 Sep 2020 02:19:27 +0000 (22:19 -0400)] 
set pytest rootdir

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

4 years agoMerge "Accommodate for same base class multiple times in inherits list"
mike bayer [Mon, 28 Sep 2020 02:25:37 +0000 (02:25 +0000)] 
Merge "Accommodate for same base class multiple times in inherits list"

4 years agoRepair erroneous "future" symbol
Mike Bayer [Sun, 27 Sep 2020 15:06:48 +0000 (11:06 -0400)] 
Repair erroneous "future" symbol

the change in 1e800285508ecd869c6874fed 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

4 years agoAccommodate for same base class multiple times in inherits list
Mike Bayer [Sun, 27 Sep 2020 15:44:58 +0000 (11:44 -0400)] 
Accommodate for same base class multiple times in inherits list

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

4 years agoSupport pytest 6.x
Mike Bayer [Sun, 27 Sep 2020 01:01:01 +0000 (21:01 -0400)] 
Support pytest 6.x

pytest has removed support for pytest.Class().collect()
and we need to use from_parent.

Change-Id: Ia5fed9b22e76c99f71489283acee207f996f52a4

4 years agoformatting fixes, some content addition
Mike Bayer [Fri, 25 Sep 2020 04:10:04 +0000 (00:10 -0400)] 
formatting fixes, some content addition

Change-Id: I807f9763252cdb18ba8702cf42fdb2a7d4c72b52

4 years agoMerge "new docs WIP"
mike bayer [Fri, 25 Sep 2020 03:19:21 +0000 (03:19 +0000)] 
Merge "new docs WIP"

4 years agonew docs WIP
Mike Bayer [Thu, 17 Sep 2020 22:15:42 +0000 (18:15 -0400)] 
new docs WIP

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

4 years agoMerge "Improve Asyncpg json handling"
mike bayer [Thu, 24 Sep 2020 02:19:18 +0000 (02:19 +0000)] 
Merge "Improve Asyncpg json handling"

4 years agoImprove Asyncpg json handling
Federico Caselli [Mon, 21 Sep 2020 17:59:00 +0000 (19:59 +0200)] 
Improve Asyncpg json handling

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

4 years agoAdd pypi shields
Mike Bayer [Wed, 23 Sep 2020 18:47:43 +0000 (14:47 -0400)] 
Add pypi shields

These are all available from the same shields.io source,
courtesy @dolfinus

Fixes: #5594
Change-Id: I985c415f50627d328384a8fddf9a1457663ee00d

4 years agotry out the github stale hook.
Mike Bayer [Wed, 23 Sep 2020 16:04:18 +0000 (12:04 -0400)] 
try out the github stale hook.

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

4 years agoSupport for multiple hosts in PostgreSQL connection string
RamonWill [Wed, 2 Sep 2020 22:43:53 +0000 (18:43 -0400)] 
Support for multiple hosts in PostgreSQL connection string

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: #4392
Closes: #5554
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5554
Pull-request-sha: 3f7a0ab8df9f1411a9f1ac0e152583bc7bf0c365

Change-Id: I3f3768d51b8331de786ffdc025b7ecfc662eafe5

4 years agoMerge "Deprecate negative slice indexes"
mike bayer [Tue, 22 Sep 2020 19:47:21 +0000 (19:47 +0000)] 
Merge "Deprecate negative slice indexes"

4 years agoMerge "Tweak docker config for mssql"
mike bayer [Tue, 22 Sep 2020 19:00:06 +0000 (19:00 +0000)] 
Merge "Tweak docker config for mssql"

4 years agoDeprecate negative slice indexes
Mike Bayer [Tue, 22 Sep 2020 14:26:35 +0000 (10:26 -0400)] 
Deprecate negative slice indexes

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

4 years agoExpect collected weak reference in ORM listener
Mike Bayer [Tue, 22 Sep 2020 13:00:44 +0000 (09:00 -0400)] 
Expect collected weak reference in ORM listener

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

4 years agoMerge "restore slice methods to dynamic query"
mike bayer [Tue, 22 Sep 2020 01:54:52 +0000 (01:54 +0000)] 
Merge "restore slice methods to dynamic query"

4 years agorestore slice methods to dynamic query
Mike Bayer [Tue, 22 Sep 2020 00:17:04 +0000 (20:17 -0400)] 
restore slice methods to dynamic query

in f0f08db5715e41cc08e57dbc76a85300b these got
lost, put them back and test

Change-Id: Id1962e1f5d6160fe222becec5a8e32ec6a40017a

4 years agoRaise if unique() not applied to 2.0 joined eager load results
Mike Bayer [Mon, 21 Sep 2020 21:28:03 +0000 (17:28 -0400)] 
Raise if unique() not applied to 2.0 joined eager load results

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

4 years agoTweak docker config for mssql
Gord Thompson [Sun, 20 Sep 2020 20:43:33 +0000 (14:43 -0600)] 
Tweak docker config for mssql

Change-Id: Iae6fca41976f9cd7a3870f18eadfbea146d572dd

4 years agoMerge "Stringify correctly for non-str exception argument"
mike bayer [Sun, 20 Sep 2020 19:01:53 +0000 (19:01 +0000)] 
Merge "Stringify correctly for non-str exception argument"

4 years agoStringify correctly for non-str exception argument
Andrzej BartosiÅ„ski [Sat, 19 Sep 2020 16:47:46 +0000 (12:47 -0400)] 
Stringify correctly for non-str exception argument

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: #5599
Closes: #5600
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5600
Pull-request-sha: cdccccc42a6ac8de771593a43ee8675bfd8dbeb6

Change-Id: Icd710d9015abc80f61a84893d75fbb33ee0fe46e

4 years agoFix has_table() for mssql temporary tables
Gord Thompson [Fri, 18 Sep 2020 22:33:17 +0000 (16:33 -0600)] 
Fix has_table() for mssql temporary tables

Fixes: #5597
Fixes the issue where :meth:`_reflection.has_table` always returns
``False`` for temporary tables.

Change-Id: I03ab04c849a157ce8fd28c07ec3bf4407b0f2c94

4 years agoMerge "Complete deprecation of from_self()"
mike bayer [Sat, 19 Sep 2020 03:10:47 +0000 (03:10 +0000)] 
Merge "Complete deprecation of from_self()"

4 years agoComplete deprecation of from_self()
Mike Bayer [Fri, 18 Sep 2020 17:29:42 +0000 (13:29 -0400)] 
Complete deprecation of from_self()

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

4 years agoAdd support for Azure authentication options
Gord Thompson [Thu, 17 Sep 2020 16:32:31 +0000 (10:32 -0600)] 
Add support for Azure authentication options

Fixes: #5592
Change-Id: I0688e5ea0fc6b01a0b72f397daea8f57a2ec0766

4 years agoMerge "Create a framework to allow all SQLALCHEMY_WARN_20 to pass"
mike bayer [Wed, 16 Sep 2020 18:45:51 +0000 (18:45 +0000)] 
Merge "Create a framework to allow all SQLALCHEMY_WARN_20 to pass"

4 years agoCreate a framework to allow all SQLALCHEMY_WARN_20 to pass
Mike Bayer [Mon, 17 Aug 2020 21:24:27 +0000 (17:24 -0400)] 
Create a framework to allow all SQLALCHEMY_WARN_20 to pass

As the test suite has widespread use of many patterns
that are deprecated, enable SQLALCHEMY_WARN_20 globally
for the test suite but then break the warnings filter
out into a whole list of all the individual warnings
we are looking for.  this way individual changesets
can target a specific class of warning, as many of these
warnings will indivdidually affect dozens of files
and potentially hundreds of lines of code.

Many warnings are also resolved here as this
patch started out that way.   From this point
forward there should be changesets that target a
subset of the warnings at a time.

For expediency, updates some migration 2.0 docs
for ORM as well.

Change-Id: I98b8defdf7c37b818b3824d02f7668e3f5f31c94

4 years agoDon't change asyncpg's "char" codec
Mike Bayer [Wed, 16 Sep 2020 12:26:14 +0000 (08:26 -0400)] 
Don't change asyncpg's "char" codec

This codec was used to ensure the "pg_attribute.generated"
column comes back as a string and not bytes, matching how
other PG drivers treat this datatype.   However, this breaks
asyncpg's internal implementation of set_type_codec going forward
and the "char" datatype is actually a bytes in any case.
So at the moment it appears psycopg2/pg8000 are broken for mis-treatment
of the datatype and asyncpg is broken in that it was allowing
us to change a codec that it appears to rely upon internally.

Fixes: #5586
Change-Id: I937eba315904721aa4e2726b95432910a8affe5f

4 years agoMerge "Fix ORM gc-related test that seems to be failing on CI"
mike bayer [Wed, 16 Sep 2020 14:43:40 +0000 (14:43 +0000)] 
Merge "Fix ORM gc-related test that seems to be failing on CI"

4 years agoFix ORM gc-related test that seems to be failing on CI
Mike Bayer [Wed, 16 Sep 2020 13:50:25 +0000 (09:50 -0400)] 
Fix ORM gc-related test that seems to be failing on CI

The test relied on the primary key value not being
of a certain number.

Change-Id: I9bd76bee542da44b630a426f1102fc682ad2d7b3

4 years agoMerge "Make :class:`_orm.registry` ``bind`` a private parameter."
mike bayer [Wed, 16 Sep 2020 14:18:59 +0000 (14:18 +0000)] 
Merge "Make :class:`_orm.registry` ``bind`` a private parameter."

4 years agoMerge "Correct for SQL Server temp table owner"
mike bayer [Wed, 16 Sep 2020 01:27:05 +0000 (01:27 +0000)] 
Merge "Correct for SQL Server temp table owner"

4 years agoCorrect for SQL Server temp table owner
Mike Bayer [Tue, 15 Sep 2020 22:48:36 +0000 (18:48 -0400)] 
Correct for SQL Server temp table owner

on my machine, the owner for a temp table comes out as
dbo, and i am testing against a CI machine.  im not sure
what happens on a CI machine except perhaps that it provisions
new databases is changing things.   in any case, since we
are searching the tempdb for the name, get the schema/owner also.

Also refines the test to use a single connection and a transaction
that rolls back, doesn't hang here but let's see what CI does.

Change-Id: I522596ccc526cdab14c516b9a566ff666ac57dd6

4 years agoMake :class:`_orm.registry` ``bind`` a private parameter.
Federico Caselli [Mon, 14 Sep 2020 21:36:14 +0000 (23:36 +0200)] 
Make :class:`_orm.registry` ``bind`` a private parameter.

Explicitly deprecate ``bind`` from :func:`_orm.declarative_base`
and :func:`_orm.as_declarative`.

Some other documentation cleanup on declarative documentation.

Change-Id: I3f7918d23833b2778ab7009ac5018841deb19f75

4 years agoRemove silent ignore for skip_locked w/ unsupported backends
Gord Thompson [Sun, 13 Sep 2020 22:38:13 +0000 (16:38 -0600)] 
Remove silent ignore for skip_locked w/ unsupported backends

For SQLAlchemy 1.4:

The "skip_locked" keyword used with ``with_for_update()`` will render "SKIP
LOCKED" on all MySQL backends, meaning it will fail for MySQL less than
version 8 and on current MariaDB backends.  This is because those backends
do not support "SKIP LOCKED" or any equivalent, so this error should not be
silently ignored.   This is upgraded from a warning in the 1.3 series.

For SQLAlchemy 1.3:

The "skip_locked" keyword used with ``with_for_update()`` will emit a
warning when used on MariaDB backends, and will then be ignored.   This is
a deprecated behavior that will raise in SQLAlchemy 1.4, as an application
that requests "skip locked" is looking for a non-blocking operation which
is not available on those backends.

Fixes: #5578
Change-Id: I49ccb6c6ff46eafed12b77f51e1da8e0e397966c

4 years agoMerge "Rename Core expression isnot, not_in_"
mike bayer [Mon, 14 Sep 2020 20:35:51 +0000 (20:35 +0000)] 
Merge "Rename Core expression isnot, not_in_"

4 years agoMerge "Pass all pool parameters in recreate()"
mike bayer [Mon, 14 Sep 2020 18:25:51 +0000 (18:25 +0000)] 
Merge "Pass all pool parameters in recreate()"

4 years agoPass all pool parameters in recreate()
Mike Bayer [Mon, 14 Sep 2020 14:14:48 +0000 (10:14 -0400)] 
Pass all pool parameters in recreate()

The following pool parameters were not being propagated to the new pool
created when :meth:`_engine.Engine.dispose` were called: ``pre_ping``,
``use_lifo``.  Additionally the ``recycle`` and ``reset_on_return``
parameters were not propagated for the :class:`_engine.AssertionPool`
class.  These issues have been fixed.

Fixes: #5582
Change-Id: Ifdb703aa7e849652242b9ff8071c854cd1d77e71

4 years agoRename Core expression isnot, not_in_
jonathan vanasco [Tue, 1 Sep 2020 20:56:53 +0000 (16:56 -0400)] 
Rename Core expression isnot, not_in_

Several operators are renamed to achieve more consistent naming across
SQLAlchemy.

The operator changes are:

* `isnot` is now `is_not`
* `not_in_` is now `not_in`

Because these are core operators, the internal migration strategy for this
change is to support legacy terms for an extended period of time -- if not
indefinitely -- but update all documentation, tutorials, and internal usage
to the new terms.  The new terms are used to define the functions, and
the legacy terms have been deprecated into aliases of the new terms.

Fixes: #5429
Change-Id: Ia1e66e7a50ac35d3f6260d8bf6ba3ce8087cbad2

4 years agoAdapt event exec_once_mutex to asyncio
Mike Bayer [Mon, 14 Sep 2020 12:04:09 +0000 (08:04 -0400)] 
Adapt event exec_once_mutex to asyncio

The pool makes use of a threading.Lock() for the
"first_connect" event.  if the pool is async make sure this
is a greenlet-adapted asyncio lock.

Fixes: #5581
Change-Id: If52415839c7ed82135465f1fe93b95d86c305820

4 years agoMerge "Update session.execute() and related documentation"
mike bayer [Sun, 13 Sep 2020 18:00:33 +0000 (18:00 +0000)] 
Merge "Update session.execute() and related documentation"

4 years agoUpdate session.execute() and related documentation
Mike Bayer [Sun, 13 Sep 2020 17:15:29 +0000 (13:15 -0400)] 
Update session.execute() and related documentation

The docs here were completely out of date and referred
to behaviors that are no longer true, behaviors that are
deprecated, etc.   For the moment, take out all the verbiage
so that nothing incorrect is present.   New ORM documentation
will need to be constructed to support this statement.

Change-Id: I4782aebb6443ceb68752c3b52b574fd30658ebc9

4 years agoDeprecate engine-wise ss cursors; repair mariadbconnector
Mike Bayer [Sun, 13 Sep 2020 14:36:16 +0000 (10:36 -0400)] 
Deprecate engine-wise ss cursors; repair mariadbconnector

The server_side_cursors engine-wide feature relies upon
regexp parsing of statements a well as general guessing as
to when the feature should be used.   This is not within the
2.0 way of doing things and should be removed.

Additionally, mariadbconnector defaults to unbuffered cursors;
add new cursor hooks so that mariadbconnector can specify
buffered or unbuffered cursors without too much difficulty.
This will also correctly default mariadbconnector to buffered
cursors which should repair the segfaults we've been getting.

Try to restore the assert_raises that was removed in
5b6dfc0c38bf1f01da4b8 to see if mariadbconnector segfaults
are resolved.

Change-Id: I77f1c972c742e40694972f578140bb0cac8c39eb

4 years agoEnsure cursor is closed for scalar() if make_row fails
Mike Bayer [Sat, 12 Sep 2020 20:07:50 +0000 (16:07 -0400)] 
Ensure cursor is closed for scalar() if make_row fails

As we have some tests that are against enums which
can raise on fetch, if we call scalar() and it fails,
we need to close the cursor.  mariadb segfaults
etc. seem to have been caused by this.

Change-Id: I8261f6fe7f972ae2d8702650440fd8d71e9bce53

4 years agoMerge "Improve handling of covering indexes"
mike bayer [Sat, 12 Sep 2020 19:46:50 +0000 (19:46 +0000)] 
Merge "Improve handling of covering indexes"

4 years agoImprove handling of covering indexes
Gord Thompson [Tue, 1 Sep 2020 20:36:40 +0000 (14:36 -0600)] 
Improve handling of covering indexes

Improved support for covering indexes (with INCLUDE columns). Added the
ability for postgresql to render CREATE INDEX statements with an INCLUDE
clause from Core. Index reflection also report INCLUDE columns separately
for both mssql and postgresql (11+).

Fixes: #4458
Change-Id: If0b82103fbc898cdaeaf6a6d2d421c732744acd6

4 years agoMerge "Raname ``mustexit`` to ``must_exist``"
mike bayer [Sat, 12 Sep 2020 16:36:00 +0000 (16:36 +0000)] 
Merge "Raname ``mustexit`` to ``must_exist``"

4 years agoMerge "Add missing "temp_table_reflect_indexes" to SuiteRequirements"
mike bayer [Sat, 12 Sep 2020 16:28:28 +0000 (16:28 +0000)] 
Merge "Add missing "temp_table_reflect_indexes" to SuiteRequirements"

4 years agoMerge "Do not specify type on mssql by default"
mike bayer [Sat, 12 Sep 2020 16:26:39 +0000 (16:26 +0000)] 
Merge "Do not specify type on mssql by default"

4 years agoMerge "Reflect mssql/postgresql filtered/partial indexes"
mike bayer [Sat, 12 Sep 2020 16:26:28 +0000 (16:26 +0000)] 
Merge "Reflect mssql/postgresql filtered/partial indexes"

4 years agoReflect mssql/postgresql filtered/partial indexes
RamonWill [Thu, 20 Aug 2020 19:05:39 +0000 (15:05 -0400)] 
Reflect mssql/postgresql filtered/partial indexes

Added support for inspection / reflection of partial indexes / filtered
indexes, i.e. those which use the ``mssql_where`` or ``postgresql_where``
parameters, with :class:`_schema.Index`.   The entry is both part of the
dictionary returned by :meth:`.Inspector.get_indexes` as well as part of a
reflected :class:`_schema.Index` construct that was reflected.  Pull
request courtesy Ramon Williams.

**Have a nice day!**
Fixes: #4966
Closes: #5504
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5504
Pull-request-sha: b3018bac987081193b2e65cfdb6aeb7d5d270fcd

Change-Id: Icbb2f93d1545700718ccb5222097185b815f5dbc

4 years agoDo not specify type on mssql by default
Federico Caselli [Fri, 7 Aug 2020 21:38:02 +0000 (23:38 +0200)] 
Do not specify type on mssql by default

Make optional sequences render as identity in mssql
Remove unused dialect option sequence_default_column_type

Change-Id: I821eeffcb442f8d1b69186a9b798b15c3d8d6ff3

4 years agoMerge "Emit deprecation warning for **kw passed to session.execute()"
mike bayer [Sat, 12 Sep 2020 13:10:19 +0000 (13:10 +0000)] 
Merge "Emit deprecation warning for **kw passed to session.execute()"

4 years agoTear down InstrumentationEvents for declarative test
Mike Bayer [Fri, 11 Sep 2020 22:15:51 +0000 (18:15 -0400)] 
Tear down InstrumentationEvents for declarative test

Fixes gc collection issues later on that occur in test_mixin.py

HUGE thanks to Federico Caselli for finding the issue!

Change-Id: I6444e868ab3d6ff62fb644ebe2fbded7df139c9c

4 years agoRevert "remote debugging"
Mike Bayer [Fri, 11 Sep 2020 22:09:31 +0000 (18:09 -0400)] 
Revert "remote debugging"

This reverts commit ce0b2f3cd1869331b6bcc971219789f3578ff705.

Revert "remote debugging continued"

This reverts commit 881d6f12f70e1b594695e2bbc7b87ab846407f58.

Revert "try to debug failing test on github workers"

This reverts commit 26d2c43c141ba6240fd2d2e01c280ecbe64c3faf.

Revert "Attempt to strengthen gc test"

This reverts commit 73cdd6c21fb5a9699ab8987f59c21ddef3d0b896.

4 years agoremote debugging
Mike Bayer [Fri, 11 Sep 2020 20:37:56 +0000 (16:37 -0400)] 
remote debugging

Change-Id: I3eee96df57caea70d08993287014b5795d8a3716

4 years agoremote debugging continued
Mike Bayer [Fri, 11 Sep 2020 20:13:00 +0000 (16:13 -0400)] 
remote debugging continued

Change-Id: I9e03d50ec00637e47ea87883fd9f450f3ffa8101

4 years agotry to debug failing test on github workers
Mike Bayer [Fri, 11 Sep 2020 18:27:30 +0000 (14:27 -0400)] 
try to debug failing test on github workers

Change-Id: I18c4761dba96b8abeb1461974ee6ed19b299dfdf

4 years agoAttempt to strengthen gc test
Mike Bayer [Fri, 11 Sep 2020 15:44:20 +0000 (11:44 -0400)] 
Attempt to strengthen gc test

- ensure class registry is empty first
- gc_collect() twice

Change-Id: I61324931bfc1aafce97880320951e568be88f121

4 years agofix typos
Mike Bayer [Fri, 11 Sep 2020 15:07:33 +0000 (11:07 -0400)] 
fix typos

Change-Id: I7649576bd1e100fd6f8968f0256b074263943a44

4 years agoEmit deprecation warning for **kw passed to session.execute()
Mike Bayer [Fri, 11 Sep 2020 14:50:58 +0000 (10:50 -0400)] 
Emit deprecation warning for **kw passed to session.execute()

Passing keyword arguments to methods such as :meth:`_orm.Session.execute`
to be passed into the :meth:`_orm.Session.get_bind` method is deprecated;
the new :paramref:`_orm.Session.execute.bind_arguments` dictionary should
be passed instead.

Fixes: #5573
Change-Id: I555bda84384dbf6d12ba4483c486f9488be0fa25

4 years agoBuild out new declarative systems; deprecate mapper()
Mike Bayer [Mon, 31 Aug 2020 15:46:55 +0000 (11:46 -0400)] 
Build out new declarative systems; deprecate mapper()

The ORM Declarative system is now unified into the ORM itself, with new
import spaces under ``sqlalchemy.orm`` and new kinds of mappings.  Support
for decorator-based mappings without using a base class, support for
classical style-mapper() calls that have access to the declarative class
registry for relationships, and full integration of Declarative with 3rd
party class attribute systems like ``dataclasses`` and ``attrs`` is now
supported.

Fixes: #5508
Change-Id: I130b2b6edff6450bfe8a3e6baa099ff04b5471ff

4 years agoAdd 3rd party integration issues FAQ; add numpy
Mike Bayer [Thu, 10 Sep 2020 19:48:14 +0000 (15:48 -0400)] 
Add 3rd party integration issues FAQ; add numpy

Users of numpy and pandas should refer to this section
where we will try to catalog the common issues that don't
really have an automatic solution.

Fixes: #5552
Change-Id: I02990e328616ccb21933ffda1167c52256bace07

4 years agoAdd more docs for populate_existing(); link with_for_update
Mike Bayer [Thu, 10 Sep 2020 15:56:34 +0000 (11:56 -0400)] 
Add more docs for populate_existing(); link with_for_update

The populate_existing() method is actually changing
to be an execution option, however it has almost no
mention in the narrative docs so add docs in terms of the
1.x version first, including that we mention you almost
definitely want to use this method if you are also using
with_for_update().

Fixes: #5572
Fixes: #4774
Change-Id: Ieca916400622c1ffc1ae81204132a02a0983594c