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.
Kataev Denis [Mon, 22 May 2017 21:52:45 +0000 (17:52 -0400)]
Repair formatting throughout documentation
1. Section decorators to [one style](http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#sections):
without inset at both side and with same length as text.
2. Fix broken [reference](http://docs.sqlalchemy.org/en/latest/core/type_basics.html#generic-types).
3. Convert tabs to space in some small files.
4. Some python code snippets have python+sql syntax hint.
Change-Id: I39a7a41ef0b0591c6bf1e610748e2b5c19fc5379
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/361
(cherry picked from commit 42b6ef8ccd691f6ace30ae16ed70f92e748f763f)
Mike Bayer [Sun, 21 May 2017 19:28:00 +0000 (15:28 -0400)]
Prevent SQL server isolation level from failing
Fixed bug where SQL Server transaction isolation must be fetched
from a different view when using Azure data warehouse, the query
is now attempted against both views and then a NotImplemented
is raised unconditionally if failure continues to provide the
best resiliency against future arbitrary API changes in new
SQL Server versions.
Mike Bayer [Thu, 18 May 2017 21:44:10 +0000 (17:44 -0400)]
- Document the most transparent way to set JSON.NULL for
a column default.
The JSON.NULL value is special in that while it is a Python-side
value, it represents "do this special behavior", and is not at all
like any other Python-side value for which normally, that's exactly
the type of data we want back. So in this case, encourage the user
to use a SQL expression that is exact, so in the ORM context, you get
back what was actually persisted in the column. There's some variants
of this such as literal(JSON.NULL, JSON) but text("'null'") is simpler.
Mike Bayer [Tue, 16 May 2017 13:51:06 +0000 (09:51 -0400)]
modernize and repair inheritance examples
remarkably, the examples for concrete and single were still
using classical mappings. Ensure all three examples use
modern declarative patterns, each illustrate the identical set
of query operations. Use back_populates, flat=True for joins,
etc. ensure flake8 linting, correct links and add a link back
from newly reworked inheritance documentation.
Mike Bayer [Fri, 12 May 2017 14:53:54 +0000 (10:53 -0400)]
Cascade mappers in terms of the instance's mapper
Fixed a (extremely old) bug in cascade_mappers where the
first cascade we do is against the "self" mapper, and not the
one that actually corresponds to the state given. These are
different in the case where we start with a relationship
to a class, and the instance is of a subclass, which itself
can have relationships that aren't on the base mapper.
A pretty severe bug that somehow has avoided the radar
since the beginning.
Mike Bayer [Fri, 12 May 2017 13:23:44 +0000 (09:23 -0400)]
Add links to with_only_columns to Select.column, append_column
Provide a brief example for these two methods
indicating that typically a table-bound (or other selectable)
column is appended here, then link to with_only_columns
documentation which has in-depth guidelines already including
that one should not append columns from the current select to itself.
Mike Bayer [Mon, 1 May 2017 17:04:32 +0000 (13:04 -0400)]
Update inheritance documentation.
The inheritance documentation is confused, disorganized, and out
of date. Reorganize and clarify, in particular in preparation
for new inheritance features.
Mike Bayer [Tue, 9 May 2017 16:17:04 +0000 (12:17 -0400)]
Use regexp to parse cx_oracle version string
Fixed bug in cx_Oracle dialect where version string parsing would
fail for cx_Oracle version 6.0b1 due to the "b" character. Version
string parsing is now via a regexp rather than a simple split.