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 [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.
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.
Mike Bayer [Tue, 30 Jan 2018 20:51:30 +0000 (15:51 -0500)]
Disable set eq test for python < 2.7.8
A test added in 1.2 thought to confirm a Python 2.7 behavior turns out to
be confirming the behavior only as of Python 2.7.8. Python bug #8743 still
impacts set comparison in Python 2.7.7 and earlier, so the test in question
involving AssociationSet no longer runs for these older Python 2.7
versions.
Mike Bayer [Mon, 29 Jan 2018 23:07:19 +0000 (18:07 -0500)]
Ensure _BundleEntity provides .mapper
Fixed bug where the :class:`.Bundle` object did not
correctly report upon the primary :class:`.Mapper` object
represened by the bundle, if any. An immediate
side effect of this issue was that the new selectinload
loader strategy wouldn't work with the horizontal sharding
extension.
robin [Sat, 27 Jan 2018 18:02:30 +0000 (13:02 -0500)]
Raise the sqlite3 import error, not the pysqlite2 one
Fixed the import error raised when a platform
has neither pysqlite2 nor sqlite3 installed, such
that the sqlite3-related import error is raised,
not the pysqlite2 one which is not the actual
failure mode. Pull request courtesy Robin.
Origin version only print `No module named pysqlite2` even
it's actually the import error of line 337: `from
sqlite3 import dbapi2 as sqlite` which point user
to the wrong debug direction.
It should raise `e.message` as `No module named _sqlite3`.
Mike Bayer [Thu, 25 Jan 2018 21:11:29 +0000 (16:11 -0500)]
Add a new FAQ section explaining how to ensure parenthesis
with op().
Not sure if this can be further improved at some point, such
as if a BinaryExpression automatically applied self_group()
when op() is called, however for the moment op() behaves consistently
as with all other operators without any ad-hoc effects.
Mike Bayer [Wed, 24 Jan 2018 16:09:47 +0000 (11:09 -0500)]
Ensure backrefs accommodate for op_bulk_replace
Fixed 1.2 regression regarding new bulk_replace event
where a backref would fail to remove an object from the
previous owner when a bulk-assignment assigned the
object to a new owner.
As this revisits the Event tokens associated with
AttributeImpl objects, remove the verbosity of the
"inline lazy init" pattern; the Event token is a simple
slotted object and should have minimal memory overhead.
Mike Bayer [Wed, 24 Jan 2018 22:27:10 +0000 (17:27 -0500)]
Adjust tests for pyodbc 4.0.22
pyodbc 4.0.22 is no longer allowing a datetime to be truncated
into a date, and additionally is asserting that numeric truncation
is not occurring; previously, it looks like we could send a
decimal of -1E-25 through the driver but we were only getting
back -1E-20, the test failed to check this. Not clear if the
larger precision worked fully at some point, but in any case,
it doesn't work now so just remove those values from the test.
Mike Bayer [Wed, 24 Jan 2018 23:03:04 +0000 (18:03 -0500)]
Rework synonym, synonym_for documentation
The map_column example was incorrect, and overall the purpose
of this parameter as well as that of synonym_for was not explained;
examples added along with more encouragement to use hybrids.
This is the only way I could get this test pass on informix, basically I strip every whitespace.
The sql text as recorded in informix is:
```
((a > 1 ) AND (a < 5 ) )
((a = 1 ) OR ((a > 2 ) AND (a <5 ) ) )
```
Yes, this is absolutely bonkers, but that is what I get :(
Mike Bayer [Tue, 16 Jan 2018 17:41:29 +0000 (12:41 -0500)]
Use NCHAR + setinputsizes() for all NVARCHAR2
The cx_Oracle dialect now calls setinputsizes() with cx_Oracle.NCHAR
unconditionally when the NVARCHAR2 datatype, in SQLAlchemy corresponding
to sqltypes.Unicode(), is in use. Per cx_Oracle's author this allows
the correct conversions to occur within the Oracle client regardless
of the setting for NLS_NCHAR_CHARACTERSET.