]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
4 years agoMerge "make URL immutable"
mike bayer [Wed, 26 Aug 2020 02:44:17 +0000 (02:44 +0000)] 
Merge "make URL immutable"

4 years agoMerge "More descriptive error for non-mapped string prop name"
mike bayer [Wed, 26 Aug 2020 02:43:32 +0000 (02:43 +0000)] 
Merge "More descriptive error for non-mapped string prop name"

4 years agomake URL immutable
Mike Bayer [Fri, 21 Aug 2020 18:44:04 +0000 (14:44 -0400)] 
make URL immutable

it's not really correct that URL is mutable and doesn't do
any argument checking.   propose replacing it with an immutable
named tuple with rich copy-and-mutate methods.

At the moment this makes a hard change to the CreateEnginePlugin
docs that previously recommended url.query.pop().  I can't find
any plugins on github other than my own that are using this
feature, so see if we can just make a hard change on this one.

Fixes: #5526
Change-Id: I28a0a471d80792fa8c28f4fa573d6352966a4a79

4 years agoMerge "Updates for MariaDB sequences"
mike bayer [Tue, 25 Aug 2020 22:14:19 +0000 (22:14 +0000)] 
Merge "Updates for MariaDB sequences"

4 years agoMore descriptive error for non-mapped string prop name
jonathan vanasco [Mon, 20 Apr 2020 17:56:49 +0000 (13:56 -0400)] 
More descriptive error for non-mapped string prop name

Fixed issue where using a loader option against a string attribute name
that is not actually a mapped attribute, such as a plain Python descriptor,
would raise an uninformative AttributeError;  a descriptive error is now
raised.

Fixes: #4589
Closes: #4594
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4594
Pull-request-sha: 2b7ed5240f49be90f9390e3d041c9cb957083465

Change-Id: I66b9937991eb7cdbe074a92f490af1c80d16449e

4 years agoMerge "Improve docs of Identity columns."
mike bayer [Mon, 24 Aug 2020 22:46:12 +0000 (22:46 +0000)] 
Merge "Improve docs of Identity columns."

4 years agoFix typo in docs examples of psycopg2.connect
Federico Caselli [Mon, 24 Aug 2020 21:05:10 +0000 (23:05 +0200)] 
Fix typo in docs examples of psycopg2.connect

Fixes: #5535
Change-Id: I7341137ec63c5a7978f9fe15ad1a932e068321c2

4 years agoImprove docs of Identity columns.
Federico Caselli [Mon, 24 Aug 2020 19:13:49 +0000 (21:13 +0200)] 
Improve docs of Identity columns.

Change-Id: Iba85ac3c2c9f40878768d74a5dd33083fc68e504

4 years agoAdd deprecation warning for mssql legacy_schema_aliasing
Gord Thompson [Thu, 20 Aug 2020 22:26:13 +0000 (16:26 -0600)] 
Add deprecation warning for mssql legacy_schema_aliasing

Fixes: #4809
Change-Id: I9ce2a5dfb79d86624c187ee28b5911fd14328ce2

4 years agoUpdates for MariaDB sequences
Federico Caselli [Fri, 21 Aug 2020 22:30:44 +0000 (00:30 +0200)] 
Updates for MariaDB sequences

MariaDB should not run a Sequence if it has optional=True.
Additionally, rework the rules in crud.py to accommodate the
new combination MariaDB brings us, which is a dialect
that supports both cursor.lastrowid, explicit sequences,
*and* no support for returning.

Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Fixes: #5528
Change-Id: I9a8ea69a34983affa95dfd22186e2908fdf0d58c

4 years agoMerge "Add support for identity columns"
mike bayer [Fri, 21 Aug 2020 21:39:40 +0000 (21:39 +0000)] 
Merge "Add support for identity columns"

4 years agoMerge "Raise UnmappedInstanceError if the attribute of a database object is an unmapp...
mike bayer [Thu, 20 Aug 2020 19:24:12 +0000 (19:24 +0000)] 
Merge "Raise UnmappedInstanceError if the attribute of a database object is an unmapped object."

4 years agoMerge "normalize execute style for events, 2.0"
mike bayer [Thu, 20 Aug 2020 15:22:08 +0000 (15:22 +0000)] 
Merge "normalize execute style for events, 2.0"

4 years agonormalize execute style for events, 2.0
Mike Bayer [Wed, 19 Aug 2020 16:08:26 +0000 (12:08 -0400)] 
normalize execute style for events, 2.0

The _execute_20 and exec_driver_sql methods should wrap
up the parameters so that they represent the single list / single
dictionary style of invocation into the legacy methods.  then
the before_ after_ execute event handlers should be receiving
the parameter dictionary as a single dictionary.   this requires
that we break out distill_params to work differently if event
handlers are present.

additionally, add deprecation warnings for old argument passing
styles.

Change-Id: I97cb4d06adfcc6b889f10d01cc7775925cffb116

4 years agoMerge "Implement DDL visitor for PG ENUM with schema translate support"
mike bayer [Wed, 19 Aug 2020 17:38:07 +0000 (17:38 +0000)] 
Merge "Implement DDL visitor for PG ENUM with schema translate support"

4 years agoMerge "Add JSON support for mssql"
mike bayer [Wed, 19 Aug 2020 17:25:06 +0000 (17:25 +0000)] 
Merge "Add JSON support for mssql"

4 years agoAdd JSON support for mssql
Gord Thompson [Sat, 1 Aug 2020 21:56:12 +0000 (15:56 -0600)] 
Add JSON support for mssql

Added support for the :class:`_types.JSON` datatype on the SQL Server
dialect using the :class:`_mssql.JSON` implementation, which implements SQL
Server's JSON functionality against the ``NVARCHAR(max)`` datatype as per
SQL Server documentation. Implementation courtesy Gord Thompson.

