Mike Bayer [Tue, 3 Oct 2017 00:50:56 +0000 (20:50 -0400)]
Improve check for overlapping FK targets on sibling classes
Fixed bug where ORM relationship would warn against conflicting sync
targets (e.g. two relationships would both write to the same column) for
sibling classes in an inheritance hierarchy, where the two relationships
would never actually conflict during writes.
Mike Bayer [Mon, 2 Oct 2017 15:50:05 +0000 (11:50 -0400)]
Support pg10
One test appears to use some awkward calling style
with the current_date function that isn't working in pg10
anymore, this looks like an extremely
old test that can be removed
Mike Bayer [Thu, 28 Sep 2017 20:47:28 +0000 (16:47 -0400)]
Take schema name into account when querying sqlite_master
Fixed bug where SQLite CHECK constraint reflection would fail
if the referenced table were in a remote schema, e.g. on SQLite a
remote database referred to by ATTACH.
Also add suite support for general CHECK constraint reflection.
Mike Bayer [Sat, 19 Aug 2017 22:39:08 +0000 (18:39 -0400)]
Support mariadb 10.2
Fixed issue where CURRENT_TIMESTAMP would not reflect correctly
in the MariaDB 10.2 series due to a syntax change, where the function
is now represented as ``current_timestamp()``.
Fixes: #4096
MariaDB 10.2 now supports CHECK constraints (warning: use version 10.2.9
or greater due to upstream issues noted in :ticket:`4097`). Reflection
now takes these CHECK constraints into account when they are present in
the ``SHOW CREATE TABLE`` output.
Mike Bayer [Thu, 28 Sep 2017 23:31:13 +0000 (19:31 -0400)]
Repair incorrectly merged mariadb logic
The changeset in c88d4d0 takes advantage of a
mariadb function that got randomly committed as part
of the SQL server fixup in 2efd89d02941ab4267d6e2842963, not
part of rel_1_1. The change here was not reviewed or tested
in gerrit and breaks the main branch.
Mike Bayer [Thu, 28 Sep 2017 16:31:54 +0000 (12:31 -0400)]
Warn for mariadb 10.2 < 9
There's a few CHECK constraint issues we managed
to get resolved as of MariaDB 10.2.8 then 10.2.9. They
are pretty severe so warn users for these particular mariadb
versions.
Mike Bayer [Wed, 27 Sep 2017 14:14:57 +0000 (10:14 -0400)]
Support method form of any_(), all_()
Fixed bug where the recently added :meth:`.ColumnOperators.any_`
and :meth:`.ColumnOperators.all_` methods didn't work when called
as methods, as opposed to using the standalone functions
:func:`~.expression.any_` and :func:`~.expression.all_`. Also
added documentation examples for these relatively unintuitive
SQL operators.
Mike Bayer [Wed, 27 Sep 2017 13:48:17 +0000 (09:48 -0400)]
Accomodate for multidimensional array in rewriting for COLLATE
Made further fixes to the :class:`.ARRAY` class in conjunction with
COLLATE, as the fix made in :ticket:`4006` failed to accommodate
for a multidimentional array.
Mike Bayer [Tue, 26 Sep 2017 00:00:20 +0000 (20:00 -0400)]
Document and test __table_cls__
A use case has been identified for __table_cls__, which was
added in 1.0 just for the purpose of test fixtures. Add this to
public API and ensure the target use case (conditional table generation)
stays supported.
Mike Bayer [Tue, 12 Sep 2017 16:57:40 +0000 (12:57 -0400)]
use the stack to get the insert statement in on conflict
Fixed bug in Postgresql :meth:`.postgresql.dml.Insert.on_conflict_do_update`
which would prevent the insert statement from being used as a CTE,
e.g. via :meth:`.Insert.cte`, within another statement.
Mike Bayer [Mon, 4 Sep 2017 16:11:19 +0000 (12:11 -0400)]
Guard against KeyError in session.merge after check for identity
Fixed bug in :meth:`.Session.merge` following along similar lines as that
of :ticket:`4030`, where an internal check for a target object in
the identity map could lead to an error if it were to be garbage collected
immediately before the merge routine actually retrieves the object.
Mike Bayer [Mon, 4 Sep 2017 20:21:14 +0000 (16:21 -0400)]
Check for non-mapped property in synonym
An :class:`.InvalidRequestError` is raised when a :func:`.synonym`
is used against an attribute that is not against a :class:`.MapperProperty`,
such as an association proxy. Previously, a recursion overflow would
occur trying to locate non-existent attributes.
Mike Bayer [Mon, 4 Sep 2017 19:53:34 +0000 (15:53 -0400)]
Always check that discarded state is the expected one
Fixed race condition in ORM identity map which would cause objects
to be inappropriately removed during a load operation, causing
duplicate object identities to occur, particularly under joined eager
loading which involves deduplication of objects. The issue is specific
to garbage collection of weak references and is observed only under the
Pypy interpreter.
Mike Bayer [Fri, 1 Sep 2017 16:31:38 +0000 (12:31 -0400)]
Add InternalError for mysqlclient disconnect
mysqlclient as of 1.3.11 changed the exception
class for a particular disconnect situation from
InterfaceError to InternalError; the disconnection
detection logic now accommodates this.
Mike Bayer [Thu, 31 Aug 2017 19:46:53 +0000 (15:46 -0400)]
Consider merge key with (None, ) as non-persistent
Fixed bug in :meth:`.Session.merge` where objects in a collection that had
the primary key attribute set to ``None`` for a key that is typically
autoincrementing would be considered to be a database-persisted key for
part of the internal deduplication process, causing only one object to
actually be inserted in the database.
Mike Bayer [Thu, 31 Aug 2017 20:22:52 +0000 (16:22 -0400)]
- pin on cx_Oracle 6.0.1 for the moment while we wait for
either https://github.com/oracle/python-cx_Oracle/issues/75
to be fixed or we can merge a workaround
Mike Bayer [Fri, 25 Aug 2017 13:41:18 +0000 (09:41 -0400)]
Allow for multiple FOLLOWING/PRECEDING in a window range
Altered the range specification for window functions to allow
for two of the same PRECEDING or FOLLOWING keywords in a range
by allowing for the left side of the range to be positive
and for the right to be negative, e.g. (1, 3) is
"1 FOLLOWING AND 3 FOLLOWING".
Mike Bayer [Wed, 23 Aug 2017 20:33:10 +0000 (16:33 -0400)]
Ensure col is not None when retrieving quick populators
Fixed bug where an :func:`.undefer_group` option would not be recognized
if it extended from a relationship that was loading using joined eager
loading.
In particular we need to double check the column both in terms of
the given "adapter" as well as without applying the "adapter"
when searching for the column in the result.
As we now avoid redoing the row processor step we also
improve on callcounts in joined eager loading.
Mike Bayer [Mon, 14 Aug 2017 13:32:08 +0000 (09:32 -0400)]
Restore original test names
The change in de1f8f8345ecd6af0ec1177703465e9471cfe862
modified how test classes are named, breaking logic that
extracts the class name for the profiling suite.
Add a new variable _sa_orig_cls_name if we've modified the
name so that the profiling logic doesn't need to guess
the original class name.
Mike Bayer [Fri, 4 Aug 2017 19:43:16 +0000 (15:43 -0400)]
Allow multiple versions of single backend
Improve screen output to illustrate which server version is
running for a particular database config, and additionally
allow full overriding for the backend-specific targets in
tox.ini via environment variables, so that CI can inject
multiple server urls for a particular database such as MySQL/MariaDB.
Mike Bayer [Fri, 18 Aug 2017 17:04:14 +0000 (13:04 -0400)]
First level repair for cx_Oracle 6.0 test regressions
Fixed more regressions caused by cx_Oracle 6.0; at the moment, the only
behavioral change for users is disconnect detection now detects for
cx_Oracle.DatabaseError in addition to cx_Oracle.InterfaceError, as
this behavior seems to have changed. Other issues regarding numeric
precision and uncloseable connections are pending with the upstream
cx_Oracle issue tracker.
Mike Bayer [Tue, 22 Aug 2017 17:12:43 +0000 (13:12 -0400)]
- allow a separate template database to be used for
PG CREATE DATABASE. as nobody will connect to it that would
solve the contention issue here
- backport --nomemory since tox.ini is using it
Mike Bayer [Fri, 28 Jul 2017 19:05:25 +0000 (15:05 -0400)]
Revert cx_Oracle WITH_UNICODE change under > 5.0
Fixed performance regression caused by the fix for :ticket:`3937` where
cx_Oracle as of version 5.3 dropped the ``.UNICODE`` symbol from its
namespace, which was interpreted as cx_Oracle's "WITH_UNICODE" mode being
turned on unconditionally, which invokes functions on the SQLAlchemy
side which convert all strings to unicode unconditionally and causing
a performance impact. In fact, per cx_Oracle's author the
"WITH_UNICODE" mode has been removed entirely as of 5.1, so the expensive unicode
conversion functions are no longer necessary and are disabled if
cx_Oracle 5.1 or greater is detected under Python 2. The warning against
"WITH_UNICODE" mode that was removed under :ticket:`3937` is also restored.
Mike Bayer [Mon, 17 Jul 2017 15:06:22 +0000 (11:06 -0400)]
Guard all indexed access in WeakInstanceDict
Added ``KeyError`` checks to all methods within
:class:`.WeakInstanceDict` where a check for ``key in dict`` is
followed by indexed access to that key, to guard against a race against
garbage collection that under load can remove the key from the dict
after the code assumes its present, leading to very infrequent
``KeyError`` raises.
Mike Bayer [Sat, 22 Jul 2017 20:32:01 +0000 (16:32 -0400)]
- move to file-per-changelog for unreleased change notes,
so that we no longer have to rely upon merges within
the changelog files. because gerrit doesn't allow us
to use custom merge engines unlike git, we have no ability
to merge multiple changes into the changelog files without
going through conflicts. new version of changelog
in git supports these new patterns.
Mike Bayer [Tue, 18 Jul 2017 15:41:12 +0000 (11:41 -0400)]
Check for column object in eval_none, not propkey
Fixed bug involving JSON NULL evaluation logic added in 1.1 as part
of :ticket:`3514` where the logic would not accommodate ORM
mapped attributes named differently from the :class:`.Column`
that was mapped.
Mike Bayer [Tue, 18 Jul 2017 18:58:26 +0000 (14:58 -0400)]
Check for non-entity when inspecting for subqueryload
Fixed issue where adding additional non-entity columns to
a query that includes an entity with subqueryload relationships
would fail, due to an inspection added in 1.1.11 as a result of
:ticket:`4011`.
Tom Sitter [Wed, 12 Jul 2017 15:54:25 +0000 (11:54 -0400)]
Replace Session class with session instance
The Session class was used instead of the session instance which resulted in an attribute error.
(cherry picked from commit 43f41fbfaa8f3030148c131628c5e9fe8fda9f66)
David Moore [Wed, 5 Jul 2017 19:06:49 +0000 (15:06 -0400)]
Add support for CACHE and ORDER to sequences
Added new keywords :paramref:`.Sequence.cache` and
:paramref:`.Sequence.order` to :class:`.Sequence`, to allow rendering
of the CACHE parameter understood by Oracle and PostgreSQL, and the
ORDER parameter understood by Oracle. Pull request
courtesy David Moore.
Change-Id: I082c3f8ef56ef89dbaad5da9d5695be5313b0614
Pull-request: https://bitbucket.org/zzzeek/sqlalchemy/pull-requests/96
(cherry picked from commit faa6609dac2ce6e55e0f690df3ba88c13133ec5c)
Mike Bayer [Fri, 16 Jun 2017 17:30:25 +0000 (13:30 -0400)]
Handle SHOW VARIABLES returning no row
MySQL 5.7 has introduced permission limiting for the "SHOW VARIABLES"
command; the MySQL dialect will now handle when SHOW returns no
row, in particular for the initial fetch of SQL_MODE, and will
emit a warning that user permissions should be modified to allow the
row to be present.
Mike Bayer [Thu, 15 Jun 2017 17:12:16 +0000 (13:12 -0400)]
Set complete FROM list for subquery eagerload's orig query
Instead of checking that the "orig_entity" we receive applies
as a correct FROM element for the subquery we're building,
set the FROM clause of the query to exactly what it already
is based on column_descriptions (assuming there is no FROM
list already), thereby ensuring that the FROM list will remain
intact, regardless of what orig_entity turns out to be and
what the target_cols ultimately refer towards.
Fixed issue with subquery eagerloading which continues on from
the series of issues fixed in :ticket:`2699`, :ticket:`3106`,
:ticket:`3893` involving that the "subquery" contains the correct
FROM clause when beginning from a joined inheritance subclass
and then subquery eager loading onto a relationship from
the base class, while the query also includes criteria against
the subclass. The fix in the previous tickets did not accommodate
for additional subqueryload operations loading more deeply from
the first level, so the fix has been further generalized.
Mike Bayer [Thu, 8 Jun 2017 16:55:23 +0000 (12:55 -0400)]
Render ARRAY index embedded between type and COLLATE
Fixed bug where using :class:`.ARRAY` with a string type that
features a collation would fail to produce the correct syntax
within CREATE TABLE.
The "COLLATE" must appear to the right of the array dimensions,
so we are using regexp substitution to insert the brackets in the
appropriate place. A more heavyweight solution would be that datatypes
know how to split up their base type vs. modifiers, but as this is
so specific to Postgresql ARRAY it's better to handle these cases
more locally.
Mike Bayer [Wed, 7 Jun 2017 16:30:22 +0000 (12:30 -0400)]
Parse for Postgresql version w/ "beta"
Continuing with the fix that correctly handles Postgresql
version string "10devel" released in 1.1.8, an additional regexp
bump to handle version strings of the form "10beta1". While
Postgresql now offers better ways to get this information, we
are sticking w/ the regexp at least through 1.1.x for the least
amount of risk to compatibility w/ older or alternate Postgresql
databases.
Mike Bayer [Tue, 6 Jun 2017 22:53:03 +0000 (18:53 -0400)]
- assert passive_deletes='all' does not affect collection/scalar
membership removal
in issue #3844 we hypotheized that passive_deletes='all' was broken
because it sets to NULL a foreign key attribute when the child
object is removed or replaced. However, not doing the NULL
set means that nothing happens at all and the operation silently
fails.
Mike Bayer [Fri, 26 May 2017 15:24:25 +0000 (11:24 -0400)]
Add placeholder XML support
Added a placeholder type :class:`.mssql.XML` to the SQL Server
dialect, so that a reflected table which includes this type can
be re-rendered as a CREATE TABLE. The type has no special round-trip
behavior nor does it currently support additional qualifying
arguments.
Mike Bayer [Thu, 25 May 2017 14:17:11 +0000 (10:17 -0400)]
Raise if ForeignKeyConstraint created with different numbers of
local and remote columns.
An :class:`.ArgumentError` is now raised if a
:class:`.ForeignKeyConstraint` object is created with a mismatched
number of "local" and "remote" columns, which otherwise causes the
internal state of the constraint to be incorrect. Note that this
also impacts the condition where a dialect's reflection process
produces a mismatched set of columns for a foreign key constraint.
Downstream DB2 dialect has been reported as potentially causing this
scenario.
Mike Bayer [Tue, 23 May 2017 14:17:51 +0000 (10:17 -0400)]
Remove twophase for cx_Oracle 6.x
Support for two-phase transactions has been removed entirely for
cx_Oracle when version 6.0b1 or later of the DBAPI is in use. The two-
phase feature historically has never been usable under cx_Oracle 5.x in
any case, and cx_Oracle 6.x has removed the connection-level "twophase"
flag upon which this feature relied.