Mike Bayer [Wed, 16 May 2018 19:47:50 +0000 (15:47 -0400)]
Clarify dogpile.cache differences which occur via #4128.
The fix for :ticket:`4128` which failed to be included
in the 1.2.5 release also works around an issue in the dogpile.cache
"advanced" example, which will also be fixed independently.
Mike Bayer [Mon, 26 Feb 2018 00:54:37 +0000 (19:54 -0500)]
Restore missing changelog files for #4128
The fix merged in 4a31c30fa5ebd6af0e72937b21b2e5ee79e12631
failed to get backported to 1.2 and the changelog files
got blown away in the release process. Restore the
changelog files to master before cherry-picking
the whole thing to 1.2.
Mike Bayer [Fri, 11 May 2018 13:19:10 +0000 (09:19 -0400)]
Default server_version_info to (0, )
Fixed a bug in the test suite where if an external dialect returned
``None`` for ``server_version_info``, the exclusion logic would raise an
``AttributeError``.
Mike Bayer [Thu, 10 May 2018 15:39:06 +0000 (11:39 -0400)]
SQL Server is not native boolean; add new flag for CHECK constraint
Fixed a 1.2 regression caused by :ticket:`4061` where the SQL Server
"BIT" type would be considered to be "native boolean". The goal here
was to avoid creating a CHECK constraint on the column, however the bigger
issue is that the BIT value does not behave like a true/false constant
and cannot be interpreted as a standalone expression, e.g.
"WHERE <column>". The SQL Server dialect now goes back to being
non-native boolean, but with an extra flag that still avoids creating
the CHECK constraint.
Mike Bayer [Thu, 3 May 2018 16:35:23 +0000 (12:35 -0400)]
Use identity_token for refresh(), unexpire, undefer
The horizontal sharding extension now makes use of the identity token
added to ORM identity keys as part of :ticket:`4137`, when an object
refresh or column-based deferred load or unexpiration operation occurs.
Since we know the "shard" that the object originated from, we make
use of this value when refreshing, thereby avoiding queries against
other shards that don't match this object's identity in any case.
Mike Bayer [Mon, 30 Apr 2018 15:31:48 +0000 (11:31 -0400)]
Render FOR UPDATE on the inner subquery as well as the outer
The ORM now doubles the "FOR UPDATE" clause within the subquery that
renders in conjunction with joined eager loading in some cases, as it has
been observed that MySQL does not lock the rows from a subquery. This
means the query renders with two FOR UPDATE clauses; note that on some
backends such as Oracle, FOR UPDATE clauses on subqueries are silently
ignored since they are unnecessary. Additionally, in the case of the "OF"
clause used primarily with Postgresql, the FOR UPDATE is rendered only on
the inner subquery when this is used so that the selectable can be targeted
to the table within the SELECT statement.
Fixed a reference leak issue where the values of the parameter dictionary
used in a statement execution would remain referenced by the "compiled
cache", as a result of storing the key view used by Python 3 dictionary
keys(). Pull request courtesy Olivier Grisel.
Mike Bayer [Fri, 20 Apr 2018 15:44:09 +0000 (11:44 -0400)]
Refactor "get" to allow for pluggable identity token schemes
Fixed regression in 1.2 within sharded query feature where the
new "identity_token" element was not being correctly considered within
the scope of a lazy load operation, when searching the identity map
for a related many-to-one element. The new behavior will allow for
making use of the "id_chooser" in order to determine the best identity
key to retrieve from the identity map. In order to achieve this, some
refactoring of 1.2's "identity_token" approach has made some slight changes
to the implementation of ``ShardedQuery`` which should be noted for other
derivations of this class.
Mike Bayer [Fri, 20 Apr 2018 17:31:45 +0000 (13:31 -0400)]
Document how to opt-out of NCHAR for cx_Oracle
Unfortunately, we need to bind Python unicode values as
NCHAR as in the case where non-ascii characters are present,
it's necessary. We can't know in all cases how this value is being
used, so in those cases where Oracle will not accept NCHAR the
user should explicitly cast a value down to String.
Mike Bayer [Thu, 19 Apr 2018 21:07:32 +0000 (17:07 -0400)]
Ensure select_from_entity adapter is used in adjust_for_single_inheritance
Fixed issue in single-inheritance loading where the use of an aliased
entity against a single-inheritance subclass in conjunction with the
:meth:`.Query.select_from` method would cause the SQL to be rendered with
the unaliased table mixed in to the query, causing a cartesian product. In
particular this was affecting the new "selectin" loader when used against a
single-inheritance subclass.
Mike Bayer [Tue, 17 Apr 2018 17:22:13 +0000 (13:22 -0400)]
Render and reflect MySQL WITH PARSER index options
Support added for the "WITH PARSER" syntax of CREATE FULLTEXT INDEX
in MySQL, using the ``mysql_with_parser`` keyword argument. Reflection
is also supported, which accommodates MySQL's special comment format
for reporting on this option as well. Additionally, the "FULLTEXT" and
"SPATIAL" index prefixes are now reflected back into the ``mysql_prefix``
index option.
Kent Bower [Wed, 11 Apr 2018 21:21:26 +0000 (17:21 -0400)]
Reflect Oracle NUMBER(NULL, 0) as INTEGER
The Oracle NUMBER datatype is reflected as INTEGER if the precision is NULL
and the scale is zero, as this is how INTEGER values come back when
reflected from Oracle's tables. Pull request courtesy Kent Bower.
Mike Bayer [Wed, 11 Apr 2018 13:29:00 +0000 (09:29 -0400)]
Correct join for FKs with schema in SQL Server
Fixed 1.2 regression caused by :ticket:`4060` where the query used to
reflect SQL Server cross-schema foreign keys was limiting the criteria
incorrectly.
Additionally, added some rework of the inter-schema reflection tests
so that MySQL, MSSQL can be included, breaking out some of the
Postgresql-specific behaviors into separate requirements.
Mike Bayer [Fri, 6 Apr 2018 15:39:15 +0000 (11:39 -0400)]
Raise informative exception for non-sortable PK
An informative exception is re-raised when a primary key value is not
sortable in Python during an ORM flush under Python 3, such as an ``Enum``
that has no ``__lt__()`` method; normally Python 3 raises a ``TypeError``
in this case. The flush process sorts persistent objects by primary key
in Python so the values must be sortable.
Mike Bayer [Wed, 4 Apr 2018 17:36:28 +0000 (13:36 -0400)]
Ensure all visit_sequence accepts **kw args
Fixed issue where the compilation of an INSERT statement with the
"literal_binds" option that also uses an explicit sequence and "inline"
generation, as on Postgresql and Oracle, would fail to accommodate the
extra keyword argument within the sequence processing routine.
Mike Bayer [Tue, 3 Apr 2018 19:35:00 +0000 (15:35 -0400)]
Use base __ne__ implementation for range types w/ None
Fixed bug where the special "not equals" operator for the Postgresql
"range" datatypes such as DATERANGE would fail to render "IS NOT NULL" when
compared to the Python ``None`` value.
Also break up range tests into backend round trip and straight
compilation suites.
Mike Bayer [Fri, 30 Mar 2018 15:22:30 +0000 (11:22 -0400)]
Filter non-integer characters from pyodbc SQL Server version
Adjusted the SQL Server version detection for pyodbc to only allow for
numeric tokens, filtering out non-integers, since the dialect does tuple-
numeric comparisons with this value. This is normally true for all known
SQL Server / pyodbc drivers in any case.
Mike Bayer [Wed, 28 Mar 2018 15:58:47 +0000 (11:58 -0400)]
Invalidate on failed connect handler
Fixed bug in connection pool where a connection could be present in the
pool without all of its "connect" event handlers called, if a previous
"connect" handler threw an exception; note that the dialects themselves
have connect handlers that emit SQL, such as those which set transaction
isolation, which can fail if the database is in a non-available state, but
still allows a connection. The connection is now invalidated first if any
of the connect handlers fail.
Mike Bayer [Wed, 21 Mar 2018 13:59:46 +0000 (09:59 -0400)]
Don't warn for mixin-based __table_args__, __mapper_args__ declared_attr
Removed a warning that would be emitted when calling upon
``__table_args__``, ``__mapper_args__`` as named with a ``@declared_attr``
method, when called from a non-mapped declarative mixin. Calling these
directly is documented as the approach to use when one is overidding one
of these methods on a mapped class. The warning still emits for regular
attribute names.
Mike Bayer [Wed, 14 Mar 2018 15:04:43 +0000 (11:04 -0400)]
Track if we're rendering within the CTE recursively
Fixed a regression that occurred from the previous fix to :ticket:`4204` in
version 1.2.5, where a CTE that refers to itself after the
:meth:`.CTE.alias` method has been called would not refer to iself
correctly.
Mike Bayer [Mon, 12 Mar 2018 16:50:52 +0000 (12:50 -0400)]
Ignore non-primary mappers within mutable instrumentation
Fixed bug where using :meth:`.Mutable.associate_with` or
:meth:`.Mutable.as_mutable` in conjunction with a class that has non-
primary mappers set up with alternatively-named attributes would produce an
attribute error. Since non-primary mappers are not used for persistence,
the mutable extension now excludes non-primary mappers from its
instrumentation steps.
Mike Bayer [Wed, 7 Mar 2018 21:27:26 +0000 (16:27 -0500)]
Raise cx_Oracle minimum version to 5.2
The minimum cx_Oracle version supported is 5.2 (June 2015). Previously,
the dialect asserted against version 5.0 but as of 1.2.2 we are using some
symbols that did not appear until 5.2.
Mike Bayer [Wed, 7 Mar 2018 21:03:07 +0000 (16:03 -0500)]
Add notes regarding flat=True
Start documenting that flat=True and aliased=True don't work
with selectable particularly when selectable is an aliased select
already. References #4212
Eric Atkin [Wed, 28 Feb 2018 21:00:38 +0000 (16:00 -0500)]
Add Query.enable_single_entity()
Added new feature :meth:`.Query.only_return_tuples`. Causes the
:class:`.Query` object to return keyed tuple objects unconditionally even
if the query is against a single entity. Pull request courtesy Eric
Atkin.
Mike Bayer [Tue, 6 Mar 2018 02:36:18 +0000 (21:36 -0500)]
Clone _cte_alias instead of assigning "self"
Fixed bug in :class:.`CTE` construct along the same lines as that of
:ticket:`4204` where a :class:`.CTE` that was aliased would not copy itself
correctly during a "clone" operation as is frequent within the ORM as well
as when using the :meth:`.ClauseElement.params` method.
Mike Bayer [Mon, 5 Mar 2018 19:48:00 +0000 (14:48 -0500)]
Don't include AliasedClass when pickling options
Fixed 1.2 regression where a mapper option that contains an
:class:`.AliasedClass` object, as is typical when using the
:meth:`.QueryableAttribute.of_type` method, could not be pickled. 1.1's
behavior was to omit the aliased class objects from the path, so this
behavior is restored.
Mike Bayer [Mon, 5 Mar 2018 16:33:30 +0000 (11:33 -0500)]
Only replace first occurrence for COLLATE/ARRAY syntax
Fixed bug in Postgresql COLLATE / ARRAY adjustment first introduced
in :ticket:`4006` where new behaviors in Python 3.7 regular expressions
caused the fix to fail.
Mike Bayer [Fri, 2 Mar 2018 20:08:08 +0000 (15:08 -0500)]
Get MySQL version info from @@version
MySQL dialects now query the server version using ``SELECT @@version``
explicitly to the server to ensure we are getting the correct version
information back. Proxy servers like MaxScale interfere with the value
that is passed to the DBAPI's connection.server_version value so this
is no longer reliable.
Mike Bayer [Thu, 1 Mar 2018 15:45:39 +0000 (10:45 -0500)]
Check existing CTE for an alias name when rendering FROM clause
Fixed bug in CTE rendering where a :class:`.CTE` that was also turned into
an :class:`.Alias` would not render its "ctename AS aliasname" clause
appropriately if there were more than one reference to the CTE in a FROM
clause.
Mike Bayer [Mon, 26 Feb 2018 00:54:37 +0000 (19:54 -0500)]
Merge existing query params in baked lazy load
Fixed a long-standing regression that occurred in version
1.0, which prevented the use of a custom :class:`.MapperOption`
that alters the _params of a :class:`.Query` object for a
lazy load, since the lazy loader itself would overwrite those
parameters. This applies to the "temporal range" example
on the wiki. Note however that the
:meth:`.Query.populate_existing` method is now required in
order to rewrite the mapper options associated with an object
already loaded in the identity map. Also, a custom defined
:class:`.MapperOption` will now cause lazy loaders related to
the target object to use a non-baked query by default unless
the :meth:`.MapperOption._generate_cache_key` method is implemented.
Fixed bug where the new :meth:`.baked.Result.with_post_criteria`
method would not interact with a subquery-eager loader correctly,
in that the "post criteria" would not be applied to embedded
subquery eager loaders. This is related to :ticket:`4128` in that
the post criteria feature is now used by the lazy loader.
Mike Bayer [Fri, 23 Feb 2018 18:55:17 +0000 (13:55 -0500)]
Ensure we have states to load when doing poly post load
Fixed bug in new "polymorphic selectin" loading when a selection of
polymorphic objects were to be partially loaded from a relationship
lazy loader, leading to an "empty IN" condition within the load that
raises an error for the "inline" form of "IN".
Mike Bayer [Fri, 23 Feb 2018 00:47:24 +0000 (19:47 -0500)]
Allow bind processors to work with expanding IN
Fixed bug in new "expanding IN parameter" feature where the bind parameter
processors for values wasn't working at all, tests failed to cover this
pretty basic case which includes that ENUM values weren't working.
Eric Atkin [Thu, 22 Feb 2018 19:16:14 +0000 (14:16 -0500)]
Quote cte alias if needed
Fixed bug where CTE expressions would not have their name or alias name
quoted when the given name is case sensitive or otherwise requires quoting.
Pull request courtesy Eric Atkin.
Mike Bayer [Wed, 21 Feb 2018 16:16:09 +0000 (11:16 -0500)]
Ensure mapping has no version_id_generator when checking missing version_id
Fixed 1.2 regression in ORM versioning feature where a mapping against a
:func:`.select` or :func:`.alias` that also used a versioning column
against the underlying table would fail due to the check added as part of
:ticket:`3673`.
See also #4194 and #4195 for related issues found regarding
mapped selects and versioning.
Mike Bayer [Tue, 20 Feb 2018 17:15:57 +0000 (12:15 -0500)]
Default to using current mapped class as owner if none found
Repaired regression caused in 1.2.3 and 1.1.16 regarding association proxy
objects, revising the approach to :ticket:`4185` when calculating the
"owning class" of an association proxy to default to choosing the current
class if the proxy object is not directly associated with a mapped class,
such as a mixin.
Mike Bayer [Mon, 19 Feb 2018 23:13:24 +0000 (18:13 -0500)]
Rewrite the "deleting from collections" section
This section documents an aspect of the ORM that is
more generalized than just collections as well as more general
than just using session.delete(), even though session.delete()
with collections is the most common use case. Try to expand
out the scope here to explain the situation from the perspective
of any kind of relationship, include example with delete cascade
with many-to-one as well.
Mike Bayer [Mon, 19 Feb 2018 21:59:42 +0000 (16:59 -0500)]
Implement remove() for _empty_collection
Fixed regression caused in 1.2.3 due to fix from :ticket:`4181` where
the changes to the event system involving :class:`.Engine` and
:class:`.OptionEngine` did not accommodate for event removals, which
would raise an ``AttributeError`` when invoked at the class
level.
Mike Bayer [Fri, 16 Feb 2018 23:13:30 +0000 (18:13 -0500)]
Remove erroneous skip message
The logic here seems to try to say something different when
__backend__ is True but it produces a nonsensical message,
since __only_on__ doesn't tell us about the implementation
we are actually running.