summaryrefslogtreecommitdiff
path: root/test/orm
Commit message (Collapse)AuthorAgeFilesLines
* Deprecate FromClause.count()Mike Bayer2016-06-1412-91/+127
| | | | | | | | | | | count() here is misleading in that it not only counts from an arbitrary column in the table, it also does not make accommodations for DISTINCT, JOIN, etc. as the ORM-level function does. Core should not be attempting to provide a function like this. Change-Id: I9916fc51ef744389a92c54660ab08e9695b8afc2 Fixes: #3724
* Use the "committed" values when extracting many-to-one lazyload valueMike Bayer2016-06-081-15/+23
| | | | | | | | | | | | | | | The scalar object set() method calls upon the lazy loader to get at the "old" value of the attriute, however doesn't ensure that the "committed" value of the foreign key attributes is used. If the user has manipulated these attributes and they themselves have pending, non committed changes, we get the "new" value which these attributes would have set up if they were flushed. "old" vs "new" value is always about how the value has changed since the load, so we always have to use the DB-persisted values for everything when looking for "old". Change-Id: I82bdc40ad0cf033c3a98f3361776cf3161542cd6 Fixes: #3708
* Add 'FOR NO KEY UPDATE' / 'FOR KEY SHARE' support for PostgresqlSergey Skopin2016-06-081-2/+25
| | | | | | | | Adds ``key_share=True`` for with_for_update(). Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Change-Id: I74e0c3fcbc023e1dc98a1fa0c7db67b4c3693a31 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/279
* Add "render_nulls" flag to bulk_insert as optional performance optimizationtsauerwein2016-06-061-2/+25
| | | | | | | | | | | | | | Currently, ``Session.bulk_insert_mappings`` omits NULL values which causes it to break up batches of inserts based on which batches contain NULL and which do not. By adding this flag, the same columns are rendered in the INSERT for all rows allowing them to be batched. The downside is that server-side defaults are omitted. Doctext-author: Mike Bayer <mike_mp@zzzcomputing.com> Change-Id: Iec5969304d4bdbf57290b200331bde02254aa3a5 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/243
* Add SKIP LOCKED support for Postgresql, OracleJack Zhou2016-06-021-0/+18
| | | | | | | | This adds `SELECT ... FOR UPDATE SKIP LOCKED`/ `SELECT ... FOR SHARE SKIP LOCKED` rendering. Change-Id: Id1dc4f1cafc1de23f397a6f73d54ab2c58d5910d Pull-request: https://bitbucket.org/zzzeek/sqlalchemy/pull-requests/86
* Accommodate "callable" bound param in evaluatorMike Bayer2016-05-161-1/+13
| | | | | | | | | | Fixed bug in "evaluate" strategy of :meth:`.Query.update` and :meth:`.Query.delete` which would fail to accommodate a bound parameter with a "callable" value, as which occurs when filtering by a many-to-one equality expression along a relationship. Change-Id: I47758d3f5d8b9ea1a07e23166780d5f3c32b17f1 Fixes: #3700
* Fix formatting on test_evaluatorMike Bayer2016-05-161-10/+16
| | | | Change-Id: Idcd77a570b19f1b022a74d67fa8253d922dadc67
* Check for duplicate calls to register_attribute_implMike Bayer2016-05-101-0/+41
| | | | | | | | | | Fixed bug whereby the event listeners used for backrefs could be inadvertently applied multiple times, when using a deep class inheritance hierarchy in conjunction with mutiple mapper configuration steps. Change-Id: I712beaf4674e2323bf5b282922658020a6d00b53 Fixes: #3710
* Repair _orm_columns() to accommodate text()Mike Bayer2016-05-051-0/+19
| | | | | | | | | Fixed bug whereby passing a :func:`.text` construct to the :meth:`.Query.group_by` method would raise an error, instead of intepreting the object as a SQL fragment. Change-Id: I5fc2f590b76508d52e23b5fa9cf037ddea8080c3 fixes: #3706
* Merge "Deprecate Mapper.order_by"mike bayer2016-04-1913-54/+106
|\
| * Deprecate Mapper.order_byMike Bayer2016-04-1913-54/+106
| | | | | | | | | | | | | | | | | | | | | | This is an old parameter no longer relevant to how SQLAlchemy works, once the Query object was introduced. By deprecating it we establish that we aren't supporting non-working use cases and that we encourage applications to move off of the use of this parameter. Fixes: #3394 Change-Id: I25b9a38142a1537bbcb27d3e8b66a8b265140072
* | Rename Query._mapper_zero() to Query._entity_zero()Mike Bayer2016-04-192-6/+7
|/ | | | | | | | | | | | To be more descriptive of the use of _mapper_zero(), rename it to _entity_zero(), but also supply a new _mapper_zero() function that more strictly returns a mapper. The existing _entity_zero() function is renamed to _query_entity_zero. _only_mapper_zero() is removed as it isn't used. Divide up the existing calling functions to refer to the appropriate new method. Change-Id: I8780c3235e87b4936c6daf64d9d299b22b6e1260 Fixes: #3608
* Merge "Add raise/raiseload relationship loading strategy"mike bayer2016-04-191-0/+109
|\
| * Add raise/raiseload relationship loading strategyAdrian Moennich2016-04-191-0/+109
| | | | | | | | | | | | | | Fixes: #3512 Co-Authored-By: Mike Bayer <mike_mp@zzzcomputing.com> Change-Id: Ibd126c50eda621e2f4120ee378f7313af2d7ec3c Pull-request: https://github.com/zzzeek/sqlalchemy/pull/193
* | Honor hybrid property / method docstringsMike Bayer2016-04-181-5/+19
|/ | | | | | | | | | | | The docstring specified on a hybrid property or method is now honored at the class level, allowing it to work with tools like Sphinx autodoc. The mechanics here necessarily involve some wrapping of expressions to occur for hybrid properties, which may cause them to appear differently using introspection. Fixes: #3653 Change-Id: I02549977fe8b2a051802eed7b00cc532fbc214e3 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/239
* - don't load deferred columns on unexpire for merge with load=False,Diana Clarke2016-04-061-4/+100
| | | | | | | fixes #3488 Change-Id: Ic9577b800e4a4e2465ec7f3a2e95bd231f5337ee Co-Authored-By: Mike Bayer <mike_mp@zzzcomputing.com>
* - Added support for rendering "FULL OUTER JOIN" to both Core and ORM.Mike Bayer2016-03-281-0/+9
| | | | Pull request courtesy Stefan Urbanek. fixes #1957
* - oracle doesn't release savepointsMike Bayer2016-03-241-1/+1
|
* - Further continuing on the common MySQL exception case ofMike Bayer2016-03-231-2/+31
| | | | | | | | | a savepoint being cancelled first covered in :ticket:`2696`, the failure mode in which the :class:`.Session` is placed when a SAVEPOINT vanishes before rollback has been improved to allow the :class:`.Session` to still function outside of that savepoint. It is assumed that the savepoint operation failed and was cancelled. fixes #3680
* - Fixed bug where a newly inserted instance that is rolled backMike Bayer2016-03-141-1/+25
| | | | | | | | | would still potentially cause persistence conflicts on the next transaction, because the instance would not be checked that it was expired. This fix will resolve a large class of cases that erronously cause the "New instance with identity X conflicts with persistent instance Y" error. fixes #3677
* - skip GC tests here when coverage is enabled, seems to interfereMike Bayer2016-03-081-1/+1
|
* - Anonymous labeling is applied to a :attr:`.func` construct that isMike Bayer2016-02-261-1/+58
| | | | | | | | | passed to :func:`.column_property`, so that if the same attribute is referred to as a column expression twice the names are de-duped, thus avoiding "ambiguous column" errors. Previously, the ``.label(None)`` would need to be applied in order for the name to be de-anonymized. fixes #3663
* - An improvement to the workings of :meth:`.Query.correlate` suchMike Bayer2016-02-251-3/+72
| | | | | | | that when a "polymorphic" entity is used which represents a straight join of several tables, the statement will ensure that all the tables within the join are part of what's correlating. fixes #3662
* - reworked the way the "select_wraps_for" expression isMike Bayer2016-02-201-1/+17
| | | | | | | | | | | | | | | | | | | | | | | handled within visit_select(); this attribute was added in the 1.0 series to accommodate the subquery wrapping behavior of SQL Server and Oracle while also working with positional column targeting and no longer relying upon "key fallback" in order to target columns in such a statement. The IBM DB2 third-party dialect also has this use case, but its implementation is using regular expressions to rewrite the textual SELECT only and does not make use of a "wrapped" select at this time. The logic no longer attempts to reconcile proxy set collections as this was not deterministic, and instead assumes that the select() and the wrapper select() match their columns postionally, at least for the column positions they have in common, so it is now very simple and safe. fixes #3657. - as a side effect of #3657 it was also revealed that the strategy of calling upon a ResultProxy._getter was not correctly calling into NoSuchColumnError when an expected column was not present, and instead returned None up to loading.instances() to produce NoneType failures; added a raiseerr argument to _getter() which is called when we aren't expecting None, fixes #3658.
* - Fixed bug which would cause an eagerly loaded many-to-one attributeMike Bayer2016-02-171-2/+147
| | | | | | | | to not be loaded, if the joined eager load were from a row where the same entity were present multiple times, some calling for the attribute to be eagerly loaded and others not. The logic here is revised to take in the attribute even though a different loader path has handled the parent entity already. fixes #3431
* - Fixed bug in :meth:`.Session.merge` where an object with a compositeMike Bayer2016-02-111-1/+50
| | | | | | | | primary key that has values for some but not all of the PK fields would emit a SELECT statement leaking the internal NEVER_SET symbol into the query, rather than detecting that this object does not have a searchable primary key and no SELECT should be emitted. fixes #3647
* - A refinement to the logic which adds columns to the resulting SQL whenMike Bayer2016-02-091-7/+137
| | | | | | | | | | | | | :meth:`.Query.distinct` is combined with :meth:`.Query.order_by` such that columns which are already present will not be added a second time, even if they are labeled with a different name. Regardless of this change, the extra columns added to the SQL have never been returned in the final result, so this change only impacts the string form of the statement as well as its behavior when used in a Core execution context. Additionally, columns are no longer added when the DISTINCT ON format is used, provided the query is not wrapped inside a subquery due to joined eager loading. fixes #3641
* - revert the change first made in a6fe4dc, as we are now generalizingMike Bayer2016-01-281-3/+3
| | | | | | | | | | | | | | | | | | | | | | | the warning here to all safe_reraise() cases in Python 2. - Revisiting :ticket:`2696`, first released in 1.0.10, which attempts to work around Python 2's lack of exception context reporting by emitting a warning for an exception that was interrupted by a second exception when attempting to roll back the already-failed transaction; this issue continues to occur for MySQL backends in conjunction with a savepoint that gets unexpectedly lost, which then causes a "no such savepoint" error when the rollback is attempted, obscuring what the original condition was. The approach has been generalized to the Core "safe reraise" function which takes place across the ORM and Core in any place that a transaction is being rolled back in response to an error which occurred trying to commit, including the context managers provided by :class:`.Session` and :class:`.Connection`, and taking place for operations such as a failure on "RELEASE SAVEPOINT". Previously, the fix was only in place for a specific path within the ORM flush/commit process; it now takes place for all transational context managers as well. fixes #2696
* - use regex here, columns dont matter, keep coming up with different orderingsMike Bayer2016-01-231-3/+3
|
* - make this test deterministicMike Bayer2016-01-211-3/+3
|
* - Added new parameter :paramref:`.orm.mapper.passive_deletes` toMike Bayer2016-01-201-0/+236
| | | | | | | | available mapper options. This allows a DELETE to proceed for a joined-table inheritance mapping against the base table only, while allowing for ON DELETE CASCADE to handle deleting the row from the subclass tables. fixes #2349
* - Fixed issue where two same-named relationships that refer toMike Bayer2016-01-191-0/+39
| | | | | | | | a base class and a concrete-inherited subclass would raise an error if those relationships were set up using "backref", while setting up the identical configuration using relationship() instead with the conflicting names would succeed, as is allowed in the case of a concrete mapping. fixes #3630
* - The ``str()`` call for :class:`.Query` will now take into accountMike Bayer2016-01-191-2/+66
| | | | | | | | | | | | the :class:`.Engine` to which the :class:`.Session` is bound, when generating the string form of the SQL, so that the actual SQL that would be emitted to the database is shown, if possible. Previously, only the engine associated with the :class:`.MetaData` to which the mappings are associated would be used, if present. If no bind can be located either on the :class:`.Session` or on the :class:`.MetaData` to which the mappings are associated, then the "default" dialect is used to render the SQL, as was the case previously. fixes #3081
* - refactor a bit the loader options system to make it a bit moreMike Bayer2016-01-101-3/+125
| | | | | intelligible, given the fixes for ref #3623. unfortunately the system is still quite weird even though it was rewritten to be... less weird
* - Fixed regression since 0.9 where the 0.9 style loader optionsMike Bayer2016-01-091-0/+58
| | | | | | | system failed to accommodate for multiple :func:`.undefer_group` loader options in a single query. Multiple :func:`.undefer_group` options will now be taken into account even against the same entity. fixes #3623
* - varchar requires a lengthMike Bayer2015-12-221-1/+1
|
* - add the test from ref #3614 as well for testing ref #3611Mike Bayer2015-12-211-0/+60
|
* - Fixed regression caused in 1.0.10 by the fix for :ticket:`3593` whereMike Bayer2015-12-151-18/+99
| | | | | | | the check added for a polymorphic joinedload from a poly_subclass->class->poly_baseclass connection would fail for the scenario of class->poly_subclass->class. fixes #3611
* - Fixed bug where :meth:`.Session.bulk_update_mappings` and relatedMike Bayer2015-12-141-0/+37
| | | | | | | | would not bump a version id counter when in use. The experience here is still a little rough as the original version id is required in the given dictionaries and there's not clean error reporting on that yet. fixes #3610
* - Fixed bug in :meth:`.Update.return_defaults` which would cause allMike Bayer2015-12-142-4/+462
| | | | | | | | | | | | | | insert-default holding columns not otherwise included in the SET clause (such as primary key cols) to get rendered into the RETURNING even though this is an UPDATE. - Major fixes to the :paramref:`.Mapper.eager_defaults` flag, this flag would not be honored correctly in the case that multiple UPDATE statements were to be emitted, either as part of a flush or a bulk update operation. Additionally, RETURNING would be emitted unnecessarily within update statements. fixes #3609
* - Fixed bug where use of the :meth:`.Query.select_from` method wouldMike Bayer2015-12-121-0/+33
| | | | | | cause a subsequent call to the :meth:`.Query.with_parent` method to fail. fixes #3606 - add mark-as-fail test for #3607
* - The :meth:`.Session.merge` method now tracks pending objects byMike Bayer2015-12-041-0/+95
| | | | | | | | primary key before emitting an INSERT, and merges distinct objects with duplicate primary keys together as they are encountered, which is essentially semi-deterministic at best. This behavior matches what happens already with persistent objects. fixes #3601
* - Fixed issue where post_update on a many-to-one relationship wouldMike Bayer2015-12-021-1/+34
| | | | | | fail to emit an UPDATE in the case where the attribute were set to None and not previously loaded. fixes #3599
* Merge remote-tracking branch 'origin/pr/210'Mike Bayer2015-11-301-1/+2
|\
| * Update usages of getargspec to compat version.pr/210Jacob MacDonald2015-10-291-1/+2
| | | | | | | | | | The places inspect.getargspec was being used were causing problems for newer Python versions.
* | - Added support for parameter-ordered SET clauses in an UPDATEMike Bayer2015-11-282-7/+46
| | | | | | | | | | | | | | | | | | | | statement. This feature is available by passing the :paramref:`~.sqlalchemy.sql.expression.update.preserve_parameter_order` flag either to the core :class:`.Update` construct or alternatively adding it to the :paramref:`.Query.update.update_args` dictionary at the ORM-level, also passing the parameters themselves as a list of 2-tuples. Thanks to Gorka Eguileor for implementation and tests. adapted from pullreq github:200
* | - Fixed bug which is actually a regression that occurred betweenMike Bayer2015-11-251-1/+130
| | | | | | | | | | | | | | | | versions 0.8.0 and 0.8.1, due :ticket:`2714`. The case where joined eager loading needs to join out over a subclass-bound relationship when "with_polymorphic" were also used would fail to join from the correct entity. fixes #3593
* | - Fixed joinedload bug which would occur when a. the query includesMike Bayer2015-11-211-1/+110
| | | | | | | | | | | | | | | | | | | | | | | | limit/offset criteria that forces a subquery b. the relationship uses "secondary" c. the primaryjoin of the relationship refers to a column that is either not part of the primary key, or is a PK col in a joined-inheritance subclass table that is under a different attribute name than the parent table's primary key column d. the query defers the columns that are present in the primaryjoin, typically via not being included in load_only(); the necessary column(s) would not be present in the subquery and produce invalid SQL. fixes #3592
* | - don't create tables on compile-only testsMike Bayer2015-11-211-0/+2
| |
* | - try to get this to skip for oracleMike Bayer2015-11-201-1/+4
| |