summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
...
* - keep trying to identify the race here. can reproduce locallyMike Bayer2017-04-271-11/+11
| | | | | | now and it seems like mock might not be doing the right thing. Change-Id: I5c108d82631c9217da54a8ace68d7728c3e204d8
* Enforce boolean result type for all eq_, is_, isnot, comparisonMike Bayer2017-04-271-0/+10
| | | | | | | | | | | | Repaired issue where the type of an expression that used :meth:`.ColumnOperators.is_` or similar would not be a "boolean" type, instead the type would be "nulltype", as well as when using custom comparison operators against an untyped expression. This typing can impact how the expression behaves in larger contexts as well as in result-row-handling. Change-Id: Ib810ff686de500d8db26ae35a51005fab29603b6 Fixes: #3873
* - try to work around a race that can occur in STP whenMike Bayer2017-04-271-2/+11
| | | | | | used in this intentionally broken scenario Change-Id: I88ea6fa710da2189e6d47e2d12f5f0fd6f6bb7d4
* Add selectin loadingMike Bayer2017-04-265-4/+2105
| | | | | | | | | | Adding a new kind of relationship loader that is a cross between the "immediateload" and the "subquery" eager loader, using an IN criteria to load related items in bulk immediately after the lead query result is loaded. Change-Id: If13713fba9b465865aef8fd50b5b6b977fe3ef7d Fixes: #3944
* test / document postgresql_ops against a labeled expressionMike Bayer2017-04-241-0/+26
| | | | | | | | | | Since postgresql_ops explicitly states that it expects string keys, to apply to a function call or expression one needs to give the SQL expression a label that can be referred to by name in the dictionary. test / document this. Change-Id: I4bc4ade46dac27f9c1b92e7823433292beab97b9 Fixes: #3970
* Add _negate() to Label to negate inner elementMike Bayer2017-04-211-1/+15
| | | | | | | | | Fixed the negation of a :class:`.Label` construct so that the inner element is negated correctly, when the :func:`.not_` modifier is applied to the labeled expression. Change-Id: Ia99917b2959bdfbff28689c962b4203911c57b85 Fixes: #3969
* Accommodate for query._current_path in subq eager load join_depthMike Bayer2017-04-171-2/+35
| | | | | | | | | | Fixed bug in subquery eager loading where the "join_depth" parameter for self-referential relationships would not be correctly honored, loading all available levels deep rather than correctly counting the specified number of levels for eager loading. Change-Id: Ifa54085cbab3b41c2196f3ee519f485c63e4cb8d Fixes: #3967
* Merge "Use baked lazyloading by default"mike bayer2017-04-144-233/+598
|\
| * Use baked lazyloading by defaultMike Bayer2017-04-134-233/+598
| | | | | | | | | | | | | | | | | | | | | | | | | | The ``lazy="select"`` loader strategy now makes used of the :class:`.BakedQuery` query caching system in all cases. This removes most overhead of generating a :class:`.Query` object and running it into a :func:`.select` and then string SQL statement from the process of lazy-loading related collections and objects. The "baked" lazy loader has also been improved such that it can now cache in most cases where query load options are used. Change-Id: Ic96792fffaa045ae9aa0a4657d6d29235d3efb85 Fixes: #3954
* | Remove MySQL UTC_TIMESTAMP ruleMike Bayer2017-04-132-1/+87
|/ | | | | | | | | Removed an ancient and unnecessary intercept of the UTC_TIMESTAMP MySQL function, which was getting in the way of using it with a parameter. Change-Id: I6e6b52c051418bcb9d31987e78299310810cb78d Fixes: #3966
* - try one more test, then we're likely going to give up on cx_OracleMike Bayer2017-04-121-29/+30
| | | | Change-Id: I7f9a1265664b0368ee7a771d01c7ca1612156d1f
* - move a few memusage tests out of "backend". something is up w/ cx_OracleMike Bayer2017-04-121-30/+35
| | | | | | | when the suite runs, such as a background thread or something like that, which is affecting these tests a bit. Change-Id: I52d50a44778ec1eecb8e335ae59b1a4773e80a79
* Warn on _compiled_cache growthMike Bayer2017-04-122-29/+50
| | | | | | | | | | | | | | | | | Added warnings to the LRU "compiled cache" used by the :class:`.Mapper` (and ultimately will be for other ORM-based LRU caches) such that when the cache starts hitting its size limits, the application will emit a warning that this is a performance-degrading situation that may require attention. The LRU caches can reach their size limits primarily if an application is making use of an unbounded number of :class:`.Engine` objects, which is an antipattern. Otherwise, this may suggest an issue that should be brought to the SQLAlchemy developer's attention. Additionally, adjusted the test_memusage algorithm again as the previous one could still allow a growing memory size to be missed. Change-Id: I020d1ceafb7a08f6addfa990a1e7acd09f933240
* Set up base ARRAY to be compatible with postgresql.ARRAY.Mike Bayer2017-04-111-99/+132
| | | | | | | | | | For some reason, when ARRAY was added to the base it was never linked to postgresql.ARRAY. Link the two types and also make base ARRAY the schema event target so that it supports the same features as postgresql.ARRAY. Change-Id: I82fa6c9d2b8c5028dba3a009715f7bc296b2bc0b Fixes: #3964
* Merge "Compare entities also on chop_path"mike bayer2017-04-102-0/+207
|\
| * Compare entities also on chop_pathMike Bayer2017-04-102-0/+207
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When comparing query._current_path to options, the path chop was not taking into account that the query or the options are against aliased classes that don't match the mapper. The issue does not seem to take place for the Load() version of _chop_path. Fixed bug to improve upon the specificity of loader options that take effect subsequent to the lazy load of a related entity, so that the loader options will match to an aliased or non-aliased entity more specifically if those options include entity information. Fixes: #3963 Change-Id: Ifdff37d579042fcc62bdeabce9e2413e9a03fbba
* | Add new "expanding" feature to bindparam()Mike Bayer2017-04-074-5/+91
|/ | | | | | | | | | | | | | | | Added a new kind of :func:`.bindparam` called "expanding". This is for use in ``IN`` expressions where the list of elements is rendered into individual bound parameters at statement execution time, rather than at statement compilation time. This allows both a single bound parameter name to be linked to an IN expression of multiple elements, as well as allows query caching to be used with IN expressions. The new feature allows the related features of "select in" loading and "polymorphic in" loading to make use of the baked query extension to reduce call overhead. This feature should be considered to be **experimental** for 1.2. Fixes: #3953 Change-Id: Ie708414a3ab9c0af29998a2c7f239ff7633b1f6e
* Consider mysql partition options separately from other table optionsMike Bayer2017-04-061-0/+37
| | | | | | | | | Move down all the PARTITION, SUBPARTITION options into a separate segment so that they come out at the end of CREATE TABLE after the table options. Change-Id: Iaa1c823848c93680ca22d72bda1b7c49742b9060 Fixes: #3961
* Support Postgresql INTERVAL fields spec/reflectionMike Bayer2017-04-051-1/+59
| | | | | | | | | | | | | Added support for all possible "fields" identifiers when reflecting the Postgresql ``INTERVAL`` datatype, e.g. "YEAR", "MONTH", "DAY TO MINUTE", etc.. In addition, the :class:`.postgresql.INTERVAL` datatype itself now includes a new parameter :paramref:`.postgresql.INTERVAL.fields` where these qualifiers can be specified; the qualifier is also reflected back into the resulting datatype upon reflection / inspection. Change-Id: I33816e68c533b023e0632db6f4e73fefd2de4721 Fixes: #3959
* Merge "Double percent signs based on paramstyle, not dialect"mike bayer2017-04-053-30/+43
|\
| * Double percent signs based on paramstyle, not dialectMike Bayer2017-04-053-30/+43
| | | | | | | | | | | | | | | | | | | | | | | | This patch moves the "doubling" of percent signs into the base compiler and makes it completely a product of whether or not the paramstyle is format/pyformat or not. Without this paramstyle, percent signs are not doubled across text(), literal_column(), and column(). Change-Id: Ie2f278ab1dbb94b5078f85c0096d74dbfa049197 Fixes: #3740
* | Recognize brackets, quoted_name in SQL Server schemaMike Bayer2017-04-041-7/+95
|/ | | | | | | | | | | | | The SQL Server dialect now allows for a database and/or owner name with a dot inside of it, using brackets explicitly in the string around the owner and optionally the database name as well. In addition, sending the :class:`.quoted_name` construct for the schema name will not split on the dot and will deliver the full string as the "owner". :class:`.quoted_name` is also now available from the ``sqlalchemy.sql`` import space. Change-Id: I77491d63ce47638bd23787d903ccde2f35a9d43d Fixes: #2626
* Merge "Apply SQL compilation to sqltext for column-level CHECK constraint"mike bayer2017-04-041-0/+13
|\
| * Apply SQL compilation to sqltext for column-level CHECK constraintMike Bayer2017-04-041-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | Fixed bug where a column-level :class:`.CheckConstraint` would fail to compile the SQL expression using the underlying dialect compiler as well as apply proper flags to generate literal values as inline, in the case that the sqltext is a Core expression and not just a plain string. This was long-ago fixed for table-level check constraints in 0.9 as part of :ticket:`2742`, which more commonly feature Core SQL expressions as opposed to plain string expressions. Change-Id: I1301ba4b40063e91bc47726aecc5f4990ffcaeda Fixes: #3957
* | Ensure we check that SQL expression has an .info attributeMike Bayer2017-04-041-2/+4
|/ | | | | | | | | | Fixed regression released in 1.1.8 due to :ticket:`3950` where the deeper search for information about column types in the case of a "schema type" or a :class:`.TypeDecorator` would produce an attribute error if the mapping also contained a :obj:`.column_property`. Change-Id: I38254834d3d79c9b339289a8163eb4789ec4c931 Fixes: #3956
* ResultProxy won't autoclose connection until state flag is setMike Bayer2017-04-032-0/+73
| | | | | | | | | | | | | | Changed the mechanics of :class:`.ResultProxy` to unconditionally delay the "autoclose" step until the :class:`.Connection` is done with the object; in the case where Postgresql ON CONFLICT with RETURNING returns no rows, autoclose was occurring in this previously non-existent use case, causing the usual autocommit behavior that occurs unconditionally upon INSERT/UPDATE/DELETE to fail. Change-Id: I235a25daf4381b31f523331f810ea04450349722 Fixes: #3955 (cherry picked from commit 8ee363e4917b0dcd64a83b6d26e465c9e61e0ea5) (cherry picked from commit f52fb5282a046d26b6ee2778e03b995eb117c2ee)
* Merge "Use consistent method signature for Alias.self_group()"mike bayer2017-04-031-0/+14
|\
| * Use consistent method signature for Alias.self_group()Mike Bayer2017-04-031-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | Fixed bug where the use of an :class:`.Alias` object in a column context would raise an argument error when it tried to group itself into a parenthesized expression. Using :class:`.Alias` in this way is not yet a fully supported API, however it applies to some end-user recipes and may have a more prominent role in support of some future Postgresql features. Change-Id: I81717e30416e0350f08d1e022c3d84656e0a9735 Fixes: #3939
* | Return self when Variant.coerce_compared_value would return implMike Bayer2017-04-011-2/+72
|/ | | | | | | | | | | | | Fixed regression released in 1.1.5 due to :ticket:`3859` where adjustments to the "right-hand-side" evaluation of an expression based on :class:`.Variant` to honor the underlying type's "right-hand-side" rules caused the :class:`.Variant` type to be inappropriately lost, in those cases when we *do* want the left-hand side type to be transferred directly to the right hand side so that bind-level rules can be applied to the expression's argument. Change-Id: Ia54dbbb19398549d654b74668753c4152599d900 Fixes: #3952
* Track SchemaEventTarget types in as_mutable()Mike Bayer2017-03-301-0/+43
| | | | | | | | | | | | | | Fixed bug in :mod:`sqlalchemy.ext.mutable` where the :meth:`.Mutable.as_mutable` method would not track a type that had been copied using :meth:`.TypeEngine.copy`. This became more of a regression in 1.1 compared to 1.0 because the :class:`.TypeDecorator` class is now a subclass of :class:`.SchemaEventTarget`, which among other things indicates to the parent :class:`.Column` that the type should be copied when the :class:`.Column` is. These copies are common when using declarative with mixins or abstract classes. Change-Id: Ib04df862c58263185dbae686c548fea3e12c46f1 Fixes: #3950
* Apply type processing to untyped preexec default clauseMike Bayer2017-03-302-61/+53
| | | | | | | | | | | | | | | | Fixed bug where a SQL-oriented Python-side column default could fail to be executed properly upon INSERT in the "pre-execute" codepath, if the SQL itself were an untyped expression, such as plain text. The "pre- execute" codepath is fairly uncommon however can apply to non-integer primary key columns with SQL defaults when RETURNING is not used. Tests exist here to ensure typing is applied to a typed expression for default, but in the case of an untyped SQL value, we know the type from the column, so apply this. Change-Id: I5d8b391611c137b9f700115a50a2bf5b30abfe94 Fixes: #3923
* Add bindparams support for baked Result count() methodMalaclypse The Younger2017-03-301-0/+28
| | | | | | | | | | Added support for bound parameters, e.g. those normally set up via :meth:`.Query.params`, to the :meth:`.baked.Result.count` method. Previously, support for parameters were omitted. Pull request courtesy Pat Deegan. Change-Id: I8c33548cf2a483699767e459731694c8cadebff6 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/350
* Support Postgresql development version numbersSean McCully2017-03-291-1/+4
| | | | | | | | | Added support for parsing the Postgresql version string for a development version like "PostgreSQL 10devel". Pull request courtesy Sean McCully. Change-Id: I7bc18bc4d290349c23e9796367b7d694d0873096 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/351
* Allow aliased() to be passed to Query.select_entity_from().Mike Bayer2017-03-271-0/+25
| | | | | | | | | | | | | | | | | An :func:`.aliased()` construct can now be passed to the :meth:`.Query.select_entity_from` method. Entities will be pulled from the selectable represented by the :func:`.aliased` construct. This allows special options for :func:`.aliased` such as :paramref:`.aliased.adapt_on_names` to be used in conjunction with :meth:`.Query.select_entity_from`. Additionally rewrote the docstring for :meth:`.Query.select_entity_from`, including starting with explicit use of :func:`.aliased` as the usual idiomatic pattern. An example using text().columns() is added as well as the use case from :ticket:`3933` using name matching. Change-Id: If7e182965236993064a2a086e3b6d55a4f097ca8 Fixes: #3933
* Add safe_reraise() + warnings only to Connection._autorollbackMike Bayer2017-03-272-21/+62
| | | | | | | | | | | | Added an exception handler that will warn for the "cause" exception on Py2K when the "autorollback" feature of :class:`.Connection` itself raises an exception. In Py3K, the two exceptions are naturally reported by the interpreter as one occurring during the handling of the other. This is continuing with the series of changes for rollback failure handling that were last visited as part of :ticket:`2696` in 1.0.12. Change-Id: I600ba455a14ebaea27c6189889181f97c632f179 Fixes: #3946
* Treat collation names as identifiersMike Bayer2017-03-233-10/+27
| | | | | | | | | | | The expression used for COLLATE as rendered by the column-level :func:`.expression.collate` and :meth:`.ColumnOperators.collate` is now quoted as an identifier when the name is case sensitive, e.g. has uppercase characters. Note that this does not impact type-level collation, which is already quoted. Change-Id: I83d5d9cd1e66a4f20b96303bb84c5f360d5d6a1a Fixes: #3785
* Support hybrids/composites with bulk updatesMike Bayer2017-03-223-20/+213
| | | | | | | | | | | The :meth:`.Query.update` method can now accommodate both hybrid attributes as well as composite attributes as a source of the key to be placed in the SET clause. For hybrids, an additional decorator :meth:`.hybrid_property.update_expression` is supplied for which the user supplies a tuple-returning function. Change-Id: I15e97b02381d553f30b3301308155e19128d2cfb Fixes: #3229
* Raise on flag_modified() for non-present attributeMike Bayer2017-03-211-1/+38
| | | | | | | | | | | | The :func:`.attributes.flag_modified` function now raises :class:`.InvalidRequestError` if the named attribute key is not present within the object, as this is assumed to be present in the flush process. To mark an object "dirty" for a flush without referring to any specific attribute, the :func:`.attributes.flag_dirty` function may be used. Change-Id: I6c64e4d253c239e38632f38c27bb16e68fe8dfbe Fixes: #3753
* Allow reuse of hybrid_property across subclassesDiana Clarke2017-03-211-0/+113
| | | | | | | | | | | | | | The :class:`sqlalchemy.ext.hybrid.hybrid_property` class now supports calling mutators like ``@setter``, ``@expression`` etc. multiple times across subclasses, and now provides a ``@getter`` mutator, so that a particular hybrid can be repurposed across subclasses or other classes. This now matches the behavior of ``@property`` in standard Python. Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Fixes: #3911 Fixes: #3912 Change-Id: Iff033d8ccaae20ded9289cbfa789c376759381f5
* Integrate "pre-ping" into connection pool.Mike Bayer2017-03-201-2/+147
| | | | | | | | | | | | | | | Added native "pessimistic disconnection" handling to the :class:`.Pool` object. The new parameter :paramref:`.Pool.pre_ping`, available from the engine as :paramref:`.create_engine.pool_pre_ping`, applies an efficient form of the "pre-ping" recipe featured in the pooling documentation, which upon each connection check out, emits a simple statement, typically "SELECT 1", to test the connection for liveness. If the existing connection is no longer able to respond to commands, the connection is transparently recycled, and all other connections made prior to the current timestamp are invalidated. Change-Id: I89700d0075e60abd2250e54b9bd14daf03c71c00 Fixes: #3919
* Merge branch 'master' of https://bitbucket.org/jalessio/sqlalchemyMike Bayer2017-03-181-1/+1
|\
| * Fix typos ('expicit' -> 'explicit')Jamie Alessio2017-03-141-1/+1
| |
* | Merge "Implement comments for tables, columns"mike bayer2017-03-174-2/+47
|\ \
| * | Implement comments for tables, columnsFrazer McLean2017-03-174-2/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added support for SQL comments on :class:`.Table` and :class:`.Column` objects, via the new :paramref:`.Table.comment` and :paramref:`.Column.comment` arguments. The comments are included as part of DDL on table creation, either inline or via an appropriate ALTER statement, and are also reflected back within table reflection, as well as via the :class:`.Inspector`. Supported backends currently include MySQL, Postgresql, and Oracle. Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Fixes: #1546 Change-Id: Ib90683850805a2b4ee198e420dc294f32f15d35d
* | | Add bulk_replace event, integrate with @validatesMike Bayer2017-03-161-0/+37
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added new attribute event :meth:`.AttributeEvents.bulk_replace`. This event is triggered when a collection is assigned to a relationship, before the incoming collection is compared with the existing one. This early event allows for conversion of incoming non-ORM objects as well. The event is integrated with the ``@validates`` decorator. The ``@validates`` decorator now allows the decorated method to receive objects from a "bulk collection set" operation that have not yet been compared to the existing collection. This allows incoming values to be converted to compatible ORM objects as is already allowed from an "append" event. Note that this means that the ``@validates`` method is called for **all** values during a collection assignment, rather than just the ones that are new. Change-Id: I27f59db008d9e521d31a3e30143d7cd997e4b7b3 Fixes: #3896
* | Annotate parentmapper in primaryjoin / secondaryjoinMike Bayer2017-03-161-0/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch applies the "parentmapper" annotation to the columns in the primaryjoin/secondaryjoin, but more dramatically, also removes all the "deannotate" steps that were historically applied to the relationship primaryjoin/secondaryjoin. These deannotation steps were left over from the initial implementations of annotations where the behaviors were not as reliable. By ensuring these annotations are present, the evaluator no longer needs to do a name-based lookup when it sees a column that has no "parentmapper", because it can be assured this is not a mapped column. This fixes the issue where the expression were based on a relationship primaryjoin but the name of a column in the join condition didn't match the attribute name. Change-Id: I8c1d4594116d4109fef314a87c96a24d2efa0058 Fixes: #3366
* | Don't mutate old collection on bulk replaceMike Bayer2017-03-152-6/+13
| | | | | | | | | | | | | | | | | | | | | | | | For a bulk replace, assume the old collection is no longer useful to the attribute system and only send the removal events, not actually mutated the collection. this changes behavior significantly and also means that dispose_collection now receives the old collection intact. Change-Id: Ic2685c85438191f07797d9ef97833a2cfdc4fcc2 Fixes: #3913
* | Merge "Consult _select_from_entity in _adjust_for_single_inheritance"mike bayer2017-03-151-5/+20
|\ \
| * | Consult _select_from_entity in _adjust_for_single_inheritanceMike Bayer2017-03-141-5/+20
| |/ | | | | | | | | | | | | | | | | | | Fixed bug in single-table inheritance where the select_from() argument would not be taken into account when limiting rows to a subclass. Previously, only expressions in the columns requested would be taken into account. Change-Id: Id353c45eade52b264d8f6685a58ba53975669eea Fixes: #3891
* | Consult compiled paramstyle on execute_compiledMike Bayer2017-03-151-0/+30
|/ | | | | | | | | | | | Fixed bug where in the unusual case of passing a :class:`.Compiled` object directly to :meth:`.Connection.execute`, the dialect with which the :class:`.Compiled` object were generated was not consulted for the paramstyle of the string statement, instead assuming it would match the dialect-level paramstyle, causing mismatches to occur. Change-Id: I114e4db2183fbb75bb7c0b0641f5a161855696ee Fixes: #3938