summaryrefslogtreecommitdiff
path: root/test/sql
Commit message (Collapse)AuthorAgeFilesLines
* fix ORM support for column-named bindparam() in crud .values()Mike Bayer2023-01-113-2/+186
| | | | | | | | | | | | | | | | | | | | | | | Fixed bug / regression where using :func:`.bindparam()` with the same name as a column in the :meth:`.Update.values` method of :class:`.Update`, as well as the :meth:`.Insert.values` method of :class:`.Insert` in 2.0 only, would in some cases silently fail to honor the SQL expression in which the parameter were presented, replacing the expression with a new parameter of the same name and discarding any other elements of the SQL expression, such as SQL functions, etc. The specific case would be statements that were constructed against ORM entities rather than plain :class:`.Table` instances, but would occur if the statement were invoked with a :class:`.Session` or a :class:`.Connection`. :class:`.Update` part of the issue was present in both 2.0 and 1.4 and is backported to 1.4. For 1.4, also backports the sqlalchemy.testing.Variation update to the variation() API. Fixes: #9075 Change-Id: Ie954bc1f492ec6a566163588182ef4910c7ee452 (cherry picked from commit b5b864e0fe50243a94c0ef04fddda6fa446c1524)
* ensure whereclause, returning copied as tuplesMike Bayer2022-12-281-1/+39
| | | | | | | | | | | Fixed issue in the internal SQL traversal for DML statements like :class:`_dml.Update` and :class:`_dml.Delete` which would cause among other potential issues, a specific issue using lambda statements with the ORM update/delete feature. Fixes: #9033 Change-Id: I76428049cb767ba302fbea89555114bf63ab8687 (cherry picked from commit e68173bf7d296b2948abed06f79c7cbd0ab66b0d)
* pass more contextual information to PyWrapper param createMike Bayer2022-12-271-0/+102
| | | | | | | | | | | Fixed issue in lambda SQL feature where the calculated type of a literal value would not take into account the type coercion rules of the "compared to type", leading to a lack of typing information for SQL expressions, such as comparisons to :class:`.JSON` elements and similar. Fixes: #9029 Change-Id: I381c8d7458d98ba762313dee9ec47a9c1881f74a (cherry picked from commit f63d7e33ec785a5ea4fbc77963c537be26b8419b)
* add joins_implicitly to column_valued()Mike Bayer2022-12-201-17/+37
| | | | | | | | | | | | | | Added parameter :paramref:`.FunctionElement.column_valued.joins_implicitly`, which is useful in preventing the "cartesian product" warning when making use of table-valued or column-valued functions. This parameter was already introduced for :meth:`.FunctionElement.table_valued` in :ticket:`7845`, however it failed to be added for :meth:`.FunctionElement.column_valued` as well. Fixes: #9009 Change-Id: Ifb72fbcb4f4d2998e730d6f85ec7280df3bf3d47 (cherry picked from commit 567878e5c67d08c561dd064fe6dc25e4db7349e7)
* implement literal_binds with expanding + bind_expressionMike Bayer2022-12-151-18/+30
| | | | | | | | | | | | Fixed bug where SQL compilation would fail (assertion fail in 2.0, NoneType error in 1.4) when using an expression whose type included :meth:`_types.TypeEngine.bind_expression`, in the context of an "expanding" (i.e. "IN") parameter in conjunction with the ``literal_binds`` compiler parameter. Fixes: #8989 Change-Id: Ic9fd27b46381b488117295ea5a492d8fc158e39f (cherry picked from commit 8c6de3c2c43ab372cbbe76464b4c5be3b6457252)
* look out for extras=None in freezeMike Bayer2022-12-091-0/+46
| | | | | | | | | | Fixed issue where :meth:`_engine.Result.freeze` method would not work for textual SQL using either :func:`_sql.text` or :meth:`_engine.Connection.exec_driver_sql`. Fixes: #8963 Change-Id: Ia131c6ac41a4adf32eb1bf1abf23930ef395f16c (cherry picked from commit 44170aee47a021883c6244f702de2e4385a5cd1d)
* Fix positional compiling bugsFederico Caselli2022-12-014-25/+363
| | | | | | | | | | | | Fixed a series of issues regarding positionally rendered bound parameters, such as those used for SQLite, asyncpg, MySQL and others. Some compiled forms would not maintain the order of parameters correctly, such as the PostgreSQL ``regexp_replace()`` function as well as within the "nesting" feature of the :class:`.CTE` construct first introduced in :ticket:`4123`. Fixes: #8827 Change-Id: I9813ed7c358cc5c1e26725c48df546b209a442cb (cherry picked from commit 0f2baae6bf72353f785bad394684f2d6fa53e0ef)
* Merge "avoid putting annotated columns in sets" into rel_1_4mike bayer2022-11-261-2/+2
|\
| * avoid putting annotated columns in setsMike Bayer2022-11-141-2/+2
| | | | | | | | | | | | | | | | | | | | backporting a small bit of the changes made for the 2.0 version of #8796. See if the changes apply cleanly to the 1.4 branch. Fixes: #8796 Change-Id: I8118511a10beb38c545a55c962a18a77611293af
* | add informative exception context for literal renderMike Bayer2022-11-143-4/+52
|/ | | | | | | | | | | An informative re-raise is now thrown in the case where any "literal bindparam" render operation fails, indicating the value itself and the datatype in use, to assist in debugging when literal params are being rendered in a statement. Fixes: #8800 Change-Id: Id658f8b03359312353ddbb0c7563026239579f7b (cherry picked from commit c7baf6e0aa624c9378c3bc3c4923d1e188d62dc9)
* establish consistency for RETURNING column labelsMike Bayer2022-11-112-1/+144
| | | | | | | | | | | | | | | | | | | | | | For the PostgreSQL and SQL Server dialects only, adjusted the compiler so that when rendering column expressions in the RETURNING clause, the "non anon" label that's used in SELECT statements is suggested for SQL expression elements that generate a label; the primary example is a SQL function that may be emitting as part of the column's type, where the label name should match the column's name by default. This restores a not-well defined behavior that had changed in version 1.4.21 due to :ticket:`6718`, :ticket:`6710`. The Oracle dialect has a different RETURNING implementation and was not affected by this issue. Version 2.0 features an across the board change for its widely expanded support of RETURNING on other backends. Fixed issue in the Oracle dialect where an INSERT statement that used ``insert(some_table).values(...).returning(some_table)`` against a full :class:`.Table` object at once would fail to execute, raising an exception. Fixes: #8770 Change-Id: I2ab078a214a778ffe1720dbd864ae4c105a0691d (cherry picked from commit c8a7b67181d31634355150fc0379ec0e780ff728)
* soft close cursor for Query direct iterator interruptedMike Bayer2022-11-031-0/+106
| | | | | | | | | | | | | | | | | | | | | | | | Fixed issue where the underlying DBAPI cursor would not be closed when using :class:`_orm.Query` and direct iteration, if a user-defined exception case were raised within the iteration process, interrupting the iterator which otherwise is not possible to re-use in this context. When using :meth:`_orm.Query.yield_per` to create server-side cursors, this would lead to the usual MySQL-related issues with server side cursors out of sync. To resolve, a catch for ``GeneratorExit`` is applied within the default iterator, which applies only in those cases where the interpreter is calling ``.close()`` on the iterator in any case. A similar scenario can occur when using :term:`2.x` executions with direct use of :class:`.Result`, in that case the end-user code has access to the :class:`.Result` itself and should call :meth:`.Result.close` directly. Version 2.0 will feature context-manager calling patterns to address this use case. However within the 1.4 scope, ensured that ``.close()`` methods are available on all :class:`.Result` implementations including :class:`.ScalarResult`, :class:`.MappingResult`. Fixes: #8710 Change-Id: I3166328bfd3900957eb33cbf1061d0495c9df670
* Merge "apply basic escaping to anon_labels unconditionally" into rel_1_4mike bayer2022-10-281-0/+34
|\
| * apply basic escaping to anon_labels unconditionallyMike Bayer2022-10-271-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | Fixed issue which prevented the :func:`_sql.literal_column` construct from working properly within the context of a :class:`.Select` construct as well as other potential places where "anonymized labels" might be generated, if the literal expression contained characters which could interfere with format strings, such as open parenthesis, due to an implementation detail of the "anonymous label" structure. Fixes: #8724 Change-Id: I3089124fbd055a011c8a245964258503b717d941 (cherry picked from commit caa9f0ff98d44359f5162bca8e7fe7bcaa2989a7)
* | open some compound tests for mysql 8.0.31Mike Bayer2022-10-281-3/+3
|/ | | | | | | | Not sure of exact version but as we have done a major rebuild of CI, newer mysql 8.0 is passing on these. Change-Id: Ibcfe0ce519ab6a2941ca514b4254944769b60df4 (cherry picked from commit 50d3b85c693a4ca673bcabd711f130ae58111f16)
* `aggregate_order_by` now supports cache generation.Federico Caselli2022-09-251-104/+1
| | | | | | | | | | also adjusted CacheKeyFixture to be a general purpose fixture so that sub-components / dialects can run their own cache key tests. Fixes: #8574 Change-Id: I6c66107856aee11e548d357cea77bceee3e316a0 (cherry picked from commit 7980b677085fc759a0406f6778b9729955f3c7f6)
* remove should_nest behavior for contains_eager()Mike Bayer2022-09-231-1/+21
| | | | | | | | | | | | | | | | | | | | Fixed regression for 1.4 in :func:`_orm.contains_eager` where the "wrap in subquery" logic of :func:`_orm.joinedload` would be inadvertently triggered for use of the :func:`_orm.contains_eager` function with similar statements (e.g. those that use ``distinct()``, ``limit()`` or ``offset()``). This is not appropriate for :func:`_orm.contains_eager` which has always had the contract that the user-defined SQL statement is unmodified with the exception of adding the appropriate columns. Also includes an adjustment to the assertion in Label._make_proxy() which was there to prevent a fixed label name from being anonymized; if the label is already anonymous, the change should proceed. This logic was being hit before the contains_eager behavior was adjusted. With the adjustment, this code is not used. Fixes: #8569 Change-Id: I161e65041c0162fd2b83cbef40f57a50fcfaf0fd (cherry picked from commit 57b400f07951f0ae8651ca38338ec5be1d222c7e)
* break out text() from TextualSelect for col matchingMike Bayer2022-09-191-0/+44
| | | | | | | | | | | Fixed issue where mixing "*" with additional explicitly-named column expressions within the columns clause of a :func:`_sql.select` construct would cause result-column targeting to sometimes consider the label name or other non-repeated names to be an ambiguous target. Fixes: #8536 Change-Id: I3c845eaf571033e54c9208762344f67f4351ac3a (cherry picked from commit 78327d98be9236c61f950526470f29b184dabba6)
* include TableClause.schema in cache keyMike Bayer2022-08-301-0/+2
| | | | | | | | | | | | Fixed issue where use of the :func:`_sql.table` construct, passing a string for the :paramref:`_sql.table.schema` parameter, would fail to take the "schema" string into account when producing a cache key, thus leading to caching collisions if multiple, same-named :func:`_sql.table` constructs with different schemas were used. Fixes: #8441 Change-Id: Ic4b55b3e8ec53b4c88ba112691bdf60ea1d4c448 (cherry picked from commit 613642d9639f47ad11ab62a3fa71f6132edbaa0d)
* fill out all distinguising fields for AliasedInspMike Bayer2022-08-171-0/+1
| | | | | | | | | | | | Hardened the cache key strategy for the :func:`_orm.aliased` and :func:`_orm.with_polymorphic` constructs. While no issue involving actual statements being cached can easily be demonstrated (if at all), these two constructs were not including enough of what makes them unique in their cache keys for caching on the aliased construct alone to be accurate. Fixes: #8401 Change-Id: I13d14985b6965f398edd9494601d8ae89ac641f2 (cherry picked from commit a58f1b9c698dc7be29d43f2c4c21de8918943f77)
* deep compare CTEs before considering them conflictingMike Bayer2022-08-051-8/+26
| | | | | | | | | | | | Fixed issue where referencing a CTE multiple times in conjunction with a polymorphic SELECT could result in multiple "clones" of the same CTE being constructed, which would then trigger these two CTEs as duplicates. To resolve, the two CTEs are deep-compared when this occurs to ensure that they are equivalent, then are treated as equivalent. Fixes: #8357 Change-Id: I1f634a9cf7a6c4256912aac1a00506aecea3b0e2 (cherry picked from commit 85fa363c846f4ed287565c43c32e2cca29470e25)
* check for TypeDecorator when handling getitemMike Bayer2022-07-191-0/+130
| | | | | | | | | | Fixed issue where :class:`.TypeDecorator` would not correctly proxy the ``__getitem__()`` operator when decorating the :class:`.ARRAY` datatype, without explicit workarounds. Fixes: #7249 Change-Id: I3273572b4757e41fb5952639cb867314227d368a (cherry picked from commit 1e01fab7e600c53284eabceceab5706e4074eb2e)
* use concat() directly for contains, startswith, endswithMike Bayer2022-07-171-0/+82
| | | | | | | | | | | | | | | | Adjusted the SQL compilation for string containment functions ``.contains()``, ``.startswith()``, ``.endswith()`` to force the use of the string concatenation operator, rather than relying upon the overload of the addition operator, so that non-standard use of these operators with for example bytestrings still produces string concatenation operators. To accommodate this, needed to add a new _rconcat operator function, which is private, as well as a fallback in concat_op() that works similarly to Python builtin ops. Fixes: #8253 Change-Id: I2b7f56492f765742d88cb2a7834ded6a2892bd7e (cherry picked from commit 85a88df13ab8d217331cf98392544a888b4d7df3)
* generalize sql server check for id col to accommodate ORM casesMike Bayer2022-07-051-3/+25
| | | | | | | | | | | | | | | Fixed issues that prevented the new usage patterns for using DML with ORM objects presented at :ref:`orm_dml_returning_objects` from working correctly with the SQL Server pyodbc dialect. Here we add a step to look in compile_state._dict_values more thoroughly for the keys we need to determine "identity insert" or not, and also add a new compiler variable dml_compile_state so that we can skip the ORM's compile_state if present. Fixes: #8210 Change-Id: Idbd76bb3eb075c647dc6c1cb78f7315c821e15f7 (cherry picked from commit 5806428800d2f1ac775156f90497a2fc3a644f35)
* repair yield_per for non-SS dialects and add new optionsMike Bayer2022-07-011-0/+131
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implemented new :paramref:`_engine.Connection.execution_options.yield_per` execution option for :class:`_engine.Connection` in Core, to mirror that of the same :ref:`yield_per <orm_queryguide_yield_per>` option available in the ORM. The option sets both the :paramref:`_engine.Connection.execution_options.stream_results` option at the same time as invoking :meth:`_engine.Result.yield_per`, to provide the most common streaming result configuration which also mirrors that of the ORM use case in its usage pattern. Fixed bug in :class:`_engine.Result` where the usage of a buffered result strategy would not be used if the dialect in use did not support an explicit "server side cursor" setting, when using :paramref:`_engine.Connection.execution_options.stream_results`. This is in error as DBAPIs such as that of SQLite and Oracle already use a non-buffered result fetching scheme, which still benefits from usage of partial result fetching. The "buffered" strategy is now used in all cases where :paramref:`_engine.Connection.execution_options.stream_results` is set. Added :meth:`.FilterResult.yield_per` so that result implementations such as :class:`.MappingResult`, :class:`.ScalarResult` and :class:`.AsyncResult` have access to this method. Fixes: #8199 Change-Id: I6dde3cbe483a1bf81e945561b60f4b7d1c434750 (cherry picked from commit e5a0cdb2eaa1d7f381e93d0529a7f8e6d5888877)
* restore parameter escaping for public methodsMike Bayer2022-06-091-5/+28
| | | | | | | | | | | | | | | Adjusted the fix made for :ticket:`8056` which adjusted the escaping of bound parameter names with special characters such that the escaped names were translated after the SQL compilation step, which broke a published recipe on the FAQ illustrating how to merge parameter names into the string output of a compiled SQL string. The change restores the escaped names that come from ``compiled.params`` and adds a conditional parameter to :meth:`.SQLCompiler.construct_params` named ``escape_names`` that defaults to ``True``, restoring the old behavior by default. Fixes: #8113 Change-Id: I9cbedb1080bc06d51f287fd2cbf26aaab1c74653 (cherry picked from commit 105cd180856309cf5abf24f59b782a1bcd8210d6)
* graceful degrade for FKs not reflectableMike Bayer2022-06-071-8/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed bugs involving the :paramref:`.Table.include_columns` and the :paramref:`.Table.resolve_fks` parameters on :class:`.Table`; these little-used parameters were apparently not working for columns that refer to foreign key constraints. In the first case, not-included columns that refer to foreign keys would still attempt to create a :class:`.ForeignKey` object, producing errors when attempting to resolve the columns for the foreign key constraint within reflection; foreign key constraints that refer to skipped columns are now omitted from the table reflection process in the same way as occurs for :class:`.Index` and :class:`.UniqueConstraint` objects with the same conditions. No warning is produced however, as we likely want to remove the include_columns warnings for all constraints in 2.0. In the latter case, the production of table aliases or subqueries would fail on an FK related table not found despite the presence of ``resolve_fks=False``; the logic has been repaired so that if a related table is not found, the :class:`.ForeignKey` object is still proxied to the aliased table or subquery (these :class:`.ForeignKey` objects are normally used in the production of join conditions), but it is sent with a flag that it's not resolvable. The aliased table / subquery will then work normally, with the exception that it cannot be used to generate a join condition automatically, as the foreign key information is missing. This was already the behavior for such foreign key constraints produced using non-reflection methods, such as joining :class:`.Table` objects from different :class:`.MetaData` collections. Fixes: #8100 Fixes: #8101 Change-Id: Ifa37a91bd1f1785fca85ef163eec031660d9ea4d (cherry picked from commit 40e3c0da5be7dd526866bfc63590fc5621a9bd6e)
* propagate proxy_key from WrapsColumnExpressionMike Bayer2022-06-012-1/+30
| | | | | | | | | | | | | | this allows cast() of a label() to propagate the proxy key outwards in the same way that it apparently works at the SQL level. This is stuffing even more rules into naming so basically seeing how far we can go without other cases starting to fail. Fixes: #8084 Change-Id: I20bd97dae798fee6492334c06934e807d0f269ef (cherry picked from commit 14250f2668151f1c4df86dbf962c771e9788111e)
* raise informative error when selectable can't be extendedMike Bayer2022-05-311-0/+70
| | | | | | | | | | | | An informative error is raised for the use case where :meth:`.Insert.from_select` is being passed a "compound select" object such as a UNION, yet the INSERT statement needs to append additional columns to support Python-side or explicit SQL defaults from the table metadata. In this case a subquery of the compound object should be passed. Fixes: #8073 Change-Id: Ic4a5dbf84ec49d2451901be05cb9cf6ae93f02b7 (cherry picked from commit 7474df2159f89d684d32aabb15014ef95cea1641)
* move bindparam quote application from compiler to defaultMike Bayer2022-05-292-5/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in 296c84313ab29bf9599634f3 for #5653 we generalized Oracle's parameter escaping feature into the compiler, so that it could also work for PostgreSQL. The compiler used quoted names within parameter dictionaries, which then led to the complexity that all functions which interpreted keys from the compiled_params dict had to also quote the param names to use the dictionary. This extra complexity was not added to the ORM peristence.py however, which led to the versioning id feature being broken as well as other areas where persistence.py relies on naming schemes present in context.compiled_params. It also was not added to the "processors" lookup which led to #8053, that added this escaping to that part of the compiler. To both solve the whole problem as well as simplify the compiler quite a bit, move the actual application of the escaped names to be as late as possible, when default.py builds the final list of parameters. This is more similar to how it worked previously where OracleExecutionContext would be late-applying these escaped names. This re-establishes context.compiled_params as deterministically named regardless of dialect in use and moves out the complexity of the quoted param names to be only at the cursor.execute stage. Fixed bug, likely a regression from 1.3, where usage of column names that require bound parameter escaping, more concretely when using Oracle with column names that require quoting such as those that start with an underscore, or in less common cases with some PostgreSQL drivers when using column names that contain percent signs, would cause the ORM versioning feature to not work correctly if the versioning column itself had such a name, as the ORM assumes certain bound parameter naming conventions that were being interfered with via the quotes. This issue is related to :ticket:`8053` and essentially revises the approach towards fixing this, revising the original issue :ticket:`5653` that created the initial implementation for generalized bound-parameter name quoting. Fixes: #8056 Change-Id: I57b064e8f0d070e328b65789c30076f6a0ca0fef (cherry picked from commit a48b597d0cafa1dd7fc46be99eb808fd4cb0a347)
* apply bindparam escape name to processors dictionaryMike Bayer2022-05-251-0/+42
| | | | | | | | | | | | | | Fixed SQL compiler issue where the "bind processing" function for a bound parameter would not be correctly applied to a bound value if the bound parameter's name were "escaped". Concretely, this applies, among other cases, to Oracle when a :class:`.Column` has a name that itself requires quoting, such that the quoting-required name is then used for the bound parameters generated within DML statements, and the datatype in use requires bind processing, such as the :class:`.Enum` datatype. Fixes: #8053 Change-Id: I39d060a87e240b4ebcfccaa9c535e971b7255d99 (cherry picked from commit 4d58ca05e83048e999059a8c2c2e67cb77abf976)
* raise for same param name in expanding + non expandingMike Bayer2022-05-151-0/+19
| | | | | | | | | | | | | | An informative error is raised if two individual :class:`.BindParameter` objects share the same name, yet one is used within an "expanding" context (typically an IN expression) and the other is not; mixing the same name in these two different styles of usage is not supported and typically the ``expanding=True`` parameter should be set on the parameters that are to receive list values outside of IN expressions (where ``expanding`` is set by default). Fixes: #8018 Change-Id: Ie707f29680eea16b9e421af93560ac1958e11a54 (cherry picked from commit f9fccdeeb6749d10aeec458f1a549906d58ddad8)
* use bindparam_type in BinaryElementImpl._post_coercion if availableMike Bayer2022-05-011-0/+19
| | | | | | | | | | | Fixed an issue where using :func:`.bindparam` with no explicit data or type given could be coerced into the incorrect type when used in expressions such as when using :meth:`.ARRAY.comparator.any` and :meth:`.ARRAY.comparator.all`. Fixes: #7979 Change-Id: If7779e713c9a3a5fee496b66e417cfd3fca5b1f9 (cherry picked from commit 889cbe53121c8fd50c845357dd52b24594346b68)
* backport 6f02d5edd88fe247 to 1.4Mike Bayer2022-04-241-1/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in 6f02d5edd88fe2475629438b0730181a2b00c5fe some cleanup to ForeignKey repaired the use case of ForeignKey objects referring to table name alone, by adding more robust column resolution logic. This change also fixes an issue where the "referred column" naming convention key uses the resolved referred column earlier than usual when a ForeignKey is setting up its constraint. Fixed bug where :class:`.ForeignKeyConstraint` naming conventions using the ``referred_column_0`` naming convention key would not work if the foreign key constraint were set up as a :class:`.ForeignKey` object rather than an explicit :class:`.ForeignKeyConstraint` object. As this change makes use of a backport of some fixes from version 2.0, an additional little-known feature that has likely been broken for many years is also fixed which is that a :class:`.ForeignKey` object may refer to a referred table by name of the table alone without using a column name, if the name of the referent column is the same as that of the referred column. The ``referred_column_0`` naming convention key was not previously not tested with the :class:`.ForeignKey` object, only :class:`.ForeignKeyConstraint`, and this bug reveals that the feature has never worked correctly unless :class:`.ForeignKeyConstraint` is used for all FK constraints. This bug traces back to the original introduction of the feature introduced for :ticket:`3989`. Fixes: #7958 Change-Id: I230d43e9deba5dff889b9e7fee6cd4d3aa2496d3
* properly type array element in any() / all()Mike Bayer2022-04-221-8/+8
| | | | | | | | | | | Fixed bug in :class:`.ARRAY` datatype in combination with :class:`.Enum` on PostgreSQL where using the ``.any()`` method to render SQL ANY(), given members of the Python enumeration as arguments, would produce a type adaptation failure on all drivers. Fixes: #6515 Change-Id: Ia1e3b4e10aaf264ed436ce6030d105fc60023433 (cherry picked from commit d023c8e1c7ad82fb249fab5155eb83dee17a160c)
* update flake8 noqa skips with proper syntaxFederico Caselli2022-04-111-1/+1
| | | | | Change-Id: I42ed77f559e3ee5b8c600d98457ee37803ef0ea6 (cherry picked from commit 139c6ec0fb1f930be9b64545262d2580f6cbc83e)
* maintain complete cloned_set for BindParameterMike Bayer2022-04-061-3/+14
| | | | | | | | | | | | Fixed regression caused by :ticket:`7823` which impacted the caching system, such that bound parameters that had been "cloned" within ORM operations, such as polymorphic loading, would in some cases not acquire their correct execution-time value leading to incorrect bind values being rendered. Fixes: #7903 Change-Id: I61c802749b859bebeb127d24e66d6e77d13ce57a (cherry picked from commit 2168a64affb2e299b9a37079af7b2a8d4ae0ff64)
* TableValuedAlias generation fixesMike Bayer2022-04-032-5/+43
| | | | | | | | | | | | | | | | | | | | | | | | | Fixed bug in newly implemented :paramref:`.FunctionElement.table_valued.joins_implicitly` feature where the parameter would not automatically propagate from the original :class:`.TableValuedAlias` object to the secondary object produced when calling upon :meth:`.TableValuedAlias.render_derived` or :meth:`.TableValuedAlias.alias`. Additionally repaired these issues in :class:`.TableValuedAlias`: * repaired a potential memory issue which could occur when repeatedly calling :meth:`.TableValuedAlias.render_derived` against successive copies of the same object (for .alias(), we currently have to still continue chaining from the previous element. not sure if this can be improved but this is standard behavior for .alias() elsewhere) * repaired issue where the individual element types would be lost when calling upon :meth:`.TableValuedAlias.render_derived` or :meth:`.TableValuedAlias.alias`. Fixes: #7890 Change-Id: Ie5120c7ff1e5c1bba5aaf77c782a51c637860208 (cherry picked from commit c315c7401a2aa00a8a0fa0f7d4189a9976fd7962)
* Update bindparam cache keyFederico Caselli2022-03-301-0/+21
| | | | | | | | | | | | The ``literal_execute`` parameter now takes part of the cache generation of a bindparam, since it changes the sql string generated by the compiler. Previously the correct bind values were used, but the ``literal_execute`` would be ignored on subsequent executions of the same query. Fixes: #7876 Change-Id: I6bf887f1a2fe31f9d0ab68f5b4ff315004d006b2 (cherry picked from commit 429512d55e814b03854bc12ec541dbeee9e3b94e)
* column_descriptions or equiv for DML, core selectMike Bayer2022-03-281-0/+132
| | | | | | | | | | | | | Added new attributes :attr:`.ValuesBase.returning_column_descriptions` and :attr:`.ValuesBase.entity_description` to allow for inspection of ORM attributes and entities that are installed as part of an :class:`.Insert`, :class:`.Update`, or :class:`.Delete` construct. The :attr:`.Select.column_descriptions` accessor is also now implemented for Core-only selectables. Fixes: #7861 Change-Id: Ia6a1cd24c798ba61f4e8e8eac90a0fd00d738342 (cherry picked from commit 2f1df5f9105149d6cb01c8b6ab6b9ccffa020780)
* support BLANK_SCHEMA, RETAIN_SCHEMA FK schema on copyMike Bayer2022-03-261-0/+22
| | | | | | | | | | | | | Added support so that the :paramref:`.Table.tometadata.referred_schema_fn` callable passed to :meth:`.Table.to_metadata` may return the value :data:`.BLANK_SCHEMA` to indicate that the referenced foreign key should be reset to None. The :data.`RETAIN_SCHEMA` symbol may also be returned from this function to indicate "no change", which will behave the same as ``None`` currently does which also indicates no change. Fixes: #7860 Change-Id: I82a45988d534295d8356453f68001b21d4ff706d (cherry picked from commit 74d3f3965b383aef7421f2cf1779573a4ac65987)
* Add option to disable from linting for table valued functionMike Bayer2022-03-231-0/+28
| | | | | | | | | | | | | | Added new parameter :paramref:`.FunctionElement.table_valued.joins_implicitly`, for the :meth:`.FunctionElement.table_valued` construct. This parameter indicates that the given table-valued function implicitly joins to the table it refers towards, essentially disabling the "from linting" feature, i.e. the "cartesian product" warning, from taking effect due to the presence of this parameter. May be used for functions such as ``func.json_each()``. Fixes: #7845 Change-Id: I80edcb74efbd4417172132c0db4d9c756fdd5eae (cherry picked from commit 04dcc5c704dbf0b22705523e263e512c24936175)
* pop the stack that we pushedMike Bayer2022-03-081-0/+21
| | | | | | | | | | | | Fixed regression caused by :ticket:`7760` where the new capabilities of :class:`.TextualSelect` were not fully implemented within the compiler properly, leading to issues with composed INSERT constructs such as "INSERT FROM SELECT" and "INSERT...ON CONFLICT" when combined with CTE and textual statements. Fixes: #7798 Change-Id: Ia2ce92507e574dd36fd26dd38ec9dd2713584467 (cherry picked from commit c36965ab211183764357456fff1640418586ed97)
* Merge "warn for enum length silently ignored" into rel_1_4mike bayer2022-03-041-2/+19
|\
| * warn for enum length silently ignoredMike Bayer2022-03-041-2/+19
| | | | | | | | | | | | | | | | | | | | | | the "length" parameter is silently ignored when native_enum is not passed as False. if native_enum is True, a non-native VARCHAR can still be generated. Warn for this silent ignore right now, consider having "length" used in all cases where non-native enum is rendered likely in 2.0. Change-Id: Ibceedd4e3aa3926f3268c0c39d94ab73d17a9bdc (cherry picked from commit 18683f474b285b4d7e16c38c0a570276912e1081)
* | Merge "fix type string formatting calls" into rel_1_4mike bayer2022-03-041-0/+18
|\ \ | |/ |/|
| * fix type string formatting callsMike Bayer2022-03-041-0/+18
| | | | | | | | | | | | | | | | | | | | Fixed type-related error messages that would fail for values that were tuples, due to string formatting syntax, including compile of unsupported literal values and invalid boolean values. Fixes: #7721 Change-Id: I6775721486ef2db2d0738b9aa08b9f2570f55659 (cherry picked from commit a261a78894c4f835b5da7fcbfb3d466a687bc11b)
* | add length to enum repr paramsMike Bayer2022-03-041-0/+7
|/ | | | | | | | This amends the fix for #7789. Fixes: #7598 Change-Id: I067a081d743f1efaf8288601bec0400712012265 (cherry picked from commit a26a522648af14ffb9388d8d306bd98523bef1c9)
* Fix repr for MySQL SET, generic Enumpetit872022-03-041-0/+7
| | | | | | | | | | | | | | | | | Fixed issues in :class:`_mysql.SET` datatype as well as :class:`.Enum` where the ``__repr__()`` method would not render all optional parameters in the string output, impacting the use of these types in Alembic autogenerate. Pull request for MySQL courtesy Yuki Nishimine. Fixes: #7720 Fixes: #7789 Closes: #7772 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7772 Pull-request-sha: d58845479f497f6b2e12d7df2e9eb2d6ac22109b Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Change-Id: Idcec23eab4258511d9f32f4e3d78e511ea6021f1 (cherry picked from commit a926dea6b78c91b627f0f0b86cdc6a9279872e99)
* support add_cte() for TextualSelectMike Bayer2022-02-231-0/+45
| | | | | | | | | | | | Fixed issue where the :meth:`.HasCTE.add_cte` method as called upon a :class:`.TextualSelect` instance was not being accommodated by the SQL compiler. The fix additionally adds more "SELECT"-like compiler behavior to :class:`.TextualSelect` including that DML CTEs such as UPDATE and INSERT may be accommodated. Fixes: #7760 Change-Id: Id97062d882e9b2a81b8e31c2bfaa9cfc5f77d5c1 (cherry picked from commit bef67e58121704a9836e1e5ec2d361cd2086036c)