Fixes: #4384
Change-Id: I28af79a4d8fafaa68ea032228609bba727784f18

4 years agoImplement DDL visitor for PG ENUM with schema translate support
Mike Bayer [Wed, 19 Aug 2020 02:53:09 +0000 (22:53 -0400)] 
Implement DDL visitor for PG ENUM with schema translate support

Fixed issue where the :class:`_postgresql.ENUM` type would not consult the
schema translate map when emitting a CREATE TYPE or DROP TYPE during the
test to see if the type exists or not.  Additionally, repaired an issue
where if the same enum were encountered multiple times in a single DDL
sequence, the "check" query would run repeatedly rather than relying upon a
cached value.

Fixes: #5520
Change-Id: I79f46e29ac0168e873ff178c242f8d78f6679aeb

4 years agoAdd support for identity columns
Federico Caselli [Sat, 30 May 2020 12:45:00 +0000 (14:45 +0200)] 
Add support for identity columns

Added the :class:`_schema.Identity` construct that can be used to
configure identity columns rendered with GENERATED { ALWAYS |
BY DEFAULT } AS IDENTITY. Currently the supported backends are
PostgreSQL >= 10, Oracle >= 12 and MSSQL (with different syntax
and a subset of functionalities).

Fixes: #5362
Fixes: #5324
Fixes: #5360
Change-Id: Iecea6f3ceb36821e8b96f0b61049b580507a1875

4 years agoSupport data types for CREATE SEQUENCE in PostgreSQL
Federico Caselli [Fri, 7 Aug 2020 20:38:24 +0000 (22:38 +0200)] 
Support data types for CREATE SEQUENCE in PostgreSQL

Allow specifying the data type when creating a :class:`.Sequence` in
PostgreSQL by using the parameter :paramref:`.Sequence.data_type`.

Fixes: #5498
Change-Id: I2b4a80aa89b1503c56748dc3ecd2cf145faddd8b

4 years agoMerge "Deliver straight BinaryExpr w/ no negate for any() / all()"
mike bayer [Tue, 18 Aug 2020 19:07:19 +0000 (19:07 +0000)] 
Merge "Deliver straight BinaryExpr w/ no negate for any() / all()"

4 years agoDeliver straight BinaryExpr w/ no negate for any() / all()
Mike Bayer [Tue, 18 Aug 2020 18:17:06 +0000 (14:17 -0400)] 
Deliver straight BinaryExpr w/ no negate for any() / all()

Adjusted the :meth:`_types.ARRAY.Comparator.any` and
:meth:`_types.ARRAY.Comparator.all` methods to implement a straight "NOT"
operation for negation, rather than negating the comparison operator.

Fixes: #5518
Change-Id: I87ee9278c321aafe51a679fcfcbb5fbb11307fda

4 years agoMerge "Update dialect for pg8000 version 1.16.0"
mike bayer [Tue, 18 Aug 2020 17:33:46 +0000 (17:33 +0000)] 
Merge "Update dialect for pg8000 version 1.16.0"

4 years agoUpdate dialect for pg8000 version 1.16.0
Tony Locke [Sun, 2 Aug 2020 19:19:26 +0000 (15:19 -0400)] 
Update dialect for pg8000 version 1.16.0

The pg8000 dialect has been revised and modernized for the most recent
version of the pg8000 driver for PostgreSQL.  Changes to the dialect
include:

* All data types are now sent as text rather than binary.

* Using adapters, custom types can be plugged in to pg8000.

* Previously, named prepared statements were used for all statements.
  Now unnamed prepared statements are used by default, and named
  prepared statements can be used explicitly by calling the
  Connection.prepare() method, which returns a PreparedStatement
  object.

Pull request courtesy Tony Locke.

Notes by Mike: to get this all working it was needed to break
up JSONIndexType into "str" and "int" subtypes; this will be
needed for any dialect that is dependent on setinputsizes().

also includes @caselit's idea to include query params
in the dbdriver parameter.

Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Closes: #5451
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5451
Pull-request-sha: 639751ca9c7544801b9ede02e6cbe15a16c59c82

Change-Id: I2869bc52c330916773a41d11d12c297aecc8fcd8

4 years agoClarify that session.close() is like reset
Mike Bayer [Tue, 18 Aug 2020 14:52:04 +0000 (10:52 -0400)] 
Clarify that session.close() is like reset

Fixes: #5517
Change-Id: I86809cf84de3ec19a279ae13f4e5e71336d8b359

4 years agoMerge "Fix wheel check in linux workflow and improve it"
mike bayer [Mon, 17 Aug 2020 22:08:22 +0000 (22:08 +0000)] 
Merge "Fix wheel check in linux workflow and improve it"

4 years agoFix wheel check in linux workflow and improve it
Federico Caselli [Mon, 17 Aug 2020 21:29:50 +0000 (23:29 +0200)] 
Fix wheel check in linux workflow and improve it

Change-Id: I3b208674649e41bca0285d00aa11cc5975eb971a

4 years agocherry-pick changelog update for 1.3.20
Mike Bayer [Mon, 17 Aug 2020 20:12:12 +0000 (16:12 -0400)] 
cherry-pick changelog update for 1.3.20

4 years agocherry-pick changelog from 1.3.19
Mike Bayer [Mon, 17 Aug 2020 20:12:11 +0000 (16:12 -0400)] 
cherry-pick changelog from 1.3.19

4 years agoMerge "Create a real type for Tuple() and handle appropriately in compiler"
mike bayer [Mon, 17 Aug 2020 19:56:30 +0000 (19:56 +0000)] 
Merge "Create a real type for Tuple() and handle appropriately in compiler"

4 years agoMerge "Make discriminator column used by ConcreteBase configurable"
mike bayer [Mon, 17 Aug 2020 19:55:38 +0000 (19:55 +0000)] 
Merge "Make discriminator column used by ConcreteBase configurable"

