summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
Commit message (Collapse)AuthorAgeFilesLines
...
* Warn when declared_attr.cascading detected on mapped classMike Bayer2017-06-062-0/+13
| | | | | | | | | | | | | | 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
* Re-send column value w/ onupdate default during post-updateMike Bayer2017-06-061-1/+1
| | | | | | | | | | | 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
* Merge "Implement _postfetch_post_update to expire/refresh onupdates in ↵mike bayer2017-06-061-5/+39
|\ | | | | | | post_update"
| * Implement _postfetch_post_update to expire/refresh onupdates in post_updateMike Bayer2017-06-051-5/+39
| | | | | | | | | | | | | | | | | | | | | | | | 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
* | Implement in-place mutation operators for MutableSet, MutableListMike Bayer2017-06-051-0/+20
|/ | | | | | | | | | | 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
* selectin polymorphic loadingMike Bayer2017-06-059-37/+340
| | | | | | | | | | | | | 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
* Merge branch 'fix-typo' of https://github.com/lelit/sqlalchemyMike Bayer2017-06-021-5/+5
|\
| * Fix a few doc typosLele Gaifax2017-06-021-5/+5
| |
* | Implement get_unique_constraints, get_check_constraints for OracleEloy Felix2017-05-302-3/+134
| | | | | | | | | | | | | | | | Pull-request: https://github.com/zzzeek/sqlalchemy/pull/326 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/342 Fixes: #4002 Change-Id: I221fe8ba305fc455a03e3a5d15f803bf8ee2e8fb
* | Don't hard-evaluate non-ORM @declared_attr for AbstractConcreteBaseMike Bayer2017-05-261-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Add placeholder XML supportMike Bayer2017-05-261-0/+18
| | | | | | | | | | | | | | | | | | | | | | 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
* | Merge "Raise if ForeignKeyConstraint created with different numbers of local ↵mike bayer2017-05-251-0/+16
|\ \ | | | | | | | | | and remote columns."
| * | Raise if ForeignKeyConstraint created with different numbers ofMike Bayer2017-05-251-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | Flatten operator precedence for comparison operatorsMichael Birtwell2017-05-251-12/+13
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Add with_for_update() support in session.refresh()Mike Bayer2017-05-243-5/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Merge "Remove twophase for cx_Oracle 6.x"mike bayer2017-05-231-35/+21
|\ \
| * | Remove twophase for cx_Oracle 6.xMike Bayer2017-05-231-35/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. Change-Id: I2e8161cc2bc12f4845c9224cd483038112fe9734 Fixes: #3997
* | | Add AttributeEvents.modifiedMike Bayer2017-05-233-6/+59
|/ / | | | | | | | | | | | | | | | | | | Added new event handler :meth:`.AttributeEvents.modified` which is triggered when the func:`.attributes.flag_modified` function is invoked, which is common when using the :mod:`sqlalchemy.ext.mutable` extension module. Change-Id: Ic152f1d5c53087d780b24ed7f1f1571527b9e8fc Fixes: #3303
* | Add clause adaptation for AliasedClass to with_parent()Mike Bayer2017-05-233-16/+36
| | | | | | | | | | | | | | | | | | | | | | | | Fixed bug where :meth:`.Query.with_parent` would not work if the :class:`.Query` were against an :func:`.aliased` construct rather than a regular mapped class. Also adds a new parameter :paramref:`.util.with_parent.from_entity` to the standalone :func:`.util.with_parent` function as well as :meth:`.Query.with_parent`. Change-Id: Ic684dd63cc90b582c7580c9bba3c92fa3f286da7 Fixes: #3607
* | detect and raise for version_id is NULLDiana Clarke2017-05-221-0/+5
| | | | | | | | | | | | | | | | | | The versioning feature does not support NULL for the version counter. An exception is now raised if the version id is programmatic and was set to NULL for an UPDATE. Pull request courtesy Diana Clarke. Fixes: #3673 Change-Id: I8b0da56234a7c7f5e7fde35536e09a6216a5e48a
* | Merge "Detect no params w/ manual version_id counter and set to itself"mike bayer2017-05-221-0/+7
|\ \
| * | Detect no params w/ manual version_id counter and set to itselfMike Bayer2017-05-221-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed bug where programmatic version_id counter in conjunction with joined table inheritance would fail if the version_id counter were not actually incremented and no other values on the base table were modified, as the UPDATE would have an empty SET clause. Since programmatic version_id where version counter is not incremented is a documented use case, this specific condition is now detected and the UPDATE now sets the version_id value to itself, so that concurrency checks still take place. Change-Id: I80e385bffeed4851cc20131cbe983c173a46f655 Fixes: #3996
* | | Allow metadata.reflect() to recover from unreflectable tablesMike Bayer2017-05-224-7/+30
|/ / | | | | | | | | | | | | | | | | | | | | | | | | Added support for views that are unreflectable due to stale table definitions, when calling :meth:`.MetaData.reflect`; a warning is emitted for the table that cannot respond to ``DESCRIBE`` but the operation succeeds. The MySQL dialect now raises UnreflectableTableError which is in turn caught by MetaData.reflect(). Reflecting the view standalone raises this error directly. Change-Id: Id8005219d8e073c154cc84a873df911b4a6cf4d6 Fixes: #3871
* | Remove "scope" keyword from scoped_session.__call__()Mike Bayer2017-05-221-11/+7
| | | | | | | | | | | | | | | | | | Removed a very old keyword argument from :class:`.scoped_session` called ``scope``. This keyword was never documented and was an early attempt at allowing for variable scopes. Change-Id: I9a26498a1a66d1eafb0723e98b527688a60f9d9b Fixes: #3796
* | Prevent SQL server isolation level from failingMike Bayer2017-05-221-15/+30
|/ | | | | | | | | | | | 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. Change-Id: I621b5089febe8ace136428fa133fde1a7e21cda4 Fixes: #3994
* - Document the most transparent way to set JSON.NULL forMike Bayer2017-05-181-0/+16
| | | | | | | | | | | | | | | 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. Change-Id: I0339fafdc03e4b2f533d53970b2f74c774f2687b Fixes: #3923
* Add new configuration, inspection for baked queriesMike Bayer2017-05-172-6/+43
| | | | | | | | | | Added new flag :paramref:`.Session.enable_baked_queries` to the :class:`.Session` to allow baked queries to be disabled session-wide, reducing memory use. Also added new :class:`.Bakery` wrapper so that the bakery returned by :paramref:`.BakedQuery.bakery` can be inspected. Change-Id: I5657af7a99d2b24c89d6aee1343f432728e3f807
* - add complete parameter /return value docs to session.begin() /Mike Bayer2017-05-171-13/+45
| | | | | | session.begin_nested(). Fixes #3993 Change-Id: If485d77b364c34d94061d2f48efbde3f8a8adec9
* - give SelectinLoader its own bakery, dont use mapperMike Bayer2017-05-162-9/+24
| | | | | | | | level cache - include SelectinLoader itself in the cache key, though this is currently not critical Change-Id: I8e4bcd579277fbe53d9c7eca3552a0b8ab9d7a39
* Merge "Demote innerjoin to outerjoin coming from with_polymorphic"mike bayer2017-05-124-9/+23
|\
| * Demote innerjoin to outerjoin coming from with_polymorphicMike Bayer2017-05-124-9/+23
| | | | | | | | | | | | | | | | | | | | | | a with_polymorphic, regardless of inheritance type, represents multiple classes. A subclass that wants to joinedload with innerjoin=True needs to be demoted to an outerjoin because the parent entity rows might not be of that type. Looks more intuitive with a joined inheritance load, but applies just as well to single or concrete. Change-Id: I4d3d76106ae20032269f8848aad70a8e2f9422f9 Fixes: #3988
* | Cascade mappers in terms of the instance's mapperMike Bayer2017-05-121-4/+10
|/ | | | | | | | | | | | | | | 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. Change-Id: I512956b9757b07e06f3ca1ccb507a33fb10bed31 Fixes: #3986
* Add links to with_only_columns to Select.column, append_columnMike Bayer2017-05-121-19/+16
| | | | | | | | | | | 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. Change-Id: I0742405a7f3c41450d337b9c633519d9cc101dfb Fixes: #3987
* Merge "Update inheritance documentation."mike bayer2017-05-101-6/+4
|\
| * Update inheritance documentation.Mike Bayer2017-05-101-6/+4
| | | | | | | | | | | | | | | | The inheritance documentation is confused, disorganized, and out of date. Reorganize and clarify, in particular in preparation for new inheritance features. Change-Id: Ibe6a35b4b0432bad866a6afb0598b2cf1b509f10
* | Merge "Add conditionals specific to deferred for expire ro properties"mike bayer2017-05-101-2/+10
|\ \
| * | Add conditionals specific to deferred for expire ro propertiesMike Bayer2017-05-101-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed bug where a :func:`.column_property` that is also marked as "deferred" would be marked as "expired" during a flush, causing it to be loaded along with the unexpiry of regular attributes even though this attribute was never accessed. Change-Id: Iaa9e17b66ece30a8e729e4af746b31ff99b1ec9a Fixes: #3984
* | | Fix docs syntax errorDenis Kataev2017-05-101-8/+6
|/ /
* | Merge "Use regexp to parse cx_oracle version string"mike bayer2017-05-091-2/+12
|\ \
| * | Use regexp to parse cx_oracle version stringMike Bayer2017-05-091-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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. Change-Id: I2af7172b0d7184e3ea3bd051e9fa8d6ca2a571cd Fixes: #3975
* | | Support autocommit for GRANT and REVOKE on postgresqlJacob Hayes2017-05-091-1/+1
|/ / | | | | | | | | | | | | Extends `AUTOCOMMIT_REGEXP` for the postgres dialect to include `GRANT` and `REVOKE`. Change-Id: Iba15f1ebf5bd7bc0fc1193fdf561417e53bf5d57 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/357
* | Protect against cls weakref becoming NoneMike Bayer2017-05-082-4/+8
| | | | | | | | | | | | | | | | | | | | Protected against testing "None" as a class in the case where declarative classes are being garbage collected and new automap prepare() operations are taking place concurrently, very infrequently hitting a weakref that has not been fully acted upon after gc. Change-Id: I32e1dfc5ac46bac4127fe808cfd18368e2fad9dd
* | Merge branch 'master' of https://github.com/aflyhorse/sqlalchemyMike Bayer2017-05-081-9/+10
|\ \
| * | Break the lines to fit pdf and fix another broken syntaxLunarShaddow2017-05-081-6/+10
| | |
| * | remove ambiguous line breakers to help sphinx identify code blockLunarShaddow2017-05-051-5/+2
| |/
* | Merge branch 'patch-1' of https://github.com/UnquietCode/sqlalchemyMike Bayer2017-05-081-1/+1
|\ \
| * | fixes a typoBen Fagin2017-05-011-1/+1
| |/
* | - big rewrite of the Sequence documentation:Mike Bayer2017-05-051-20/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Sequence should be associated with MetaData always, except in the really weird case someone is sharing a Sequence among multiple metadatas. Make this a "best practice", end the confusion of #3951, #3979 2. "optional" is not a thing people use, trim this way down 3. remove confusing language Change-Id: Iab5aec319da2582092fe2615ee50430f76441aff (cherry picked from commit a1dcf23e371695d8d3be2e1d7875fad10f16a656)
* | - add another note re: 339e2c13b0fc8e95a47d00c0f8fc5afc4b6dff9aMike Bayer2017-05-051-0/+12
| | | | | | | | | | | | | | | | which clarifies that ForeignKey circumvents this logic as a "convenience". issue #3978 is updated to address trying to make this consistent. Change-Id: I089acaa89f11b7a6310c2bf32916e26eb62ab9c0
* | - add a note to MetaData.schema indicating that the TableMike Bayer2017-05-051-0/+13
|/ | | | | | | will be cataloged in the .tables collection with its fully qualified name. Fixes #3978 Change-Id: I65fa063918efc22658e93c39a0680cb83553dec8