Commit Graph

11048 Commits

Author SHA1 Message Date
Mike Bayer a66979fe1e - remove intersphinx usage, the overhead of re-fetching
inventory on every build not worth it

Change-Id: I3c4506b246d0f327c4b56afa723975daee984476
2017-07-09 13:02:59 -04:00
Mike Bayer e900aa97e2 - rst fixes
Change-Id: Ice3eeb8312fcb5a4d586113ee3e52be90fbcd95e
2017-07-09 11:13:10 -04:00
mike bayer 79285a0f46 Merge "Add support for CACHE and ORDER to sequences" 2017-07-06 09:03:29 -04:00
mike bayer 35ab498a87 Merge "Add .autocommit to scoped_session" 2017-07-05 16:23:57 -04:00
David Moore faa6609dac 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
2017-07-05 16:21:44 -04:00
Mike Bayer b7a51f3a9c - 1.1.12 placeholder
Change-Id: I23ccfebfbaaf40739a4a538d232875135a5cd04c
2017-07-05 16:07:42 -04:00
Ben Fagin 5c30910759 Add .autocommit to scoped_session
Added ``.autocommit`` attribute to :class:`.scoped_session`, proxying
the ``.autocommit`` attribute of the underling :class:`.Session`
currently assigned to the thread.  Pull request courtesy
Ben Fagin.

Change-Id: Iff741978bd67762f4c7375a23cc151b26192042b
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/372
2017-07-05 15:11:48 -04:00
Michael Doronin 7d3da6f850 Implement MySQL's ON DUPLICATE KEY UPDATE
Added support for MySQL's ON DUPLICATE KEY UPDATE
MySQL-specific :class:`.mysql.dml.Insert` object.
Pull request courtesy Michael Doronin.

Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Resolves: #4009
Change-Id: Ic71424f3c88af6082b48a910a2efb7fbfc0a7eb4
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/365
2017-07-03 14:38:09 -04:00
Michael Stewart 1db3029abc Include missing import in example 2017-06-30 14:02:20 -07:00
Mike Bayer 563180f7d4 Coerce to float for Float with all native decimal backends
The result processor for the :class:`.Float` type now unconditionally
runs values through the ``float()`` processor if the dialect
specifies that it also supports "native decimal" mode.  While most
backends will deliver Python ``float`` objects for a floating point
datatype, the MySQL backends in some cases lack the typing information
in order to provide this and return ``Decimal`` unless the float
conversion is done.

Change-Id: I638f1480fb00a507036efaf0e0080f26893d98ad
Fixes: #4020
2017-06-26 16:50:24 -04:00
mike bayer 33d083c034 Merge "Support state expiration for with_expression(); rename deferred_expression" 2017-06-26 15:47:50 -04:00
Mike Bayer 9ac0f8119e Support state expiration for with_expression(); rename deferred_expression
The attributeimpl for a deferred_expression does not
support a scalar loader, add new configurability so that
the impl can have this flag turned off.   Document
that the with_expression() system currently does not
offer any deferred loading.

To eliminate confusion over "deferred", which refers to
lazy loading of column attributes, and "with_expression",
which refers to an attribute that is explicitly at
query time only, rename deferred_expression to query_expression.

Change-Id: I07c4a050ed68c79ccbde9492e9de1630b7470d74
2017-06-26 13:49:49 -04:00
Mike Bayer fae82dda00 Return given type when it matches the adaptation
The rules for type coercion between :class:`.Numeric`, :class:`.Integer`,
and date-related types now include additional logic that will attempt
to preserve the settings of the incoming type on the "resolved" type.
Currently the target for this is the ``asdecimal`` flag, so that
a math operation between :class:`.Numeric` or :class:`.Float` and
:class:`.Integer` will preserve the "asdecimal" flag as well as
if the type should be the :class:`.Float` subclass.

