summaryrefslogtreecommitdiff
path: root/test/sql
Commit message (Collapse)AuthorAgeFilesLines
...
* Merge "Add Sequence to StrSQLCompiler"mike bayer2018-11-131-0/+12
|\
| * Add Sequence to StrSQLCompilerMike Bayer2018-11-101-0/+12
| | | | | | | | | | | | | | | | | | | | Added :class:`.Sequence` to the "string SQL" system that will render a meaningful string expression (``"<next sequence value: my_sequence>"``) when stringifying without a dialect a statement that includes a "sequence nextvalue" expression, rather than raising a compilation error. Fixes: #4144 Change-Id: Ia910f0e22008a7cde7597365954ede324101cf4d
* | Add new "all columns" naming convention tokensMike Bayer2018-11-101-0/+187
|/ | | | | | | | | | | | | | | | | | | | | | | | | | Added new naming convention tokens ``column_0N_name``, ``column_0_N_name``, etc., which will render the names / keys / labels for all columns referenced by a particular constraint in a sequence. In order to accommodate for the length of such a naming convention, the SQL compiler's auto-truncation feature now applies itself to constraint names as well, which creates a shortened, deterministically generated name for the constraint that will apply to a target backend without going over the character limit of that backend. Additional notes: 1. the SQLite dialect had a format_index method that was apparently not used, removed. 2. the naming convention logic has been applying the foreign key remote column spec to the naming convention, and not the actual column name. In the case where the referenced Table object uses .key inside the columns and these are what ForeignKey() references, the naming convention was doing the wrong thing. The patch here fixes this, however this isn't noted in the migration notes. Fixes: #3989 Change-Id: Ib24f4754b886676096c480fc54b2e5c2463ac99a
* Use the same "current_timestamp" function for both sides of round tripMike Bayer2018-10-201-2/+4
| | | | | | | | | | | | | | | this test was using sysdate() and current_timestamp() together in conjunction with a truncation to DAY, however for four hours on saturday night (see commit time :) ) these two values will have a different value if one side is EDT and the other is UTC. tox does not transmit environment variables including TZ by default, so even if the server is set up for EDT, running tox will not set TZ and at least Oracle client seems to use this value, producing UTC for session time but the database on CI was configured for EDT, producing EDT for sysdate. Change-Id: I56602d2402a475a0c4fdf61c1c5fc2618c82f915
* Merge "Import from collections.abc"mike bayer2018-09-271-2/+2
|\
| * Import from collections.abcxtreak2018-09-271-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed additional warnings generated by Python 3.7 due to changes in the organization of the Python ``collections`` and ``collections.abc`` packages. Previous ``collections`` warnings were fixed in version 1.2.11. Pull request courtesy xtreak. See I2d1c0ef97c8ecac7af152cc56263422a40faa6bb for the original collections.abc fixes. Fixes: #4339 Change-Id: Ia92d2461f20309fb33ea6c6f592f7d4e7e32ae7a Pull-request: https://github.com/zzzeek/sqlalchemy/pull/475
* | Copy create_constraint flag for EnumMike Bayer2018-09-251-1/+23
|/ | | | | | | | | Fixed bug where the :paramref:`.Enum.create_constraint` flag on the :class:`.Enum` datatype would not be propagated to copies of the type, which affects use cases such as declarative mixins and abstract bases. Fixes: #4341 Change-Id: I978be65f33a616fe4d5f5de03fb3eaab6f6a2272
* Allow dialects to customize group by clause compilationSamuel Chou2018-09-201-0/+37
| | | | | | | | | | | Refactored :class:`.SQLCompiler` to expose a :meth:`.SQLCompiler.group_by_clause` method similar to the :meth:`.SQLCompiler.order_by_clause` and :meth:`.SQLCompiler.limit_clause` methods, which can be overridden by dialects to customize how GROUP BY renders. Pull request courtesy Samuel Chou. Change-Id: I0a7238e55032558c27a0c56a72907c7b883456f1 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/474
* MariaDB 10.3 updatesMike Bayer2018-08-301-2/+4
| | | | | | | | | MariaDB seems to handle some additional UPDATE/DELETE FROM syntaxes as well as some forms of INTERSECT and EXCEPT. Open up tests that expect failure for MySQL to allow success for MariaDB 10.3. Change-Id: Ia9341a82485ef7201bb8130d8dbf4a9b6976035a
* Add missing range_ / rows parameters to additional over() methodsMike Bayer2018-08-192-0/+76
| | | | | | | | | | | | Added missing window function parameters :paramref:`.WithinGroup.over.range_` and :paramref:`.WithinGroup.over.rows` parameters to the :meth:`.WithinGroup.over` and :meth:`.FunctionFilter.over` methods, to correspond to the range/rows feature added to the "over" method of SQL functions as part of :ticket:`3049` in version 1.1. Fixes: #4322 Change-Id: I77dcdac65c699a4b52a3fc3ee09a100ffb4fc20e
* Add concept of "implicit boolean", treat as nativeMike Bayer2018-08-151-1/+33
| | | | | | | | | | | | | | | Fixed issue that is closely related to :ticket:`3639` where an expression rendered in a boolean context on a non-native boolean backend would be compared to 1/0 even though it is already an implcitly boolean expression, when :meth:`.ColumnElement.self_group` were used. While this does not affect the user-friendly backends (MySQL, SQLite) it was not handled by Oracle (and possibly SQL Server). Whether or not the expression is implicitly boolean on any database is now determined up front as an additional check to not generate the integer comparison within the compliation of the statement. Fixes: #4320 Change-Id: Iae0a65e5c01bd576e64733c3651e1e1a1a1b240c
* Fixed issue with :meth:`.TypeEngine.bind_expression` andMike Bayer2018-08-081-5/+182
| | | | | | | | | | | | :meth:`.TypeEngine.column_expression` methods where these methods would not work if the target type were part of a :class:`.Variant`, or other target type of a :class:`.TypeDecorator`. Additionally, the SQL compiler now calls upon the dialect-level implementation when it renders these methods so that dialects can now provide for SQL-level processing for built-in types. Change-Id: Ic7b39575184db582e628e6ecee48dcda7d03a817 Fixes: #3981
* Add support of empty list in exanding of bindparamNicolas Rolin2018-08-071-5/+3
| | | | | | | | | | | Added new logic to the "expanding IN" bound parameter feature whereby if the given list is empty, a special "empty set" expression that is specific to different backends is generated, thus allowing IN expressions to be fully dynamic including empty IN expressions. Fixes: #4271 Change-Id: Icc3c73bbd6005206b9d06baaeb14a097af5edd36 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/432
* Include UPDATE/DELETE extra_froms in correlationMike Bayer2018-08-042-3/+131
| | | | | | | | | | | | | | | | | Fixed bug where the multi-table support for UPDATE and DELETE statements did not consider the additional FROM elements as targets for correlation, when a correlated SELECT were also combined with the statement. This change now includes that a SELECT statement in the WHERE clause for such a statement will try to auto-correlate back to these additional tables in the parent UPDATE/DELETE or unconditionally correlate if :meth:`.Select.correlate` is used. Note that auto-correlation raises an error if the SELECT statement would have no FROM clauses as a result, which can now occur if the parent UPDATE/DELETE specifies the same tables in its additional set of tables ; specify :meth:`.Select.correlate` explicitly to resolve. Change-Id: Ie11eaad7e49af3f59df11691b104d6359341bdae Fixes: #4313
* Fix collections ABC access before Python 3.8Nathaniel Knight2018-08-011-1/+1
| | | | | | | | | | | | | | | | | | | | Started importing "collections" from "collections.abc" under Python 3.3 and greater for Python 3.8 compatibility. Pull request courtesy Nathaniel Knight. In Python 3.3, the abstract base classes (Iterable, Mapping, etc.) were moved from the `collections` module and put in the `collections.abc` module. They remain in the `collections` module for backwards compatibility, and will until Python 3.8. This commit adds a variable (`collections_abc`) to the `util/compat` module, which will be the `collections` module for Python < 3.3 and before, or the `collections.abc` module for Python >= 3.3. It also uses the new variable, getting rid of some deprecation warnings that were seen when running under Python 3.7. Change-Id: I2d1c0ef97c8ecac7af152cc56263422a40faa6bb Pull-request: https://github.com/zzzeek/sqlalchemy/pull/464
* Drop default-related structures after the Table is dropped.Mike Bayer2018-07-101-0/+80
| | | | | | | | | | | | Fixed bug where a :class:`.Sequence` would be dropped explicitly before any :class:`.Table` that refers to it, which breaks in the case when the sequence is also involved in a server-side default for that table, when using :meth:`.MetaData.drop_all`. The step which processes sequences to be dropped via non server-side column default functions is now invoked after the table itself is dropped. Change-Id: I185f2cc76d2011ad4dd3ba9bde5d8aef0ec335ae Fixes: #4300
* support functions "as binary comparison"Mike Bayer2018-07-091-1/+65
| | | | | | | | | Added new feature :meth:`.FunctionElement.as_comparison` which allows a SQL function to act as a binary comparison operation that can work within the ORM. Change-Id: I07018e2065d09775c0406cabdd35fc38cc0da699 Fixes: #3831
* Merge "Support JOIN in UPDATE..FROM"mike bayer2018-06-251-0/+46
|\
| * Support JOIN in UPDATE..FROMMike Bayer2018-06-131-0/+46
| | | | | | | | | | | | | | | | | | | | The :class:`.Update` construct now accommodates a :class:`.Join` object as supported by MySQL for UPDATE..FROM. As the construct already accepted an alias object for a similar purpose, the feature of UPDATE against a non-table was already implied so this has been added. Change-Id: I7b2bca627849384d5377abb0c94626463e4fad04 Fixes: #3645
* | Use utf8mb4 (or utf8mb3) for all things MySQLMike Bayer2018-06-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed bug in MySQLdb dialect and variants such as PyMySQL where an additional "unicode returns" check upon connection makes explicit use of the "utf8" character set, which in MySQL 8.0 emits a warning that utf8mb4 should be used. This is now replaced with a utf8mb4 equivalent. Documentation is also updated for the MySQL dialect to specify utf8mb4 in all examples. Additional changes have been made to the test suite to use utf8mb3 charsets and databases (there seem to be collation issues in some edge cases with utf8mb4), and to support configuration default changes made in MySQL 8.0 such as explicit_defaults_for_timestamp as well as new errors raised for invalid MyISAM indexes. Change-Id: Ib596ea7de4f69f976872a33bffa4c902d17dea25 Fixes: #4283 Fixes: #4192
* | Merge "render WITH clause after INSERT for INSERT..SELECT on Oracle, MySQL"mike bayer2018-06-242-1/+44
|\ \
| * | render WITH clause after INSERT for INSERT..SELECT on Oracle, MySQLMike Bayer2018-06-182-1/+44
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed INSERT FROM SELECT with CTEs for the Oracle and MySQL dialects, where the CTE was being placed above the entire statement as is typical with other databases, however Oracle and MariaDB 10.2 wants the CTE underneath the "INSERT" segment. Note that the Oracle and MySQL dialects don't yet work when a CTE is applied to a subquery inside of an UPDATE or DELETE statement, as the CTE is still applied to the top rather than inside the subquery. Also adds test suite support CTEs against backends. Change-Id: I8ac337104d5c546dd4f0cd305632ffb56ac8bf90 Fixes: #4275 Fixes: #4230
* | Lookup index columns in parent table by key for copyMike Bayer2018-06-141-0/+32
|/ | | | | | | | | | | | | Fixed regression in 1.2 due to :ticket:`4147` where a :class:`.Table` that has had some of its indexed columns redefined with new ones, as would occur when overriding columns during reflection or when using :paramref:`.Table.extend_existing`, such that the :meth:`.Table.tometadata` method would fail when attempting to copy those indexes as they still referred to the replaced column. The copy logic now accommodates for this condition. Change-Id: I521aa2c9f3baa0e84598bbdd6ffe4bf07b6e3ba8 Fixes: #4279
* Skip for SQL Server on non-native boolean unconstrainedMike Bayer2018-05-171-1/+1
| | | | | | | | | As SQL Server is now non-native boolean as of I4765d2a2a00b0d14f50282603cc4d48d4739dac1 but uses the BIT type, we need to constrain this test to continue to not run against SQL Server. Change-Id: I214faf2b788a0e8e10725622e3e71f3b70805533
* Fix string formatting TypeError if tuple is passedMiguel Ventura2018-05-171-3/+15
| | | | | | | | | | Fixed issue where the "ambiguous literal" error message used when interpreting literal values as SQL expression values would encounter a tuple value, and fail to format the message properly. Pull request courtesy Miguel Ventura. Change-Id: I50d5d32d5f80ec79703a42d4b19b42c2f9701f24 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/442
* Ensure all visit_sequence accepts **kw argsMike Bayer2018-04-041-1/+14
| | | | | | | | | | Fixed issue where the compilation of an INSERT statement with the "literal_binds" option that also uses an explicit sequence and "inline" generation, as on Postgresql and Oracle, would fail to accommodate the extra keyword argument within the sequence processing routine. Change-Id: Ibdab7d340aea7429a210c9535ccf1a3e85f074fb Fixes: #4231
* Track if we're rendering within the CTE recursivelyMike Bayer2018-03-142-1/+45
| | | | | | | | | | Fixed a regression that occurred from the previous fix to :ticket:`4204` in version 1.2.5, where a CTE that refers to itself after the :meth:`.CTE.alias` method has been called would not refer to iself correctly. Change-Id: Iaa63d65ad2b90c8693f9953fbb32dbb10c73a037 Fixes: #4204
* Clone _cte_alias instead of assigning "self"Mike Bayer2018-03-052-1/+86
| | | | | | | | | | Fixed bug in :class:.`CTE` construct along the same lines as that of :ticket:`4204` where a :class:`.CTE` that was aliased would not copy itself correctly during a "clone" operation as is frequent within the ORM as well as when using the :meth:`.ClauseElement.params` method. Change-Id: Id68d72dd244dedfc7bd6116c9a5123c51a55ea20 Fixes: #4210
* Check existing CTE for an alias name when rendering FROM clauseMike Bayer2018-03-011-0/+200
| | | | | | | | | | Fixed bug in CTE rendering where a :class:`.CTE` that was also turned into an :class:`.Alias` would not render its "ctename AS aliasname" clause appropriately if there were more than one reference to the CTE in a FROM clause. Change-Id: If8cff27a2f4faa5eceb59aa86398db6edb3b9e72 Fixes: #4204
* Allow bind processors to work with expanding INMike Bayer2018-02-231-122/+185
| | | | | | | | | Fixed bug in new "expanding IN parameter" feature where the bind parameter processors for values wasn't working at all, tests failed to cover this pretty basic case which includes that ENUM values weren't working. Change-Id: I8e2420d7229a3e253e43b5227ebb98f9fe0bd14a Fixes: #4198
* Quote cte alias if neededEric Atkin2018-02-221-1/+42
| | | | | | | | | | Fixed bug where CTE expressions would not have their name or alias name quoted when the given name is case sensitive or otherwise requires quoting. Pull request courtesy Eric Atkin. Fixes: #4197 Change-Id: Ib8573e82b9a1ca94b50c7c5d73ee98b79465d689 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/426
* Add values_callable feature to EnumJon Snyder2018-02-071-1/+51
| | | | | | | | | | | | Added support for :class:`.Enum` to persist the values of the enumeration, rather than the keys, when using a Python pep-435 style enumerated object. The user supplies a callable function that will return the string values to be persisted. This allows enumerations against non-string values to be value-persistable as well. Pull request courtesy Jon Snyder. Pull-request: https://github.com/zzzeek/sqlalchemy/pull/410 Fixes: #3906 Change-Id: Id385465d215d1e5baaad68368b168afdd846b82c
* fix handling of native enum aliases in sqlalchemy enum columnsDaniel Knell2018-02-051-3/+14
| | | | | | | | | | Fixed bug where the :class:`.Enum` type wouldn't handle enum "aliases" correctly, when more than one key refers to the same value. Pull request courtesy Daniel Knell. Fixes: #4180 Change-Id: Ia716c00ca6c67aeab56965f0fdd575ecb7c71416 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/420
* Merge "Make column-level collation quoting dialect-specific"mike bayer2018-01-122-2/+28
|\
| * Make column-level collation quoting dialect-specificMike Bayer2018-01-122-2/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | Fixed regression in 1.2 where newly repaired quoting of collation names in :ticket:`3785` breaks SQL Server, which explicitly does not understand a quoted collation name. Whether or not mixed-case collation names are quoted or not is now deferred down to a dialect-level decision so that each dialect can prepare these identifiers directly. Change-Id: Iaf0a8123d9bf4711219e320896bb28c5d2649304 Fixes: #4154
* | `ValuesBase.values` inconsistency fixAubrey Stark-Toller2018-01-121-0/+33
|/ | | | | | | | | | Fixed bug in :meth:`.Insert.values` where using the "multi-values" format in combination with :class:`.Column` objects as keys rather than strings would fail. Pull request courtesy Aubrey Stark-Toller. Change-Id: I9d3b40b5950df8f5bfdc8b1d22f9c3afb277f17f Pull-request: https://github.com/zzzeek/sqlalchemy/pull/412 Fixes: #4162
* Fully copy index expressionsMike Bayer2017-12-141-2/+5
| | | | | | | | | | | | | | | | | Fixed bug where the :meth:`.Table.tometadata` method would not properly accommodate :class:`.Index` objects that didn't consist of simple column expressions, such as indexes against a :func:`.text` construct, indexes that used SQL expressions or :attr:`.func`, etc. The routine now copies expressions fully to a new :class:`.Index` object while substituting all table-bound :class:`.Column` objects for those of the target table. Also refined the means by which tometadata() checks if an Index or UniqueConstraint is generated by a column-level flag, by propagating an attribute "_column_flag=True" to such indexes/constraints. Change-Id: I7ef1b8ea42f9933357ae35f241a5ba9838bac35b Fixes: #4147
* Merge "Change visit name for ColumnElement"mike bayer2017-12-071-2/+14
|\
| * Change visit name for ColumnElementMike Bayer2017-12-061-2/+14
| | | | | | | | | | | | | | | | | | | | No SQLA built-in subclasses ColumnElement without specifying an alternate visit_name, and user defined ColumnElement subclasses should avoid being treated like ColumnClause, e.g. where a Table is present. Fixes: #4142 Change-Id: I15ed09ba8bdebae4cb0c7e5e5df3f59351477577
* | Merge "Allow delete where clause to refer multiple tables."mike bayer2017-12-063-5/+146
|\ \
| * | Allow delete where clause to refer multiple tables.inytar2017-12-053-5/+146
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implemented "DELETE..FROM" syntax for Postgresql, MySQL, MS SQL Server (as well as within the unsupported Sybase dialect) in a manner similar to how "UPDATE..FROM" works. A DELETE statement that refers to more than one table will switch into "multi-table" mode and render the appropriate "USING" or multi-table "FROM" clause as understood by the database. Pull request courtesy Pieter Mulder. For SQL syntaxes see: Postgresql: https://www.postgresql.org/docs/current/static/sql-delete.html MySQL: https://dev.mysql.com/doc/refman/5.7/en/delete.html#multiple-table_syntax MSSQL: https://docs.microsoft.com/en-us/sql/t-sql/statements/delete-transact-sql Sybase: http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc00801.1510/html/iqrefso/X315721.htm Co-authored by: Mike Bayer <mike_mp@zzzcomputing.com> Change-Id: I6dfd57b49e44a095d076dc493cd2360bb5d920d3 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/392 Fixes: #959
* | Propagate attachment events for ARRAYMike Bayer2017-12-041-1/+9
|/ | | | | | | | | | | | Fixed regression in :class:`.ARRAY` datatype caused by :ticket:`3964`, which is essentially the same issue as that of :ticket:`3832`, where column attachment events for :class:`.ARRAY` would not be invoked. This breaks the use case of using declarative mixins that declare a :class:`.Column` which makes use of :meth:`.MutableList.as_mutable`. Change-Id: If8c57615860883837f6cf72661e46180a77778c1 Fixes: #4141
* Fix regexp for expanding INMike Bayer2017-12-011-0/+60
| | | | | | | | | Fixed bug in new "expanding bind parameter" feature whereby if multiple params were used in one statement, the regular expression would not match the parameter name correctly. Change-Id: Ifaf7d627aac4ead2a13c8dddccb5c515253d88e6 Fixes: #4140
* Accommodate tuples for ColumnDefault.__repr__Nicolas CANIART2017-10-311-0/+1
| | | | | | | | | Fixed bug where ``__repr__`` of :class:`.ColumnDefault` would fail if the argument were a tuple. Pull request courtesy Nicolas Caniart. Change-Id: I08aa2448ef91054c43d6068ac54cedbdf7a83d64 Pull-request: https://bitbucket.org/zzzeek/sqlalchemy/pull-requests/1 Fixes: #4126
* Rework autoescape to be a simple boolean; escape the escape characterMike Bayer2017-10-241-18/+49
| | | | | | | | | | | | Reworked the new "autoescape" feature introduced in :ref:`change_2694` in 1.2.0b2 to be fully automatic; the escape character now defaults to a forwards slash ``"/"`` and is applied to percent, underscore, as well as the escape character itself, for fully automatic escaping. The character can also be changed using the "escape" parameter. Change-Id: I74894a2576983c0f6eb89480c9e5727f49fa9c25 Fixes: #2694
* Disallow all ambiguous boolean values for BooleanMike Bayer2017-10-121-5/+167
| | | | | | | | | | | | | | In release 1.1, the :class:`.Boolean` type was broken in that boolean coercion via ``bool()`` would occur for backends that did not feature "native boolean", but would not occur for native boolean backends, meaning the string ``"0"`` now behaved inconsistently. After a poll, a consensus was reached that non-boolean values should be raising an error, especially in the ambiguous case of string ``"0"``; so the :class:`.Boolean` datatype will now raise ``ValueError`` if an incoming value is not within the range ``None, True, False, 1, 0``. Change-Id: If70c4f79c266f0dd1a0306c0ffe7acb9c66c4cc3 Fixes: #4102
* Fix array_agg to accommodate ARRAY argumentsMike Bayer2017-10-061-1/+37
| | | | | | | | | | Fixed bug in :func:`.array_agg` function where passing an argument that is already of type :class:`.ARRAY`, such as a Postgresql :obj:`.postgresql.array` construct, would produce a ``ValueError``, due to the function attempting to nest the arrays. Change-Id: Ibe5f6275d90e4868e6ef8a733de05acd44c05d78 Fixes: #4107
* Support pg10Mike Bayer2017-10-021-8/+2
| | | | | | | | | One test appears to use some awkward calling style with the current_date function that isn't working in pg10 anymore, this looks like an extremely old test that can be removed Change-Id: I5f8aee0f5ed423461be5a9060c812eb0acdc7df5
* Support mariadb 10.2Mike Bayer2017-09-281-1/+6
| | | | | | | | | | | | | | | | | Fixed issue where CURRENT_TIMESTAMP would not reflect correctly in the MariaDB 10.2 series due to a syntax change, where the function is now represented as ``current_timestamp()``. Fixes: #4096 MariaDB 10.2 now supports CHECK constraints (warning: use version 10.2.9 or greater due to upstream issues noted in :ticket:`4097`). Reflection now takes these CHECK constraints into account when they are present in the ``SHOW CREATE TABLE`` output. Fixes: #4098 Change-Id: I8666d61814e8145ca12cbecad94019b44af868e3
* Support method form of any_(), all_()Mike Bayer2017-09-271-0/+38
| | | | | | | | | | | | Fixed bug where the recently added :meth:`.ColumnOperators.any_` and :meth:`.ColumnOperators.all_` methods didn't work when called as methods, as opposed to using the standalone functions :func:`~.expression.any_` and :func:`~.expression.all_`. Also added documentation examples for these relatively unintuitive SQL operators. Change-Id: I3e56b463e9fd146a077b9970624f50cba27f9811 Fixes: #4093