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.
Mike Bayer [Thu, 15 Feb 2018 22:42:48 +0000 (17:42 -0500)]
Test attributes for being non-mapped column properties more closely
Fixed bug in concrete inheritance mapping where user-defined
attributes such as hybrid properties that mirror the names
of mapped attributes from sibling classes would be overwritten by
the mapper as non-accessible at the instance level. Also
ensured that user-bound descriptors are not implicitly invoked at the class
level during the mapper configuration stage.
André Cruz [Thu, 15 Feb 2018 16:09:47 +0000 (11:09 -0500)]
Add ssl "operation timed out" message for psycopg2
Added "SSL SYSCALL error: Operation timed out" to the list
of messages that trigger a "disconnect" scenario for the
psycopg2 driver. Pull request courtesy André Cruz.
Mike Bayer [Tue, 13 Feb 2018 20:11:53 +0000 (15:11 -0500)]
Allow multiple plugin names
The :class:`.URL` object now allows query keys to be specified multiple
times where their values will be joined into a list. This is to support
the plugins feature documented at :class:`.CreateEnginePlugin` which
documents that "plugin" can be passed multiple times. Additionally, the
plugin names can be passed to :func:`.create_engine` outside of the URL
using the new :paramref:`.create_engine.plugins` parameter.
Mike Bayer [Mon, 12 Feb 2018 21:45:39 +0000 (16:45 -0500)]
Add dependency for parent_pre post updates to parent deletes
Fixed issue in post_update feature where an UPDATE is emitted
when the parent object has been deleted but the dependent object
is not. This issue has existed for a long time however
since 1.2 now asserts rows matched for post_update, this
was raising an error.
Mike Bayer [Fri, 9 Feb 2018 21:12:31 +0000 (16:12 -0500)]
Search through mapper superclass hierarchy for owner
Fixed regression caused by fix for issue :ticket:`4116` affecting versions
1.2.2 as well as 1.1.15, which had the effect of mis-calculation of the
"owning class" of an :class:`.AssociationProxy` as the ``NoneType`` class
in some declarative mixin/inheritance situations as well as if the
association proxy were accessed off of an un-mapped class. The "figure out
the owner" logic has been replaced by an in-depth routine that searches
through the complete mapper hierarchy assigned to the class or subclass to
determine the correct (we hope) match; will not assign the owner if no
match is found. An exception is now raised if the proxy is used
against an un-mapped instance.
Mike Bayer [Thu, 8 Feb 2018 14:16:39 +0000 (09:16 -0500)]
Add initiator argument to set_attribute
Added new argument :paramref:`.attributes.set_attribute.inititator`
to the :func:`.attributes.set_attribute` function, allowing an
event token received from a listener function to be propagated
to subsequent set events.
Mike Bayer [Thu, 8 Feb 2018 19:52:29 +0000 (14:52 -0500)]
Ensure weakref finalize_fairy operates upon the current connection
Fixed a fairly serious connection pool bug where a connection that is
acquired after being refreshed as a result of a user-defined
:class:`.DisconnectionError` or due to the 1.2-released "pre_ping" feature
would not be correctly reset if the connection were returned to the pool by
weakref cleanup (e.g. the front-facing object is garbage collected); the
weakref would still refer to the previously invalidated DBAPI connection
which would have the reset operation erroneously called upon it instead.
This would lead to stack traces in the logs and a connection being checked
into the pool without being reset, which can cause locking issues.
Jon Snyder [Wed, 17 Jan 2018 21:37:59 +0000 (16:37 -0500)]
Add values_callable feature to Enum
Added support for :class:`.Enum` to persist the values of the enumeration,
rather than the keys, when using a Python pep-435 style enumerated object.
The user supplies a callable function that will return the string values to
be persisted. This allows enumerations against non-string values to be
value-persistable as well. Pull request courtesy Jon Snyder.
Mike Bayer [Tue, 6 Feb 2018 23:13:27 +0000 (18:13 -0500)]
Add flag for class-level disallow of events, apply to OptionEngine
Fixed bug where events associated with an :class:`Engine`
at the class level would be doubled when the
:meth:`.Engine.execution_options` method were used. To
achieve this, the semi-private class :class:`.OptionEngine`
no longer accepts events directly at the class level
and will raise an error; the class only propagates class-level
events from its parent :class:`.Engine`. Instance-level
events continue to work as before.
The comments present another way of doing this where we would
copy events from the parent engine at option time rather
than linking the event listeners, but this would be a behavioral
change that adding new events to the parent engine would not
take effect for an already-created OptionEngine.
Mike Bayer [Tue, 6 Feb 2018 20:47:43 +0000 (15:47 -0500)]
Check cx_Oracle error code on all exception classes
Fixed bug in cx_Oracle disconnect detection, used by pre_ping and other
features, where an error could be raised as DatabaseError which includes a
numeric error code; previously we weren't checking in this case for a
disconnect code.
The ON DELETE options for foreign keys are now part of
Oracle reflection. Oracle does not support ON UPDATE
cascades. Pull request courtesy Miroslav Shubernetskiy.
Daniel Knell [Mon, 5 Feb 2018 14:25:47 +0000 (09:25 -0500)]
fix handling of native enum aliases in sqlalchemy enum columns
Fixed bug where the :class:`.Enum` type wouldn't handle
enum "aliases" correctly, when more than one key refers to the
same value. Pull request courtesy Daniel Knell.
Mike Bayer [Mon, 5 Feb 2018 14:03:08 +0000 (09:03 -0500)]
Convert dialect modules to relative imports and test
For some reason the dialects were not consistently
converted to relative imports. Also added a test to
ensure that __all__ is functioning within each dialect.
Mike Bayer [Fri, 2 Feb 2018 14:36:25 +0000 (09:36 -0500)]
Look for __sa_reconstructor__ on original_init
Fixed bug where the :func:`.orm.reconstructor` event
helper would not be recognized if it were applied to the
``__init__()`` method of the mapped class.
It's not clear when this bug appeared, but was likely
during a refactoring of instrumentation mechanics somewhere
between 0.8 and 1.0.