Change-Id: Idfaba17220d6db21ca1ca4dcb4c19834cd397817
Fixes: #4018
2017-06-26 12:46:53 -04:00
mike bayer e04594339c Merge "Coerce float Python type to Float; ensure Python float coming back" 2017-06-26 11:56:38 -04:00
Mike Bayer 1776597131 Coerce float Python type to Float; ensure Python float coming back
Added some extra strictness to the handling of Python "float" values
passed to SQL statements.  A "float" value will be associated with the
:class:`.Float` datatype and not the Decimal-coercing :class:`.Numeric`
datatype as was the case before, eliminating a confusing warning
emitted on SQLite as well as unecessary coercion to Decimal.

Change-Id: I1bb1810ff1d198c0d929ccba5656e55401d74119
Fixes: #4017
2017-06-26 11:05:38 -04:00
Jodok Batlogg 9f1a375f10 added link for CrateDB support 2017-06-23 21:16:18 +02:00
Eloy Felix bff001187f Don't erase reflected comment in _init_existing
Change-Id: Ie0b78c79367933486528ca0ba686d4a9f16922b1
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/370
2017-06-20 09:48:49 -04:00
Mike Bayer 83c1e03c5c Add ad-hoc mapped expressions
Added a new feature :func:`.orm.with_expression` that allows an ad-hoc
SQL expression to be added to a specific entity in a query at result
time.  This is an alternative to the SQL expression being delivered as
a separate element in the result tuple.

Change-Id: Id8c479f7489fb02e09427837c59d1eabb2a6c014
Fixes: #3058
2017-06-19 17:41:39 -04:00
Mike Bayer 735fcd5e77 - 1.1.11 release date
Change-Id: I351e5727368b67598d091e5153a66987e349f8f6
2017-06-19 11:00:59 -04:00
mike bayer 139cbe4f72 Merge "Handle SHOW VARIABLES returning no row" 2017-06-16 18:40:13 -04:00
mike bayer 6d8d89042b Merge "Add all versioning logic to _post_update()" 2017-06-16 16:41:14 -04:00
Mike Bayer 5650a0c306 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.

