summaryrefslogtreecommitdiff
path: root/test/orm
Commit message (Collapse)AuthorAgeFilesLines
* - and re-adjust this test now that we only cover one levelMike Bayer2016-02-181-3/+2
| | | | deep of __clause_element__()....
* - additional test adjustments. need to review carefully theMike Bayer2016-02-181-5/+11
| | | | impact of these behavioral changes
* - 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
| |
* | - A rare case which occurs when a :meth:`.Session.rollback` fails in theMike Bayer2015-11-191-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | scope of a :meth:`.Session.flush` operation that's raising an exception, as has been observed in some MySQL SAVEPOINT cases, prevents the original database exception from being observed when it was emitted during flush, but only on Py2K because Py2K does not support exception chaining; on Py3K the originating exception is chained. As a workaround, a warning is emitted in this specific case showing at least the string message of the original database error before we proceed to raise the rollback-originating exception. fixes #2696
* | - Fixed bug where the "single table inheritance" criteria would beMike Bayer2015-11-111-0/+15
|/ | | | | | | added onto the end of a query in some inappropriate situations, such as when querying from an exists() of a single-inheritance subclass. fixes #3582
* - use is_() here to more clearly show what's going wrongMike Bayer2015-10-191-13/+25
| | | | on occasional pypy test runs
* - Fixed regression in 1.0 where new feature of using "executemany"Mike Bayer2015-10-191-0/+88
| | | | | | | | | for UPDATE statements in the ORM (e.g. :ref:`feature_updatemany`) would break on Postgresql and other RETURNING backends when using server-side version generation schemes, as the server side value is retrieved via RETURNING which is not supported with executemany. fixes #3556
* Merge remote-tracking branch 'origin/pr/203'Mike Bayer2015-10-091-2/+6
|\
| * Remplement Query.one() in terms of .one_or_none()pr/203Eric Siegerman2015-09-281-2/+6
| | | | | | Thanks to Mike Bayer for suggesting a simpler refactoring.
* | - The system by which a :class:`.Column` considers itself to be anMike Bayer2015-10-074-12/+7
|/ | | | | | | | | | | | | | | | | "auto increment" column has been changed, such that autoincrement is no longer implicitly enabled for a :class:`.Table` that has a composite primary key. In order to accommodate being able to enable autoincrement for a composite PK member column while at the same time maintaining SQLAlchemy's long standing behavior of enabling implicit autoincrement for a single integer primary key, a third state has been added to the :paramref:`.Column.autoincrement` parameter ``"auto"``, which is now the default. fixes #3216 - The MySQL dialect no longer generates an extra "KEY" directive when generating CREATE TABLE DDL for a table using InnoDB with a composite primary key with AUTO_INCREMENT on a column that isn't the first column; to overcome InnoDB's limitation here, the PRIMARY KEY constraint is now generated with the AUTO_INCREMENT column placed first in the list of columns.
* Add Query.one_or_none()pr/201Eric Siegerman2015-09-241-0/+54
|
* - Fixed rare TypeError which could occur when stringifying certainMike Bayer2015-09-231-1/+11
| | | | | kinds of internal column loader options within internal logging. fixes #3539
* - Added a new type-level modifier :meth:`.TypeEngine.evaluates_none`Mike Bayer2015-09-191-1/+46
| | | | | | | | | | | | | which indicates to the ORM that a positive set of None should be persisted as the value NULL, instead of omitting the column from the INSERT statement. This feature is used both as part of the implementation for :ticket:`3514` as well as a standalone feature available on any type. fixes #3250 - add new documentation section illustrating the "how to force null" use case of #3250 - alter our change from #3514 so that the class-level flag is now called "should_evaluate_none"; so that "evaluates_none" is now a generative method.
* - fixes for the ORM side test for #3531.Mike Bayer2015-09-171-3/+6
|
* - The :func:`.type_coerce` construct is now a fully fledged CoreMike Bayer2015-09-161-0/+72
| | | | | | | | | | | expression element which is late-evaluated at compile time. Previously, the function was only a conversion function which would handle different expression inputs by returning either a :class:`.Label` of a column-oriented expression or a copy of a given :class:`.BindParameter` object, which in particular prevented the operation from being logically maintained when an ORM-level expression transformation would convert a column to a bound parameter (e.g. for lazy loading). fixes #3531
* - Internal calls to "bookkeeping" functions withinMike Bayer2015-09-081-2/+3
| | | | | | | | :meth:`.Session.bulk_save_objects` and related bulk methods have been scaled back to the extent that this functionality is not currently used, e.g. checks for column default values to be fetched after an INSERT or UPDATE statement. fixes #3526
* - Fixed bug in :meth:`.Session.bulk_save_objects` where a mappedMike Bayer2015-09-081-1/+53
| | | | | | | column that had some kind of "fetch on update" value and was not locally present in the given object would cause an AttributeError within the operation. fixes #3525
* - The :class:`.SessionEvents` suite now includes events to allowticket_2677Mike Bayer2015-09-025-23/+597
| | | | | | | | | | | | | | | | | | | | | unambiguous tracking of all object lifecycle state transitions in terms of the :class:`.Session` itself, e.g. pending, transient, persistent, detached. The state of the object within each event is also defined. fixes #2677 - Added a new session lifecycle state :term:`deleted`. This new state represents an object that has been deleted from the :term:`persistent` state and will move to the :term:`detached` state once the transaction is committed. This resolves the long-standing issue that objects which were deleted existed in a gray area between persistent and detached. The :attr:`.InstanceState.persistent` accessor will **no longer** report on a deleted object as persistent; the :attr:`.InstanceState.deleted` accessor will instead be True for these objects, until they become detached. - The :paramref:`.Session.weak_identity_map` parameter is deprecated. See the new recipe at :ref:`session_referencing_behavior` for an event-based approach to maintaining strong identity map behavior. references #3517
* - Added new checks for the common error case of passing mapped classesMike Bayer2015-08-221-0/+36
| | | | | | or mapped instances into contexts where they are interpreted as SQL bound parameters; a new exception is raised for this. fixes #3321
* - merge of ticket_3514 None-handling branchMike Bayer2015-08-171-0/+166
| | | | | | | | | | | | | | | | - Fixes to the ORM and to the postgresql JSON type regarding the ``None`` constant in conjunction with the Postgresql :class:`.JSON` type. When the :paramref:`.JSON.none_as_null` flag is left at its default value of ``False``, the ORM will now correctly insert the Json "'null'" string into the column whenever the value on the ORM object is set to the value ``None`` or when the value ``None`` is used with :meth:`.Session.bulk_insert_mappings`, **including** if the column has a default or server default on it. This makes use of a new type-level flag "evaluates_none" which is implemented by the JSON type based on the none_as_null flag. fixes #3514 - Added a new constant :attr:`.postgresql.JSON.NULL`, indicating that the JSON NULL value should be used for a value regardless of other settings. part of fixes #3514
* - merge of ticket_3499 indexed access branchMike Bayer2015-08-172-7/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - The "hashable" flag on special datatypes such as :class:`.postgresql.ARRAY`, :class:`.postgresql.JSON` and :class:`.postgresql.HSTORE` is now set to False, which allows these types to be fetchable in ORM queries that include entities within the row. fixes #3499 - The Postgresql :class:`.postgresql.ARRAY` type now supports multidimensional indexed access, e.g. expressions such as ``somecol[5][6]`` without any need for explicit casts or type coercions, provided that the :paramref:`.postgresql.ARRAY.dimensions` parameter is set to the desired number of dimensions. fixes #3487 - The return type for the :class:`.postgresql.JSON` and :class:`.postgresql.JSONB` when using indexed access has been fixed to work like Postgresql itself, and returns an expression that itself is of type :class:`.postgresql.JSON` or :class:`.postgresql.JSONB`. Previously, the accessor would return :class:`.NullType` which disallowed subsequent JSON-like operators to be used. part of fixes #3503 - The :class:`.postgresql.JSON`, :class:`.postgresql.JSONB` and :class:`.postgresql.HSTORE` datatypes now allow full control over the return type from an indexed textual access operation, either ``column[someindex].astext`` for a JSON type or ``column[someindex]`` for an HSTORE type, via the :paramref:`.postgresql.JSON.astext_type` and :paramref:`.postgresql.HSTORE.text_type` parameters. also part of fixes #3503 - The :attr:`.postgresql.JSON.Comparator.astext` modifier no longer calls upon :meth:`.ColumnElement.cast` implicitly, as PG's JSON/JSONB types allow cross-casting between each other as well. Code that makes use of :meth:`.ColumnElement.cast` on JSON indexed access, e.g. ``col[someindex].cast(Integer)``, will need to be changed to call :attr:`.postgresql.JSON.Comparator.astext` explicitly. This is part of the refactor in references #3503 for consistency in operator use.
* - add tests for InstanceEvents.init, InstanceEvents.init_failureMike Bayer2015-08-141-0/+37
| | | | | | | - ensure that kwargs can be modified in-place within InstanceEvents.init and that these take effect for the __init__ method. - improve documentation for these and related events, including that kwargs can be modified in-place.
* - Fixed 1.0 regression where the "noload" loader strategy would failMike Bayer2015-08-111-0/+18
| | | | | | | | | to function for a many-to-one relationship. The loader used an API to place "None" into the dictionary which no longer actually writes a value; this is a side effect of :ticket:`3061`. - remove InstanceState._initialize() totally, it's used nowhere else and no longer does what it says it does - fill in fowards-port version ids throughout the changes for 1.0.9
* - pep8 test/orm/test_mapperMike Bayer2015-08-111-536/+698
|
* - increase the varchar hereMike Bayer2015-07-011-1/+1
|