summaryrefslogtreecommitdiff
path: root/test/sql
Commit message (Collapse)AuthorAgeFilesLines
...
| * | Modernize tests - unionGord Thompson2021-07-121-2/+2
| | | | | | | | | | | | Change-Id: I2ccb714a249350f23e2b5f78f5f9ffb0d4f7efb0
* | | Adjust CTE recrusive col list to accommodate dupe col namesMike Bayer2021-07-133-2/+155
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed issue in CTE constructs where a recursive CTE that referred to a SELECT that has duplicate column names, which are typically deduplicated using labeling logic in 1.4, would fail to refer to the deduplicated label name correctly within the WITH clause. As part of this change we are also attempting to remove the behavior of SelectStatementGrouping forcing off the "asfrom" contextual flag, which will have the result of additional labeling being applied to some UNION and similar statements when they are interpreted as subqueries. To maintain compatibility with "grouping", the Grouping/SelectStatementGrouping are now broken out into two separate compiler cases, as the "asfrom" logic appears to be tailored towards table valued SELECTS as column expressions. Fixes: #6710 Change-Id: I8af07a5c670dbe5736cd9f16084ef82f5e4c8642
* | | Merge "labeling refactor"mike bayer2021-07-134-14/+142
|\ \ \ | |/ / |/| |
| * | labeling refactorMike Bayer2021-07-124-14/+142
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To service #6718 and #6710, the system by which columns are given labels in a SELECT statement as well as the system that gives them keys in a .c or .selected_columns collection have been refactored to provide a single source of truth for both, in constrast to the previous approach that included similar logic repeated in slightly different ways. Main ideas: 1. ColumnElement attributes ._label, ._anon_label, ._key_label are renamed to include the letters "tq", meaning "table-qualified" - these labels are only used when rendering a SELECT that has LABEL_STYLE_TABLENAME_PLUS_COL for its label style; as this label style is primarily legacy, the "tq" names should be isolated so that in a 2.0 style application these aren't being used at all 2. The means by which the "labels" and "proxy keys" for the elements of a SELECT has been centralized to a single source of truth; previously, the three of _generate_columns_plus_names, _generate_fromclause_column_proxies, and _column_naming_convention all had duplicated rules between them, as well as that there were a little bit of labeling rules in compiler._label_select_column as well; by this we mean that the various "anon_label" "anon_key" methods on ColumnElement were called by all four of these methods, where there were many cases where it was necessary that one method comes up with the same answer as another of the methods. This has all been centralized into _generate_columns_plus_names for all the names except the "proxy key", which is generated by _column_naming_convention. 3. compiler._label_select_column has been rewritten to both not make any naming decisions nor any "proxy key" decisions, only whether to label or not to label; the _generate_columns_plus_names method gives it the information, where the proxy keys come from _column_naming_convention; previously, these proxy keys were matched based on restatement of similar (but not really the same) logic in two places. The heuristics of "whether to label or not to label" are also reorganized to be much easier to read and understand. 4. a new method compiler._label_returning_column is added for dialects to use in their "generate returning columns" methods. A github search reveals a small number of third party dialects also doing this using the prior _label_select_column method so we try to make sure _label_select_column continues to work the exact same way for that specific use case; for the "SELECT" use case it now needs 5. After some attempts to do it different ways, for the case where _proxy_key is giving us some kind of anon label, we are hard changing it to "_no_label" right now, as there's not currently a way to fully match anonymized labels from stmt.c or stmt.selected_columns to what will be in the result map. The idea of "_no_label" is to encourage the user to use label('name') for columns they want to be able to target by string name that don't have a natural name. Change-Id: I7a92a66f3a7e459ccf32587ac0a3c306650daf11
* | | Merge "implement independent CTEs"mike bayer2021-07-122-6/+156
|\ \ \
| * | | implement independent CTEsMike Bayer2021-07-122-6/+156
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added new method :meth:`_sql.HasCTE.add_cte` to each of the :func:`_sql.select`, :func:`_sql.insert`, :func:`_sql.update` and :func:`_sql.delete` constructs. This method will add the given :class:`_sql.CTE` as an "independent" CTE of the statement, meaning it renders in the WITH clause above the statement unconditionally even if it is not otherwise referenced in the primary statement. This is a popular use case on the PostgreSQL database where a CTE is used for a DML statement that runs against database rows independently of the primary statement. Fixes: #6752 Change-Id: Ibf635763e40269cbd10f4c17e208850d8e8d0188
* | | Merge "Modernize tests - select(whereclause)"mike bayer2021-07-124-36/+52
|\ \ \
| * | | Modernize tests - select(whereclause)Gord Thompson2021-07-044-36/+52
| |/ / | | | | | | | | | Change-Id: I306cfbea9920b35100e3087dcc21d7ffa6c39c55
* | | represent tablesample.sampling as FunctionElement in all casesMike Bayer2021-07-111-0/+1
|/ / | | | | | | | | | | | | | | | | Fixed regression where the :func:`_sql.tablesample` construct would fail to be executable when constructed given a floating-point sampling value not embedded within a SQL function. Fixes: #6735 Change-Id: I557bcd4bdbffc4329ad69d5659ba99b1c8deb554
* | clear new Query._memoized_select_entities in _from_selectableMike Bayer2021-06-301-0/+38
| | | | | | | | | | | | | | | | | | | | | | Fixed regression caused in 1.4.19 due to #6503 and related involving :meth:`_orm.Query.with_entities` where the new structure used would be inappropriately transferred to an enclosing :class:`_orm.Query` when making use of set operations such as :meth:`_orm.Query.union`, causing the JOIN instructions within to be applied to the outside query as well. Fixes: #6698 Change-Id: Ia9f294215ebc01330d142a0a3e5be9d02be9380f
* | Fix missing None handling of Table.prefixesKai Mueller2021-06-281-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed issue where passing ``None`` for the value of :paramref:`_schema.Table.prefixes` would not store an empty list, but rather the constant ``None``, which may be unexpected by third party dialects. The issue is revealed by a usage in recent versions of Alembic that are passing ``None`` for this value. Pull request courtesy Kai Mueller. Fixes: #6685 Closes: #6672 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6672 Pull-request-sha: b79aca0ee4011b244978b35fed4c687ffbe56dc9 Change-Id: I758641c6fbde6f2607d074fecea7efa6728aeea0
* | Add "impl" parameter to PickleTypejason3gb2021-06-241-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | Add a impl parameter to :class:`_types.PickleType` constructor, allowing any arbitary type to be used in place of the default implementation of :class:`_types.LargeBinary`. Pull request courtesy jason3gb. Fixes: #6646 Closes: #6657 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6657 Pull-request-sha: e49bcd368d1f71dba92225d8d6e3af2bbe7142f7 Change-Id: Ib79f3b0ebbc94393f673f5a5ba6558260083d0cf
* | consider "*" col as textual orderedMike Bayer2021-06-231-0/+22
| | | | | | | | | | | | | | | | | | Fixed old issue where a :func:`_sql.select()` made against the token "*", which then yielded exactly one column, would fail to correctly organize the ``cursor.description`` column name into the keys of the result object. Fixes: #6665 Change-Id: Ie8c00f62998972ad4a19a750d2642d00fde006f6
* | Export deferred columns but not col props; fix CTE labelingMike Bayer2021-06-221-0/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Refined the behavior of ORM subquery rendering with regards to deferred columns and column properties to be more compatible with that of 1.3 while also providing for 1.4's newer features. As a subquery in 1.4 does not make use of loader options, including :func:`_orm.deferred`, a subquery that is against an ORM entity with deferred attributes will now render those deferred attributes that refer directly to mapped table columns, as these are needed in the outer SELECT if that outer SELECT makes use of these columns; however a deferred attribute that refers to a composed SQL expression as we normally do with :func:`_orm.column_property` will not be part of the subquery, as these can be selected explicitly if needed in the subquery. If the entity is being SELECTed from this subquery, the column expression can still render on "the outside" in terms of the derived subquery columns. This produces essentially the same behavior as when working with 1.3. However in this case the fix has to also make sure that the ``.selected_columns`` collection of an ORM-enabled :func:`_sql.select` also follows these rules, which in particular allows recursive CTEs to render correctly in this scenario, which were previously failing to render correctly due to this issue. As part of this change the _exported_columns_iterator() method has been removed and logic simplified to use ._all_selected_columns from any SelectBase object where _exported_columns_iterator() was used before. Additionally sets up UpdateBase to include ReturnsRows in its hierarchy; the literal point of ReturnsRows was to be a common base for UpdateBase and SelectBase so it was kind of weird it wasn't there. Fixes: #6661 Fixed issue in CTE constructs mostly relevant to ORM use cases where a recursive CTE against "anonymous" labels such as those seen in ORM ``column_property()`` mappings would render in the ``WITH RECURSIVE xyz(...)`` section as their raw internal label and not a cleanly anonymized name. Fixes: #6663 Change-Id: I26219d4d8e6c0915b641426e9885540f74fae4d2
* | memoize current options and joins w with_entities/with_only_colsMike Bayer2021-06-173-0/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed further regressions in the same area as that of :ticket:`6052` where loader options as well as invocations of methods like :meth:`_orm.Query.join` would fail if the left side of the statement for which the option/join depends upon were replaced by using the :meth:`_orm.Query.with_entities` method, or when using 2.0 style queries when using the :meth:`_sql.Select.with_only_columns` method. A new set of state has been added to the objects which tracks the "left" entities that the options / join were made against which is memoized when the lead entities are changed. Fixes: #6503 Fixes: #6253 Change-Id: I211b2af98b0b20d1263fb15dc513884dcc5de6a4
* | repair Join.is_derived_from() to not rely on simple identityMike Bayer2021-06-071-0/+32
| | | | | | | | | | | | | | | | | | Fixed issue where query production for joinedload against a complex left hand side involving joined-table inheritance could fail to produce a correct query, due to a clause adaption issue. Fixes: #6595 Change-Id: Id4b839d52447cdc103b392dd8946c4cfa7a829e1
* | Fix adaption in AnnotatedLabel; repair needless expense in coercionMike Bayer2021-05-281-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed regression involving clause adaption of labeled ORM compound elements, such as single-table inheritance discriminator expressions with conditionals or CASE expressions, which could cause aliased expressions such as those used in ORM join / joinedload operations to not be adapted correctly, such as referring to the wrong table in the ON clause in a join. This change also improves a performance bump that was located within the process of invoking :meth:`_sql.Select.join` given an ORM attribute as a target. Fixes: #6550 Change-Id: I98906476f0cce6f41ea00b77c789baa818e9d167
* | Update black flak8 and zimportsFederico Caselli2021-05-126-7/+5
| | | | | | | | Change-Id: I488c9557eda390e4a88319affd4c8813ee274f80
* | Merge "allow CTE to be direct DML target"mike bayer2021-05-111-0/+73
|\ \
| * | allow CTE to be direct DML targetMike Bayer2021-05-111-0/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implemented support for a :class:`_sql.CTE` construct to be used directly as the target of a :func:`_sql.delete` construct, i.e. "WITH ... AS cte DELETE FROM cte". This appears to be a useful feature of SQL Server. The CTE is now generally usable as a DML target table however it's not clear if this syntax is valid beyond the use case of DELETE itself. Fixes: #6464 Change-Id: I3aac6fae2a1abb39bc0ffa87a044f5eb4f90f026
* | | set bindparam.expanding in coercion againMike Bayer2021-05-103-6/+99
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adjusted the logic added as part of :ticket:`6397` in 1.4.12 so that internal mutation of the :class:`.BindParameter` object occurs within the clause construction phase as it did before, rather than in the compilation phase. In the latter case, the mutation still produced side effects against the incoming construct and additionally could potentially interfere with other internal mutation routines. In order to solve the issue of the correct operator being present on the BindParameter.expand_op, we necessarily have to expand the BinaryExpression._negate() routine to flip the operator on the BindParameter also. Fixes: #6460 Change-Id: I1e53a9aeee4de4fc11af51d7593431532731561b
* | Merge "don't cache TypeDecorator by default"mike bayer2021-05-0610-0/+171
|\ \
| * | don't cache TypeDecorator by defaultMike Bayer2021-05-0610-0/+171
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The :class:`.TypeDecorator` class will now emit a warning when used in SQL compilation with caching unless the ``.cache_ok`` flag is set to ``True`` or ``False``. ``.cache_ok`` indicates that all the parameters passed to the object are safe to be used as a cache key, ``False`` means they are not. Fixes: #6436 Change-Id: Ib1bb7dc4b124e38521d615c2e2e691e4915594fb
* | | Merge "Parenthesize for empty not in"mike bayer2021-05-052-30/+86
|\ \ \ | |/ / |/| |
| * | Parenthesize for empty not inMike Bayer2021-05-052-30/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed regression caused by the "empty in" change just made in :ticket:`6397` 1.4.12 where the expression needs to be parenthesized for the "not in" use case, otherwise the condition will interfere with the other filtering criteria. also amends StrSQLCompiler to use the newer "empty IN" style for its compilation process. Fixes: #6428 Change-Id: I182a552fc0d3065a9e38c0f4ece2deb143735c36
* | | Establish deprecation path for CursorResult.keys()Mike Bayer2021-05-042-14/+47
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Established a deprecation path for calling upon the :meth:`_cursor.CursorResult.keys` method for a statement that returns no rows to provide support for legacy patterns used by the "records" package as well as any other non-migrated applications. Previously, this would raise :class:`.ResourceClosedException` unconditionally in the same way as it does when attempting to fetch rows. While this is the correct behavior going forward, the :class:`_cursor.LegacyCursorResult` object will now in this case return an empty list for ``.keys()`` as it did in 1.3, while also emitting a 2.0 deprecation warning. The :class:`_cursor.CursorResult`, used when using a 2.0-style "future" engine, will continue to raise as it does now. Fixes: #6427 Change-Id: I4148f28c88039e4141deeab28b1a5994e6d6e098
* | Support filter_by() from columns, functions, Core SQLMike Bayer2021-05-011-1/+64
| | | | | | | | | | | | | | | | | | | | | | | | Fixed regression where :meth:`_orm.Query.filter_by` would not work if the lead entity were a SQL function or other expression derived from the primary entity in question, rather than a simple entity or column of that entity. Additionally, improved the behavior of :meth:`_sql.Select.filter_by` overall to work with column expressions even in a non-ORM context. Fixes: #6414 Change-Id: I316b5bf98293bec1ede08787f6181dd14be85419
* | track_on needs to be a fixed size, support sub-tuplesMike Bayer2021-04-301-8/+31
| | | | | | | | | | | | | | | | | | | | Fixed regression in ``selectinload`` loader strategy that would cause it to cache its internal state incorrectly when handling relationships that join across more than one column, such as when using a composite foreign key. The invalid caching would then cause other loader operations to fail. Fixes: #6410 Change-Id: I9f95ccca3553e7fd5794c619be4cf85c02b04626
* | Merge "Ensure iterable passed to Select is not a mapped class"mike bayer2021-04-291-0/+48
|\ \
| * | Ensure iterable passed to Select is not a mapped classMike Bayer2021-04-291-0/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed regression caused by :ticket:`5395` where tuning back the check for sequences in :func:`_sql.select` now caused failures when doing 2.0-style querying with a mapped class that also happens to have an ``__iter__()`` method. Tuned the check some more to accommodate this as well as some other interesting ``__iter__()`` scenarios. Fixes: #6300 Change-Id: Idf1983fd764b91a7d5fa8117aee8a3def3cfe5ff
* | | Merge "Fix ForeignKeyConstraint.copy() error"mike bayer2021-04-291-0/+23
|\ \ \ | |/ / |/| |
| * | Fix ForeignKeyConstraint.copy() errorGord Thompson2021-04-291-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed an issue with the (deprecated in 1.4) :meth:`_schema.ForeignKeyConstraint.copy` method that caused an error when invoked with the ``schema`` argument. Fixes: #6353 Change-Id: I03330d9ec254d64377f2b2e86af69a4eaff43ac6
* | | Merge "Use non-subquery form for empty IN"mike bayer2021-04-291-0/+40
|\ \ \ | |/ / |/| |
| * | Use non-subquery form for empty INMike Bayer2021-04-291-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Revised the "EMPTY IN" expression to no longer rely upon using a subquery, as this was causing some compatibility and performance problems. The new approach for selected databases takes advantage of using a NULL-returning IN expression combined with the usual "1 != 1" or "1 = 1" expression appended by AND or OR. The expression is now the default for all backends other than SQLite, which still had some compatibility issues regarding tuple "IN" for older SQLite versions. Third party dialects can still override how the "empty set" expression renders by implementing a new compiler method ``def visit_empty_set_op_expr(self, type_, expand_op)``, which takes precedence over the existing ``def visit_empty_set_expr(self, element_types)`` which remains in place. Fixes: #6258 Fixes: #6397 Change-Id: I2df09eb00d2ad3b57039ae48128fdf94641b5e59
* | | Merge "Propertly ignore ``Identity`` in MySQL and MariaDb."mike bayer2021-04-291-12/+60
|\ \ \
| * | | Propertly ignore ``Identity`` in MySQL and MariaDb.Federico Caselli2021-04-281-12/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Ensure that the MySQL and MariaDB dialect ignore the :class:`_sql.Identity` construct while rendering the ``AUTO_INCREMENT`` keyword in a create table. The Oracle and PostgreSQL compiler was updated to not render :class:`_sql.Identity` if the database version does not support it (Oracle < 12 and PostgreSQL < 10). Previously it was rendered regardless of the database version. Fixes: #6338 Change-Id: I2ca0902fdd7b4be4fc1a563cf5585504cbea9360
* | | | Merge "ensure SelectState.all_selected_columns not memoized as a generator"mike bayer2021-04-281-0/+11
|\ \ \ \
| * | | | ensure SelectState.all_selected_columns not memoized as a generatorMike Bayer2021-04-281-0/+11
| | |/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | This regression was found from #6261 before release of 1.4.12 Fixes: #6261 Fixes: #6394 Change-Id: I4c2c5da02dbcf5c2cea26c81d3521de892ef428e
* | | | accommodate for mutiple copies of bind in ckbmMike Bayer2021-04-281-0/+98
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed critical regression where bound parameter tracking as used in the SQL caching system could fail to track all parameters for the case where the same SQL expression containing a parameter were used in an ORM-related query using a feature such as class inheritance, which was then embedded in an enclosing expression which would make use of that same expression multiple times, such as a UNION. The ORM would individually copy the individual SELECT statements as part of compilation with class inheritance, which then embedded in the enclosing statement would fail to accommodate for all parameters. The logic that tracks this condition has been adjusted to work for multiple copies of a parameter. Fixes: #6391 Change-Id: I6db5dee0d361a3bb58d753a2d27ef2eee2b369c5
* | | Merge "have SchemaType inherit schema from metadata"mike bayer2021-04-271-0/+21
|\ \ \
| * | | have SchemaType inherit schema from metadataMike Bayer2021-04-271-0/+21
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed very old issue where the :class:`_types.Enum` datatype would not inherit the :paramref:`_schema.MetaData.schema` parameter of a :class:`_schema.MetaData` object when that object were passed to the :class:`_types.Enum` using :paramref:`_types.Enum.metadata`. Fixes: #6373 Change-Id: Ie77d5e8cbc0bd7bfd0039fb60a4a0bde2df58ca9
* | | Handle Sequence in _process_multiparam_default_bindMike Bayer2021-04-262-0/+107
|/ / | | | | | | | | | | | | | | | | | | | | Fixed issue where usage of an explicit :class:`.Sequence` would produce inconsistent "inline" behavior for an :class:`.Insert` construct that includes multiple values phrases; the first seq would be inline but subsequent ones would be "pre-execute", leading to inconsistent sequence ordering. The sequence expressions are now fully inline. Fixes: #6361 Change-Id: Ie16794ec0e19979a7e6c8d1bef5716a9fc199889
* | dont assume ClauseElement in attributes, coercionsMike Bayer2021-04-231-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed two distinct issues, each of which would come into play under certain circumstances, most likely however one which is a common mis-configuration in :class:`_hybrid.hybrid_property`, where the "expression" implementation would return a non :class:`_sql.ClauseElement` such as a boolean value. For both issues, 1.3's behavior was to silently ignore the mis-configuration and ultimately attempt to interpret the value as a SQL expression, which would lead to an incorrect query. * Fixed issue regarding interaction of the attribute system with hybrid_property, where if the ``__clause_element__()`` method of the attribute returned a non-:class:`_sql.ClauseElement` object, an internal ``AttributeError`` would lead the attribute to return the ``expression`` function on the hybrid_property itself, as the attribute error was against the name ``.expression`` which would invoke the ``__getattr__()`` method as a fallback. This now raises explicitly. In 1.3 the non-:class:`_sql.ClauseElement` was returned directly. * Fixed issue in SQL argument coercions system where passing the wrong kind of object to methods that expect column expressions would fail if the object were altogether not a SQLAlchemy object, such as a Python function, in cases where the object were not just coerced into a bound value. Again 1.3 did not have a comprehensive argument coercion system so this case would also pass silently. Fixes: #6350 Change-Id: I5bba0a6b27f45e5f8ebadfd6d511fa773388ef7c
* | omit text from selected_columns; clear memoizationsMike Bayer2021-04-222-0/+142
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed regression where usage of the :func:`_sql.text` construct inside the columns clause of a :class:`_sql.Select` construct, which is better handled by using a :func:`_sql.literal_column` construct, would nonetheless prevent constructs like :func:`_sql.union` from working correctly. Other use cases, such as constructing subuqeries, continue to work the same as in prior versions where the :func:`_sql.text` construct is silently omitted from the collection of exported columns. Also repairs similar use within the ORM. This adds a new internal method _all_selected_columns. The existing "selected_columns" collection can't store a TextClause and this never worked, so they are omitted. The TextClause is also not "exported", i.e. available for SELECT from a subquery, as was already the case in 1.3, so the "exported_columns" and "exported_columns_iterator" accessors are where we now omit TextClause. Fixed regression involving legacy methods such as :meth:`_sql.Select.append_column` where internal assertions would fail. Fixes: #6343 Fixes: #6261 Change-Id: I7c2e5b9ae5d94131c77599a020f4310dcf812bcf
* | Propagate compiler kw for visit_values to parametersMike Bayer2021-04-201-0/+63
| | | | | | | | | | | | | | | | | | | | | | | | Fixed issue in SQL compiler where the bound parameters set up for a :class:`.Values` construct wouldn't be positionally tracked correctly if inside of a :class:`_sql.CTE`, affecting database drivers that support VALUES + ctes and use positional parameters such as SQL Server in particular as well as asyncpg. The fix also repairs support for compiler flags such as ``literal_binds``. Fixes: #6327 Change-Id: I2d549228691d0bfc10dadd0955b1549d7584db51
* | Merge "Derive `next_value.type` from `Sequence.data_type` if available"mike bayer2021-04-201-0/+5
|\ \
| * | Derive `next_value.type` from `Sequence.data_type` if availableBryan Forbes2021-04-181-0/+5
| | | | | | | | | | | | | | | | | | Fixes #6287 Change-Id: I7d428ed86cd72cd910bfff9058a52c7fcb7c64ac
* | | Merge "Don't stringify unnamed column elements when proxying"mike bayer2021-04-173-12/+27
|\ \ \
| * | | Don't stringify unnamed column elements when proxyingMike Bayer2021-04-173-12/+27
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Repaired and solidified issues regarding custom functions and other arbitrary expression constructs which within SQLAlchemy's column labeling mechanics would seek to use ``str(obj)`` to get a string representation to use as an anonymous column name in the ``.c`` collection of a subquery. This is a very legacy behavior that performs poorly and leads to lots of issues, so has been revised to no longer perform any compilation by establishing specific methods on :class:`.FunctionElement` to handle this case, as SQL functions are the only use case that it came into play. An effect of this behavior is that an unlabeled column expression with no derivable name will be given an arbitrary label starting with the prefix ``"_no_label"`` in the ``.c`` collection of a subquery; these were previously being represented either as the generic stringification of that expression, or as an internal symbol. This change seeks to make the concept of "anon name" more private and renames anon_label and anon_key_label to _anon_name_label and _anon_key_label. There's no end-user utility to these accessors and we need to be able to reorganize these as well. Fixes: #6256 Change-Id: Ie63c86b20ca45873affea78500388da94cf8bf94
* | | Merge "pass asfrom correctly in compilers"mike bayer2021-04-171-0/+66
|\ \ \