Change-Id: I98e7a69230da397b17eae07b7e9d024fa7aeeb26
Fixes: #4007
2017-06-16 15:52:46 -04:00
Mike Bayer a991eedcf5 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 🎫`2699`, 🎫`3106`,
🎫`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.

Change-Id: Ic909590814f71e577d8266b1dbc4c393dc48e019
Fixes: #4011
2017-06-16 13:02:31 -04:00
Mike Bayer 3a314fcea8 Repair WithinGroup.get_children()
Fixed AttributeError which would occur in :class:`.WithinGroup`
construct during an iteration of the structure.

Change-Id: I563882d93c8c32292463a605b636aa60c77e9406
Fixes: #4012
2017-06-16 09:58:03 -04:00
Mike Bayer 64b0760faa Add all versioning logic to _post_update()
An UPDATE emitted as a result of the
:paramref:`.relationship.post_update` feature will now integrate with
the versioning feature to both bump the version id of the row as well
as assert that the existing version number was matched.

Fixes: #3496
Change-Id: I865405dd6069f1c1e3b0d27a4980e9374e059f97
2017-06-15 18:58:29 -04:00
Mike Bayer 7af05fcc93 - remove redundant fixture from base test class
Change-Id: I76f197d5b2b39ae476bfff924e899773aa123be0
2017-06-15 16:07:06 -04:00
Mike Bayer 9541e30e86 - ensure String has a length for mysql compatibility
Change-Id: Iaa1077ca5929bdc67300cc6bfb1ba98aff382246
2017-06-15 13:51:14 -04:00
Mike Bayer 770e1e399c Repair regression to pathing for subclasses
Issue #3963's initial commit narrowed the "current path"
match rules too much such that a path that matches current
path on subclass would no longer match.

Change-Id: I8c9a0db91a09d789cfb8666288a913f8bbcdb2e9
Fixes: #3963
2017-06-15 12:03:22 -04:00
Mike Bayer 740f6b0d5a Refinements for unitofwork internals
* remove "mapper" argument from SaveUpdateState, DeleteState
* use __slots__ for all uow action classes
* rename ".delete" to ".isdelete"
* rename issue_post_update to register_post_update since this
  doesn't actually issue the UPDATE
* rename IssuePostUpdate to PostUpdateAll

Change-Id: Ia6263b80d6a86eab1e8ed38df1421b1d0f249797
2017-06-14 12:54:53 -04:00
Mike Bayer 27a0bdcae0 Support AssociationProxy any() / has() / contains() to another AssociationProxy
The :meth:`.AssociationProxy.any`, :meth:`.AssociationProxy.has`
and :meth:`.AssociationProxy.contains`
comparison methods now support linkage to an attribute that
is itself also an :class:`.AssociationProxy`, recursively.

After some initial attempts it's clear that the any() / has()
of AssociationProxy needed to be reworked into a generic
_criterion_exists() to allow this to work recursively without
excess complexity.  For the case of the multi-linked associationproxy,
the usual checks of "any()" / "has()" correctness simply don't
take place; for a single-link association proxy the error
checking logic that takes place in relationship() has been
ported to the local any() / has() methods.

Change-Id: Ic5aed2a4e910b8138a737d215430113c31cce856
Fixes: #3769
2017-06-12 16:31:59 -04:00
Mike Bayer ec422fb70e 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.

Change-Id: I394c3c673eb60689e51b5301e51651972cfdb4c0
Fixes: #4006
2017-06-08 17:06:53 -04:00
Mike Bayer b6d3f60791 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.

Change-Id: I12ddb06465f7dcf80563c27632441ef5963f60d4
Fixes: #4005
2017-06-07 12:30:22 -04:00
Mike Bayer acf64c4178 - 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.

Change-Id: I11834e7e324349e172dc797bac62731008b6b95a
2017-06-06 18:53:03 -04:00
Mike Bayer f1faec8829 - make sure ticket # is here
Change-Id: I7d54026da9a9a9331a4fd7e675dbfe9c433fe2e4
2017-06-06 17:59:19 -04:00
Mike Bayer 4e1f5377d1 Warn when declared_attr.cascading detected on mapped class
A warning is emitted if the :attr:`.declared_attr.cascading` modifier
is used with a declarative attribute that is itself declared on
a class that is to be mapped, as opposed to a declarative mixin
class or ``__abstract__`` class.  The :attr:`.declared_attr.cascading`
modifier currently only applies to mixin/abstract classes.

Also add a test for @declared_attr.cascading when used on an attribute
on __abstract__.

Change-Id: Ib1b9dbe373e8be1cf24eadfed224a8988b3cd95d
Fixes: #3847
2017-06-06 17:16:58 -04:00
Mike Bayer 6b68a70b5f Re-send column value w/ onupdate default during post-update
Adjusted the behavior of post_update such that if a column with
an "onupdate" default has received an explicit value for
INSERT, re-send the same data during a post-update UPDATE so
that the value remains in effect, rather than an onupdate
overwriting it.

Change-Id: I26bccb6f957dcad07a2bcbda2dd9e14c60b92b06
Fixes: #3471
2017-06-06 13:54:33 -04:00
mike bayer a2099ed44f Merge "Implement _postfetch_post_update to expire/refresh onupdates in post_update" 2017-06-06 13:40:27 -04:00
Mike Bayer 9dee44ae2f Implement _postfetch_post_update to expire/refresh onupdates in post_update
Fixed bug involving the :paramref:`.relationship.post_update` feature
where a column "onupdate" value would not result in expiration or
refresh of the corresponding object attribute, if the UPDATE for the
row were a result of the "post update" feature.  Additionally, the
:meth:`.SessionEvents.refresh_flush` event is now emitted for these
attributes when refreshed within the flush.

Fixes: #3472
Change-Id: I5ee2d715e773a306ab1e8143e4382c228991ac78
2017-06-05 18:39:08 -04:00
Mike Bayer e8ad398862 Implement in-place mutation operators for MutableSet, MutableList
Implemented in-place mutation operators ``__ior__``, ``__iand__``,
``__ixor__`` and ``__isub__`` for :class:`.mutable.MutableSet`
and ``__iadd__`` for :class:`.mutable.MutableList` so that change
events are fired off when these mutator methods are used to alter the
collection.

Change-Id: Ib357a96d3b06c5deb6b53eb304a8b9f1dc9e9ede
Fixes: #3853
2017-06-05 15:49:04 -04:00
Mike Bayer bb6a1f690d selectin polymorphic loading
Added a new style of mapper-level inheritance loading
"polymorphic selectin".  This style of loading
emits queries for each subclass in an inheritance
hierarchy subsequent to the load of the base
object type, using IN to specify the desired
primary key values.

Fixes: #3948

Change-Id: I59e071c6142354a3f95730046e3dcdfc0e2c4de5
2017-06-05 11:27:00 -04:00
Mike Bayer 6bb97495ba Merge branch 'fix-typo' of https://github.com/lelit/sqlalchemy 2017-06-02 18:35:54 -04:00
Lele Gaifax 4779ddd865 Fix a few doc typos 2017-06-02 23:38:26 +02:00
Eloy Felix f8b4f7289e Implement get_unique_constraints, get_check_constraints for Oracle
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/326
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/342

Fixes: #4002
Change-Id: I221fe8ba305fc455a03e3a5d15f803bf8ee2e8fb
2017-05-30 17:14:22 -04:00
Mike Bayer 8b82369347 Don't hard-evaluate non-ORM @declared_attr for AbstractConcreteBase
Fixed bug where using :class:`.declared_attr` on an
:class:`.AbstractConcreteBase` where a particular return value were some
non-mapped symbol, including ``None``, would cause the attribute
to hard-evaluate just once and store the value to the object
dictionary, not allowing it to invoke for subclasses.   This behavior
is normal when :class:`.declared_attr` is on a mapped class, and
does not occur on a mixin or abstract class.  Since
:class:`.AbstractConcreteBase` is both "abstract" and actually
"mapped", a special exception case is made here so that the
"abstract" behavior takes precedence for :class:`.declared_attr`.

Change-Id: I6160ebb3a52c441d6a4b663c8c9bbac6d37fa417
Fixes: #3848
2017-05-26 13:28:15 -04:00
Mike Bayer b1369b4721 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.

Change-Id: I651fa729bd8e9b31a0b5effe0839aff077d77c46
Fixes: #3973
2017-05-26 11:24:25 -04:00
mike bayer 915012950c Merge "Raise if ForeignKeyConstraint created with different numbers of local and remote columns." 2017-05-25 16:24:25 -04:00
Michael Birtwell f8a3f14e4f Flatten operator precedence for comparison operators
The operator precedence for all comparison operators such as LIKE, IS,
IN, MATCH, equals, greater than, less than, etc. has all been merged
into one level, so that expressions which make use of these against
each other will produce parentheses between them.   This suits the
stated operator precedence of databases like Oracle, MySQL and others
which place all of these operators as equal precedence, as well as
Postgresql as of 9.5 which has also flattened its operator precendence.

Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Fixes: #3999
Change-Id: I3f3d5124a64af0d376361cdf15a97e2e703be56f
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/367
2017-05-25 16:02:13 -04:00
Mike Bayer a78718b934 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.

Change-Id: Id51c34a6c43749bb582639f9c1dc28723482f0e5
Fixes: #3949
References: #3998
2017-05-25 15:57:03 -04:00
Mike Bayer de11c5217b Add with_for_update() support in session.refresh()
Session.refresh() is still hardcoded to legacy lockmode,
come up with a new API so that the newer argument style
works with it.

Added new argument :paramref:`.with_for_update` to the
:meth:`.Session.refresh` method.  When the :meth:`.Query.with_lockmode`
method were deprecated in favor of :meth:`.Query.with_for_update`,
the :meth:`.Session.refresh` method was never updated to reflect
the new option.

Change-Id: Ia02a653746b7024699b515451525a88d7a17d63a
Fixes: #3991
2017-05-24 16:23:56 -04:00
Mike Bayer 9a37503bbe - add forwards-version
Change-Id: Id1652beb13209aac203456c88acff629048e00cc
2017-05-23 15:44:52 -04:00