4 years agoMerge "Bump minimum MySQL version to 5.0.2; use all-numeric server version"
mike bayer [Mon, 17 Aug 2020 15:53:20 +0000 (15:53 +0000)] 
Merge "Bump minimum MySQL version to 5.0.2; use all-numeric server version"

4 years agoMake discriminator column used by ConcreteBase configurable
Jesse Bakker [Mon, 17 Aug 2020 14:35:35 +0000 (10:35 -0400)] 
Make discriminator column used by ConcreteBase configurable

The name of the virtual column used when using the
:class:`_declarative.AbstractConcreteBase` and
:class:`_declarative.ConcreteBase` classes can now be customized, to allow
for models that have a column that is actually named ``type``.  Pull
request courtesy Jesse-Bakker.

Fixes: #5513
Closes: #5514
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5514
Pull-request-sha: 5e7429f3531e2e22fffe996c9760905578d16ef9

Change-Id: I733737844d4f4e1f52dd2475a66c7044ff7292f5

4 years agoCreate a real type for Tuple() and handle appropriately in compiler
Mike Bayer [Sat, 15 Aug 2020 19:08:09 +0000 (15:08 -0400)] 
Create a real type for Tuple() and handle appropriately in compiler

Improved the :func:`_sql.tuple_` construct such that it behaves predictably
when used in a columns-clause context.  The SQL tuple is not supported as a
"SELECT" columns clause element on most backends; on those that do
(PostgreSQL, not surprisingly), the Python DBAPI does not have a "nested
type" concept so there are still challenges in fetching rows for such an
object. Use of :func:`_sql.tuple_` in a :func:`_sql.select` or
:class:`_orm.Query` will now raise a :class:`_exc.CompileError` at the
point at which the :func:`_sql.tuple_` object is seen as presenting itself
for fetching rows (i.e., if the tuple is in the columns clause of a
subquery, no error is raised).  For ORM use,the :class:`_orm.Bundle` object
is an explicit directive that a series of columns should be returned as a
sub-tuple per row and is suggested by the error message. Additionally ,the
tuple will now render with parenthesis in all contexts. Previously, the
parenthesization would not render in a columns context leading to
non-defined behavior.

As part of this change, Tuple receives a dedicated datatype
which appears to allow us the very desirable change of removing
the bindparam._expanding_in_types attribute as well as
ClauseList._tuple_values (which might already have not been
needed due to #4645).

Fixes: #5127
Change-Id: Iecafa0e0aac2f1f37ec8d0e1631d562611c90200

4 years agoerror message for Lookup
RamonWill [Wed, 12 Aug 2020 18:50:20 +0000 (14:50 -0400)] 
error message for Lookup

Thr proposed change will provide the user with the target Enum Class name as well as up to four possible enum values when a LookupError is raised in the Enum Class.

A user requested that the enum name and possible values are included to the LookupError message to make debugging easier. The criteria included using ellipses for Enums containing more than four values and using ellipses for enum values that were greater than a certain number of characters (for this resolution the limit is 11 characters).

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: #4733
Closes: #5490
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5490
Pull-request-sha: 55e76f2ae796b59b7de157cfaae5235dffa359cb

Change-Id: I4541f9efed1c05401587a413e9e748d46938bcd1

4 years agoMerge "Test execution_options on Query object before compilation"
mike bayer [Mon, 17 Aug 2020 14:21:15 +0000 (14:21 +0000)] 
Merge "Test execution_options on Query object before compilation"

4 years agoBump minimum MySQL version to 5.0.2; use all-numeric server version
Mike Bayer [Fri, 14 Aug 2020 04:58:56 +0000 (00:58 -0400)] 
Bump minimum MySQL version to 5.0.2; use all-numeric server version

MySQL dialect's server_version_info tuple is now all numeric.  String
tokens like "MariaDB" are no longer present so that numeric comparison
works in all cases.  The .is_mariadb flag on the dialect should be
consulted for whether or not mariadb was detected.   Additionally removed
structures meant to support extremely old MySQL versions 3.x and 4.x;
the minimum MySQL version supported is now version 5.0.2.

In addition, as the "MariaDB" name goes away from server version,
expand upon the change in I330815ebe572b6a9818377da56621397335fa702
to support the name "mariadb" throughout the dialect and test suite
when mariadb-only mode is used.    This changes the "name" field
on the MariaDB dialect to "mariadb", which then implies a change
throughout the testing requirements system as well as all the
dialect-specific DDL argument names such as "mysql_engine" is
now specified as "mariadb_engine", etc.   Make use of the
recent additions to test suite URL provisioning so that we can
force MariaDB databases to have a "mariadb-only" dialect which
allows us to test this name change fully.

Update documentation to refer to MySQL / MariaDB explicitly
as well as indicating the "mariadb_" prefix used for options.

It seems likely that MySQL and MariaDB version numbers are going to
start colliding at some point so having the "mariadb" name
be available as a totally separate dialect name should give us
some options in this regard.

Currently also includes a date related fix to a test for
the postgresql dialect that was implicitly assuming a
non-UTC timezone

Fixes: #4189
Change-Id: I00e76d00f62971e1f067bd61915fa6cc1cf64e5e

4 years agoMerge "Provision on different drivers dynamically"
mike bayer [Fri, 14 Aug 2020 22:20:44 +0000 (22:20 +0000)] 
Merge "Provision on different drivers dynamically"

4 years agoProvision on different drivers dynamically
Mike Bayer [Fri, 14 Aug 2020 16:07:14 +0000 (12:07 -0400)] 
Provision on different drivers dynamically

We want TOX_POSTGRESQL and similar to be the fixed variable
that is configured from CI environment.   These variables should refer
to database servers but individual drivers like asyncpg mysqlconnector
etc. should come from local tox.ini.  add a new system to generate
per-driver URLs from a simple list of hostname-based URLs delivered
from CI environment.

Change-Id: I4267b4a70742765388c7e7c4432c1da9d9adece2

4 years agoupdate for pytest-xdist terminology
Mike Bayer [Fri, 14 Aug 2020 16:22:17 +0000 (12:22 -0400)] 
update for pytest-xdist terminology

With version 2.0.0 they removed the old terminology, which
I had no idea had been changed in any case for several years.

pushing this out for all branches

Change-Id: I51e4f577aeb9ef8205348b50489549f77072a613

4 years agoDon't import asyncpg prior to python 3.6
Mike Bayer [Fri, 14 Aug 2020 05:02:22 +0000 (01:02 -0400)] 
Don't import asyncpg prior to python 3.6

Continuing on 788ba204a43b37d28cc690138b83e6782f8a46da
make sure asyncpg doesn't get imported if version < 3.6.

Change-Id: Ic070a0c9d3656f7da7ce2eb85033968fc88a64b9

4 years agoDont run py3k-only test files on Python 3.5
Mike Bayer [Fri, 14 Aug 2020 03:05:57 +0000 (23:05 -0400)] 
Dont run py3k-only test files on Python 3.5

these are failing on the github runners because 3.5 doesnt
have the async keywords.

Change-Id: I9c58d38f8d7595313b7648b9840b334da8238bd0

4 years agoUse TOX_POSTGRESQL_MASTER for master
Mike Bayer [Fri, 14 Aug 2020 02:44:33 +0000 (22:44 -0400)] 
Use TOX_POSTGRESQL_MASTER for master

since 1.3 doesn't have updated pg8000 support nor
asyncpg support it needs to stay on the previous
TOX_POSTGRESQL variable, so make a new one that will
have the newer drivers in it.

Change-Id: I19739f8da1231db975a046f12af5eefc9636cd4a

4 years agoDoc fix; use normal TOX_POSTGRESQL env now
Mike Bayer [Fri, 14 Aug 2020 02:38:17 +0000 (22:38 -0400)] 
Doc fix; use normal TOX_POSTGRESQL env now

Change-Id: Ie47a9e9377858641f2f8e038133be27dc9aacd64

4 years agoMerge "Implement rudimentary asyncio support w/ asyncpg"
mike bayer [Fri, 14 Aug 2020 00:08:29 +0000 (00:08 +0000)] 
Merge "Implement rudimentary asyncio support w/ asyncpg"

4 years agoImplement rudimentary asyncio support w/ asyncpg
Mike Bayer [Sat, 4 Jul 2020 16:21:36 +0000 (12:21 -0400)] 
Implement rudimentary asyncio support w/ asyncpg

Using the approach introduced at
https://gist.github.com/zzzeek/6287e28054d3baddc07fa21a7227904e

We can now create asyncio endpoints that are then handled
in "implicit IO" form within the majority of the Core internals.
Then coroutines are re-exposed at the point at which we call
into asyncpg methods.

Patch includes:

* asyncpg dialect

* asyncio package

* engine, result, ORM session classes

* new test fixtures, tests

* some work with pep-484 and a short plugin for the
  pyannotate package, which seems to have so-so results

Change-Id: Idbcc0eff72c4cad572914acdd6f40ddb1aef1a7d
Fixes: #3414
4 years agoMerge "Further fixes for ticket 5470"
mike bayer [Thu, 13 Aug 2020 21:43:09 +0000 (21:43 +0000)] 
Merge "Further fixes for ticket 5470"

4 years agoRaise UnmappedInstanceError if the attribute of a database object is an unmapped...
RamonWill [Thu, 13 Aug 2020 21:23:16 +0000 (17:23 -0400)] 
Raise UnmappedInstanceError if the attribute of a database object is an unmapped object.

The proposed change will raise an UnmappedInstanceError instead of an attribute error if an instance an Instrumented Attribute is unmapped.

### Description
If a user tries to access an attribute of a database object that is unmapped then an error is raised. The reason for this is because the __get__  descriptor  uses instance_state(instance) which uses the operator.attrgetter method to see if the object in question has the attribute "_sa_instance_state" that mapped objects have.  If it doesn't contain this attribute it means that the object is unmapped.

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: #3858
Closes: #5478
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5478
Pull-request-sha: 853051c9225446b69f52b13ade78709ad2617f6d

Change-Id: I5989c81227e55e628babdd11406d1e8ec0e8d93a

4 years agoTest execution_options on Query object before compilation
RamonWill [Thu, 13 Aug 2020 21:04:13 +0000 (17:04 -0400)] 
Test execution_options on Query object before compilation

 A test that checks if the execution options are being set on the Query object before compilation

### Description
Since Issue #4670 has been open there have changes to the execution mechanics that resolved it. I have just created a test case that will enable the issue to be closed.

This pull request is:

- [ X] A documentation / typographical 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.

**Have a nice day!**
Fixes: #4670
Closes: #5446
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5446
Pull-request-sha: c98639ec94279760caacf9f288b180198511dfd3

Change-Id: I686dc7a4735000748c94bff5ba6dc7bd57b2d1c4

4 years agoFurther fixes for ticket 5470
Mike Bayer [Thu, 13 Aug 2020 14:43:53 +0000 (10:43 -0400)] 
Further fixes for ticket 5470

The fix for #5470 didn't actually take into account that
the "distinct" logic in query was also doubling up the criteria.
Added many more tests.   the 1.3 version here will be different
than 1.4 as the regression is not quite the same.

Fixes: #5470
Change-Id: I16a23917cab175761de9c867d9d9ac55031d9b97

4 years agoUse importlib_metadata; add namespace for mariadb
Mike Bayer [Wed, 12 Aug 2020 22:46:25 +0000 (18:46 -0400)] 
Use importlib_metadata; add namespace for mariadb

The ``importlib_metadata`` library is used to scan for setuptools
entrypoints rather than pkg_resources.   as importlib_metadata is a small
library that is included as of Python 3.8, the compatibility library is
installed as a dependency for Python versions older than 3.8.

Unfortunately setuptools "attr:" is broken because it tries to import
the module; seems like this is fixed as part of
https://github.com/pypa/setuptools/pull/1753 however this is too recent
to rely upon for now.

Added a new dialect token "mariadb" that may be used in place of "mysql" in
the :func:`_sa.create_engine` URL.  This will deliver a MariaDB dialect
subclass of the MySQLDialect in use that forces the "is_mariadb" flag to
True.  The dialect will raise an error if a server version string that does
not indicate MariaDB in use is received.   This is useful for
MariaDB-specific testing scenarios as well as to support applications that
are hardcoding to MariaDB-only concepts.  As MariaDB and MySQL featuresets
and usage patterns continue to diverge, this pattern may become more
prominent.

Fixes: #5400
Fixes: #5496
Change-Id: I330815ebe572b6a9818377da56621397335fa702

4 years agoSweep through UPDATE ordered_values a second time
Mike Bayer [Thu, 13 Aug 2020 00:14:15 +0000 (20:14 -0400)] 
Sweep through UPDATE ordered_values a second time

The fix in 180ae7c1a53385f72b0047496ac001ec5099cc3e
didn't do much as the code was not preserving parameter
order at all, in fact.    Reworked stmt_parameters to be
delivered in the correct order up front and preserve
throughout crud.py which was not being done at all
before.

Fixes: #5510
Change-Id: I0795c71df73005a25d1bbf216732d41b41e11a5f

4 years agoMerge "Break scalars() and mappings() into separate objects"
mike bayer [Wed, 12 Aug 2020 16:40:53 +0000 (16:40 +0000)] 
Merge "Break scalars() and mappings() into separate objects"

4 years agoBreak scalars() and mappings() into separate objects
Mike Bayer [Mon, 10 Aug 2020 22:40:49 +0000 (18:40 -0400)] 
Break scalars() and mappings() into separate objects

The issue of Result.fetchXXX()  methods returning Row
objects unless filtering is applied will not provide a
clear enough API story when type annotations are applied,
so break out scalars/mappings into separate wrapper objects.
this makes some things more intuitive and other things a little
more bumpy.   however the return type story is now clearer.

Fixes: #5503
Change-Id: I629a061823179680dc0723559183859a67ea4db1

4 years agoMerge "Fix mysql CREATE TABLE / COLLATE issue"
mike bayer [Wed, 12 Aug 2020 15:04:21 +0000 (15:04 +0000)] 
Merge "Fix mysql CREATE TABLE / COLLATE issue"

4 years agoCorrect for update.ordered_values() and use in new test
Mike Bayer [Tue, 11 Aug 2020 21:46:11 +0000 (17:46 -0400)] 
Correct for update.ordered_values() and use in new test

The test for the parameter fix in c0685e5f41 was not working
deterministically on Python 2, so use ordered_values(), however
a second issue in ordered_values() was assuming each element was a
column, so also test for array-assignment expressions with
ordered_values.

Change-Id: I944c72a52700ffb4ab5ae1a83ae21f1efc84b505

4 years agoupdate deterministic sort ordering doc
Mike Bayer [Tue, 11 Aug 2020 16:27:10 +0000 (12:27 -0400)] 
update deterministic sort ordering doc

reword the sorting in terms of the actual behavior,
put correct changed version

References: #5494
Change-Id: I725338526afe28454910d029c153e4476f8c686f

4 years agoFix mysql CREATE TABLE / COLLATE issue
Gord Thompson [Thu, 6 Aug 2020 23:19:52 +0000 (17:19 -0600)] 
Fix mysql CREATE TABLE / COLLATE issue

Fixes: #5411
Change-Id: Ib0c53f5ed3f9d3ff0586580c9a9cce73b4b870f4

4 years agoFix typos 5502/head
Karthikeyan Singaravelan [Sun, 9 Aug 2020 10:02:57 +0000 (10:02 +0000)] 
Fix typos

4 years agorender INSERT/UPDATE column expressions up front; pass state
Mike Bayer [Sat, 8 Aug 2020 17:03:17 +0000 (13:03 -0400)] 
render INSERT/UPDATE column expressions up front; pass state

Fixes related to rendering of complex UPDATE DML
which was not correctly preserving positional parameter
order in conjunction with DML features that are only known
to work on the PostgreSQL database.    Both pg8000
and asyncpg use positional parameters which is why these
issues are suddenly apparent.

crud.py now takes on the task of rendering the column
expressions for SET or VALUES so that for the very unusual
case that the column expression is a compound expression
that includes a bound parameter (namely an array index),
the bound parameter order is preserved.

Additionally, crud.py passes through the positional_names
keyword argument into bindparam_string() which is necessary
when CTEs are being rendered, as PG supports complex
CTE / INSERT / UPDATE scenarios.

Change-Id: I7f03920500e19b721636b84594de78a5bfdcbc82

4 years agoDon't link on_connect to first_connect event handler
Mike Bayer [Fri, 7 Aug 2020 18:51:33 +0000 (14:51 -0400)] 
Don't link on_connect to first_connect event handler

Adjusted the dialect initialization process such that the
:meth:`_engine.Dialect.on_connect` is not called a second time on the first
connection.   The hook is called first, then the
:meth:`_engine.Dialect.initialize` is called if that connection is the
first for that dialect, then no more events are called.   This eliminates
the two calls to the "on_connect" function which can produce very difficult
debugging situations.

Fixes: #5497
Change-Id: Icefc2e884e30ee7b4ac84b99dc54bf992a6085e3

4 years agoMerge "Add complete platform data to profiling data"
mike bayer [Fri, 7 Aug 2020 17:27:15 +0000 (17:27 +0000)] 
Merge "Add complete platform data to profiling data"

4 years agoMerge "Pass schema_translate_map from DDLCompiler to SQLCompiler"
mike bayer [Fri, 7 Aug 2020 17:22:14 +0000 (17:22 +0000)] 
Merge "Pass schema_translate_map from DDLCompiler to SQLCompiler"

4 years agoInclude bulk update/delete in RoutingSession example
Mike Bayer [Fri, 7 Aug 2020 16:32:50 +0000 (12:32 -0400)] 
Include bulk update/delete in RoutingSession example

Fixes: #5407
Change-Id: Ia0965dbc88d744cded5c23021898388f2cf95f8d

4 years agoAdd complete platform data to profiling data
Federico Caselli [Mon, 27 Jul 2020 19:57:32 +0000 (21:57 +0200)] 
Add complete platform data to profiling data

Initially to distinsuish between arm and x86_64
architecture, expand out the profile key to include
machine, system, python impl in all cases.

Ref: #5436
Change-Id: I7e48f0462ba7d9c680b2dac45ce7b0cf709b9b22

4 years agoPass schema_translate_map from DDLCompiler to SQLCompiler
Mike Bayer [Fri, 7 Aug 2020 15:24:29 +0000 (11:24 -0400)] 
Pass schema_translate_map from DDLCompiler to SQLCompiler

Fixed issue where the
:paramref:`_engine.Connection.execution_options.schema_translate_map`
feature would not take effect when the :meth:`_schema.Sequence.next_value`
function function for a :class:`_schema.Sequence` were used in the
:paramref:`_schema.Column.server_default` parameter and the create table
DDL were emitted.

Fixes: #5500
Change-Id: I74a9fa13d22749d06c8202669f9ea220d9d984d9

4 years agobase all_orm_descriptors ordering on cls.__dict__ + cls.__mro__
Mike Bayer [Thu, 6 Aug 2020 19:53:17 +0000 (15:53 -0400)] 
base all_orm_descriptors ordering on cls.__dict__ + cls.__mro__

Adjusted the workings of the :meth:`_orm.Mapper.all_orm_descriptors`
accessor to represent the attributes in the order that they are located in
a deterministic way, assuming the use of Python 3.6 or higher which
maintains the sorting order of class attributes based on how they were
declared.   This sorting is not guaranteed to match the declared order of
attributes in all cases however; see the method documentation for the exact
scheme.

Fixes: #5494
Change-Id: I6ee8d4ace3eb8b3f7c9c0f2a3d7e27b5f62abfd3

4 years agorevise asyncio verbiage a bit
Mike Bayer [Thu, 6 Aug 2020 14:16:38 +0000 (10:16 -0400)] 
revise asyncio verbiage a bit

Change-Id: I8bdf7c3271b8284ab82e01558024f933e1ee7b49

4 years agoMerge "Documentation updates for 1.4"
mike bayer [Thu, 6 Aug 2020 03:33:37 +0000 (03:33 +0000)] 
Merge "Documentation updates for 1.4"

4 years agoMerge "Implement relationship AND criteria; global loader criteria"
mike bayer [Thu, 6 Aug 2020 03:33:13 +0000 (03:33 +0000)] 
Merge "Implement relationship AND criteria; global loader criteria"

4 years agoDocumentation updates for 1.4
Mike Bayer [Sun, 28 Jun 2020 15:59:34 +0000 (11:59 -0400)] 
Documentation updates for 1.4

* major additions to 1.4 migration doc; removed additional
  verbosity regarding caching methodology and reorganized the
  doc to present itself more as a "what's changed" guide

* as we now have a path for asyncio, update that doc so that
  we aren't spreading obsolete information

* updates to the 2.0 migration guide with latest info, however
  this is still an architecture doc and not a migration guide
  yet, will need further rework.

* start really talking about 1.x vs. 2.0 style everywhere.  Querying
  is most of the docs so this is going to be a prominent
  theme, start getting it to fit in

* Add introductory documentation for ORM example sections as these
  are too sparse

* new documentation for do_orm_execute(), many separate sections,
  adding deprecation notes to before_compile() and similar

* new example suites to illustrate do_orm_execute(),
  with_loader_criteria()

* modernized horizontal sharding examples and added a separate
  example to distinguish between multiple databases and single
  database w/ multiple tables use case

* introducing DEEP ALCHEMY, will use zzzeeksphinx 1.1.6

* no name for the alchemist yet however the dragon's name
  is Flambé

Change-Id: Id6b5c03b1ce9ddb7b280f66792212a0ef0a1c541

4 years agoImplement relationship AND criteria; global loader criteria
Mike Bayer [Thu, 6 Aug 2020 01:47:43 +0000 (21:47 -0400)] 
Implement relationship AND criteria; global loader criteria

Added the ability to add arbitrary criteria to the ON clause generated
by a relationship attribute in a query, which applies to methods such
as :meth:`_query.Query.join` as well as loader options like
:func:`_orm.joinedload`.   Additionally, a "global" version of the option
allows limiting criteria to be applied to particular entities in
a query globally.

Documentation is minimal at this point, new examples will
be coming in a subsequent commit.

Some adjustments to execution options in how they are represented
in the ORMExecuteState as well as well as a few ORM tests that
forgot to get merged in a preceding commit.

Fixes: #4472
Change-Id: I2b8fc57092dedf35ebd16f6343ad0f0d7d332beb

4 years agoMerge "Fixes for MySQL 8"
mike bayer [Thu, 6 Aug 2020 02:06:45 +0000 (02:06 +0000)] 
Merge "Fixes for MySQL 8"

4 years agoFixes for MySQL 8
Mike Bayer [Thu, 6 Aug 2020 00:32:02 +0000 (20:32 -0400)] 
Fixes for MySQL 8

MySQL 8.0.19 has some changes to how it reports on display widths
for int types (seems like it omits it in some cases), and also
no longer cares about the length for YEAR.   Another adjustment
to the ordering of constraints reported in one case also.
At least one CI machine is at 8.0.21 now.

Change-Id: Ie2101bed3ad75dcbb62cd05abe95ef14ad895cf5

4 years agoConvert lazy loader, selectinload, load_on_ident to lambda statements
Mike Bayer [Wed, 5 Aug 2020 21:58:48 +0000 (17:58 -0400)] 
Convert lazy loader, selectinload, load_on_ident to lambda statements

Building on newly robust lambdas in
I29a513c98917b1d503abfdd61e6b6e8800851aa8,
convert key loading off of the "baked" system so that baked
is no longer used by the ORM.

Change-Id: I3abfb45dd6e50f84f29d39434caa0b550ce27864

4 years agoRobustness for lambdas, lambda statements
Mike Bayer [Wed, 5 Aug 2020 20:42:26 +0000 (16:42 -0400)] 
Robustness for lambdas, lambda statements

in order to accommodate relationship loaders
with lambda caching, a lot more is needed.  This is
a full refactor of the lambda system such that it
now has two levels of caching; the first level caches what
can be known from the __code__ element, then the next level
of caching is against the lambda itself and the contents
of __closure__.  This allows for the elements inside
the lambdas, like columns and entities, to change and
then be part of the cache key.  Lazy/selectinloads' use of
baked queries had to add distinct cache key elements,
which was attempted here but overall things needed to be
more robust than that.

This commit is broken out from the very long and sprawling
commit at Id6b5c03b1ce9ddb7b280f66792212a0ef0a1c541 .

Change-Id: I29a513c98917b1d503abfdd61e6b6e8800851aa8

4 years agoAdd MariaDB 1927 to is_disconnect codes
Mike Bayer [Wed, 5 Aug 2020 14:31:21 +0000 (10:31 -0400)] 
Add MariaDB 1927 to is_disconnect codes

Added MariaDB code 1927 to the list of "disconnect" codes, as recent
MariaDB versions apparently use this code when the database server was
stopped.

Fixes: #5493
Change-Id: I63f1d692f36cb0411ead278556e3f8c64ab72ea4

4 years agoMerge "Establish future behavior for Session cascade backrefs, bind"
mike bayer [Wed, 5 Aug 2020 04:49:57 +0000 (04:49 +0000)] 
Merge "Establish future behavior for Session cascade backrefs, bind"

4 years agofix formatting
Mike Bayer [Tue, 4 Aug 2020 14:40:46 +0000 (10:40 -0400)] 
fix formatting

Change-Id: I8315cfef6e5c4b87d64fc770998a1229cc690870

4 years agoAdd note that fast_executemany uses memory
Mike Bayer [Tue, 4 Aug 2020 14:13:51 +0000 (10:13 -0400)] 
Add note that fast_executemany uses memory

Ideally this would be a per-execution option, or Pyodbc
could perhaps run the data in chunks.

Fixes: #5334
Change-Id: If4a11b312346b8e4c2b8cd38840b3a2ba56dec3b

4 years agoMerge "Genericize str() for types"
mike bayer [Sun, 2 Aug 2020 03:18:12 +0000 (03:18 +0000)] 
Merge "Genericize str() for types"

4 years agoMerge "Unpin pydocstyle, minimum for flake8-docstrings 1.3.1"
mike bayer [Sun, 2 Aug 2020 00:17:02 +0000 (00:17 +0000)] 
Merge "Unpin pydocstyle, minimum for flake8-docstrings 1.3.1"

4 years agoMerge "Improve github action workflows"
mike bayer [Sun, 2 Aug 2020 00:11:33 +0000 (00:11 +0000)] 
Merge "Improve github action workflows"

4 years agoGenericize str() for types
Mike Bayer [Sat, 1 Aug 2020 17:57:04 +0000 (13:57 -0400)] 
Genericize str() for types

Remove lookup logic that attempts to locate a dialect for a type,
just use StrSQLTypeCompiler.

Cleaned up the internal ``str()`` for datatypes so that all types produce a
string representation without any dialect present, including that it works
for third-party dialect types without that dialect being present.  The
string representation defaults to being the UPPERCASE name of that type
with nothing else.

Fixes: #4262
Change-Id: I02149e8a1ba1e7336149e962939b07ae0df83c6b

4 years agoEstablish future behavior for Session cascade backrefs, bind
Mike Bayer [Sat, 1 Aug 2020 19:05:53 +0000 (15:05 -0400)] 
Establish future behavior for Session cascade backrefs, bind

The behavior of the :paramref:`_orm.relationship.cascade_backrefs` flag
will be reversed in 2.0 and set to ``False`` unconditionally, such that
backrefs don't cascade save-update operations from a forwards-assignment to
a backwards assignment.   A 2.0 deprecation warning is emitted when the
parameter is left at its default of ``True`` at the point at which such a
cascade operation actually takes place.   The new behavior can be
established as always by setting the flag to ``False`` on a specific
:func:`_orm.relationship`, or more generally can be set up across the board
by setting the the :paramref:`_orm.Session.future` flag to True.

Additionally in the interests of expediency, this commit will also
move Session away from making use of bound metadata if the future=True
flag is set.   An application that sets future=True should ideally
have to change as little else as possible for full 2.0 behavior.

Fixes: #5150
Change-Id: I490d1d61f09c62ffc2de983208aeed25dfe48aec

4 years agoClean python UUID imports
Vlastimil Zíma [Thu, 30 Jul 2020 07:56:39 +0000 (03:56 -0400)] 
Clean python UUID imports

Fixes: #5482
All supported python versions provide 'uuid' module.

Closes: #5483
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5483
Pull-request-sha: fc32498a8b639ff21d5898100592782826d2c6dd

Change-Id: I8b41b811da7576f724353425dad5d6f581641b4b

4 years agoMerge "Consider default FROM DUAL for MySQL"
mike bayer [Wed, 29 Jul 2020 18:44:28 +0000 (18:44 +0000)] 
Merge "Consider default FROM DUAL for MySQL"

4 years agoMerge "Imply `sync_backref` flag in a viewonly relationship"
mike bayer [Wed, 29 Jul 2020 18:42:49 +0000 (18:42 +0000)] 
Merge "Imply `sync_backref` flag in a viewonly relationship"

4 years agoUnpin pydocstyle, minimum for flake8-docstrings 1.3.1
Mike Bayer [Sat, 9 May 2020 14:55:19 +0000 (10:55 -0400)] 
Unpin pydocstyle, minimum for flake8-docstrings 1.3.1

Per https://gitlab.com/pycqa/flake8-docstrings/-/issues/36#note_199635329
flake8-docstrings has repaired the pydocstyle issue as of
1.3.1, so unpin pydocstyle.

Change-Id: I117a5df58ff6c5a4087c433ab817ad305df6a17b

4 years agoConsider default FROM DUAL for MySQL
Mike Bayer [Tue, 28 Jul 2020 20:46:53 +0000 (16:46 -0400)] 
Consider default FROM DUAL for MySQL

MySQL claims it doesn't require FROM DUAL for no
FROM clause even though the issue at #5481 locates
a case which requires one.  See if FROM DUAL the same
way as Oracle without attempting to guess is potentially
feasible.

Fixes: #5481
Change-Id: I2a28876c10a8ce2d121cd344dcdd837db321d4ab

4 years agoPassive deletes edits
Mike Bayer [Wed, 29 Jul 2020 17:14:49 +0000 (13:14 -0400)] 
Passive deletes edits

Change-Id: I863df033cae9bda4ce96d446a92984ae82797565

4 years agoRemove errant link
Mike Bayer [Wed, 29 Jul 2020 16:51:29 +0000 (12:51 -0400)] 
Remove errant link

The link to "passive_deletes" has moved in
9e1ee412b8650761af6df993e119906682604728 however the tag
stayed here and caused a self link.

Fixes: #5484
Change-Id: I3ac5970be30504367294b9e9a83eb5a2c579cc71

4 years agoMerge "Ensure is_comparison passed for PG RANGE op() methods"
mike bayer [Wed, 29 Jul 2020 16:49:23 +0000 (16:49 +0000)] 
Merge "Ensure is_comparison passed for PG RANGE op() methods"

4 years agoImprove github action workflows
Federico Caselli [Mon, 27 Jul 2020 20:31:29 +0000 (22:31 +0200)] 
Improve github action workflows

- in create wheel set minimum versions of setuptools and wheel to avoid
  failure in python 3.5 with metadata configured in setup.cfg
- update action versions
- test also cext in the pull requests

Change-Id: Iaa5e4e4000c7faa688b51f2f41428c7dd7cae9c3

4 years agoMerge "Remove comment code lines"
mike bayer [Sun, 26 Jul 2020 21:15:04 +0000 (21:15 +0000)] 
Merge "Remove comment code lines"

4 years agoEnsure is_comparison passed for PG RANGE op() methods
Jim Bosch [Sun, 26 Jul 2020 20:50:14 +0000 (16:50 -0400)] 
Ensure is_comparison passed for PG RANGE op() methods

Fixed issue where the return type for the various RANGE comparison
operators would itself be the same RANGE type rather than BOOLEAN, which
would cause an undesirable result in the case that a
:class:`.TypeDecorator` that defined result-processing behavior were in
use.  Pull request courtesy Jim Bosch.

Fixes: #5476
Closes: #5477
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5477
Pull-request-sha: 925b117e0c91cdd67d9ddbd9d65f5ca3e88af91f

Change-Id: I52ab4d4362d379c8253990f9d328a40990a64520

4 years agoImprove delete cascade and passive deletes sections
Mike Bayer [Sun, 26 Jul 2020 17:17:56 +0000 (13:17 -0400)] 
Improve delete cascade and passive deletes sections

Add cross linking from Core to ORM and also add new sections
and examples regarding many-to-many.    Move the section
out of "collections" and into the "cascades" chapter
where it's more likely to be found.

Change-Id: If29360e463e5745279bc5335bd12352d50ad8953

4 years agoUpdate docs with actual MariaDB JSON support 5474/head
DefteZ [Fri, 24 Jul 2020 23:45:41 +0000 (01:45 +0200)] 
Update docs with actual MariaDB JSON support

4 years agoRemove comment code lines
j00356287 [Sat, 25 Jul 2020 20:33:25 +0000 (16:33 -0400)] 
Remove comment code lines

PyODBCConnector.initialize just super from Connector, no need to redeclare, so I guess that's why they are commented before.

<!-- Provide a general summary of your proposed changes in the Title field above -->

### Description
<!-- Describe your changes in detail -->

Remove the useless comment code lines.

### 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 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.

**Have a nice day!**

Closes: #5475
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5475
Pull-request-sha: 23176a7f0316d74407492c2bb299c88924ed0868

Change-Id: If94bb6275c30015e3aaa1519471b7d9bcda18bf8

5 years agoMerge "Revise setinputsizes approach"
mike bayer [Thu, 23 Jul 2020 16:11:47 +0000 (16:11 +0000)] 
Merge "Revise setinputsizes approach"