summaryrefslogtreecommitdiff
path: root/test/sql/test_compiler.py
Commit message (Collapse)AuthorAgeFilesLines
* Allow for multiple FOLLOWING/PRECEDING in a window rangeMike Bayer2017-08-251-12/+18
| | | | | | | | | | | Altered the range specification for window functions to allow for two of the same PRECEDING or FOLLOWING keywords in a range by allowing for the left side of the range to be positive and for the right to be negative, e.g. (1, 3) is "1 FOLLOWING AND 3 FOLLOWING". Change-Id: I7d3a6c641151bb49219104968d18dac2266f3db8 Fixes: #4053
* Add new "expanding" feature to bindparam()Mike Bayer2017-04-071-0/+12
| | | | | | | | | | | | | | | | 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
* Add "empty in" strategies; default to "static"Mike Bayer2017-03-141-3/+5
| | | | | | | | | | | | | | | The longstanding behavior of the :meth:`.Operators.in_` and :meth:`.Operators.not_in_` operators emitting a warning when the right-hand condition is an empty sequence has been revised; a new flag :paramref:`.create_engine.empty_in_strategy` allows an empty "IN" expression to generate a simple boolean expression, or to invoke the previous behavior of dis-equating the expression to itself, with or without a warning. The default behavior is now to emit the simple boolean expression, allowing an empty IN to be evaulated without any performance penalty. Change-Id: I65cc37f2d7cf65a59bf217136c42fee446929352 Fixes: #3907
* Only use schema_translate_map on SchemaItem subclassesMike Bayer2017-02-281-1/+45
| | | | | | | | | | | | | Fixed bug in new "schema translate" feature where the translated schema name would be invoked in terms of an alias name when rendered along with a column expression; occurred only when the source translate name was "None". The "schema translate" feature now only takes effect for :class:`.SchemaItem` and :class:`.SchemaType` subclasses, that is, objects that correspond to a DDL-creatable structure in a database. Change-Id: Ie8cb35aeaba2c67efec8c8c57c219e4dd346e44a Fixes: #3924
* Make all tests to be PEP8 compliantKhairi Hafsham2017-02-071-2/+1
| | | | | | | | tested using pycodestyle version 2.2.0 Fixes: #3885 Change-Id: I5df43adc3aefe318f9eeab72a078247a548ec566 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/343
* Support python3.6Mike Bayer2017-01-131-2/+2
| | | | | | | | | | | Corrects some warnings and adds tox config. Adds DeprecationWarning to the error category. Large sweep for string literals w/ backslashes as this is common in docstrings Co-authored-by: Andrii Soldatenko Fixes: #3886 Change-Id: Ia7c838dfbbe70b262622ed0803d581edc736e085 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/337
* Tighten rules for order_by(Label) resolutionMike Bayer2017-01-061-0/+50
| | | | | | | | | | | | | | | | - Fixed bug originally introduced in 0.9 via :ticket:`1068` where order_by(<some Label()>) would order by the label name based on name alone, that is, even if the labeled expression were not at all the same expression otherwise present, implicitly or explicitly, in the selectable. The logic that orders by label now ensures that the labeled expression is related to the one that resolves to that name before ordering by the label name; additionally, the name has to resolve to an actual label explicit in the expression elsewhere, not just a column name. This logic is carefully kept separate from the order by(textual name) feature that has a slightly different purpose. Change-Id: I44fc36dab34380cc238c1e79ecbe23f1628d588a Fixes: #3882
* Propagate execution_options at compile stageMike Bayer2016-10-051-0/+33
| | | | | | | | Compiler can now set up execution options and additionally will propagate autocommit from embedded CTEs. Change-Id: I19db7b8fe4d84549ea95342e8d2040189fed1bbe Fixes: #3805
* Allow stringify compiler to render unnamed columnMike Bayer2016-09-021-2/+11
| | | | | | | | | | Stringify of expression with unnamed :class:`.Column` objects, as occurs in lots of situations including ORM error reporting, will now render the name in string context as "<name unknown>" rather than raising a compile error. Change-Id: I76f637c5eb4cfdb1b526964cb001565b97e296da Fixes: #3789
* Spelling fixespr/299Ville Skyttä2016-08-081-1/+1
|
* Don't reorder PrimaryKeyConstraint columns if explicitMike Bayer2016-06-201-1/+17
| | | | | | | | | | | Dialed back the "order the primary key columns per auto-increment" described in :ref:`change_mysql_3216` a bit, so that if the :class:`.PrimaryKeyConstraint` is explicitly defined, the order of columns is maintained exactly, allowing control of this behavior when necessary. Change-Id: I9e7902c57a96c15968a6abf53e319acf15680da0 Fixes: #3726
* Add DDLCompiler.create_table_suffix()Mark Sandan2016-06-161-0/+16
| | | | | | | Allows custom dialects to add keywords after the CREATE TABLE section. Change-Id: I6fa66dfcf00ef95122f491a9115410df2746cf88
* Support range specification in window functionPhillip Cloud2016-06-071-0/+67
| | | | | | | Fixes: #3049 Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Change-Id: Ie572095c3e25f70a1e72e1af6858e5edd89fd25e Pull-request: https://github.com/zzzeek/sqlalchemy/pull/264
* - Added support for rendering "FULL OUTER JOIN" to both Core and ORM.Mike Bayer2016-03-281-0/+20
| | | | Pull request courtesy Stefan Urbanek. fixes #1957
* - Fixed bug where the negation of an EXISTS expression would notMike Bayer2016-03-211-0/+15
| | | | | | | be properly typed as boolean in the result, and also would fail to be anonymously aliased in a SELECT list as is the case with a non-negated EXISTS construct. fixes #3682
* - move out unconsumed names tests from test_compiler out to test_insert, ↵Mike Bayer2016-03-021-42/+0
| | | | | | | test_update - establish consistent names between existing unconsumed names tests and new ones added per ref #3666
* - additional adjustment to the fix made in ↵Mike Bayer2016-02-211-0/+40
| | | | | | | | | | | | | | | 8ad968f33100baeb3b13c7e0b724b6b79ab4277f for ref #3657. The Oracle dialect makes more use of the "select_wraps_for" feature than SQL server because Oracle doesn't have "TOP" for a limit-only select, so tests are showing more happening here. In the case where the select() has some dupe columns, these are deduped from the .c collection so a positional match between the wrapper and original can't use .inner_columns, because these collections wont match. Using _columns_plus_names instead which is the deduped collection that determines the SELECT display, which definitely have to match up. (cherry picked from commit aa9ce3f521f254da9879ede011e520ec35b8270e)
* - reworked the way the "select_wraps_for" expression isMike Bayer2016-02-201-0/+23
| | | | | | | | | | | | | | | | | | | | | | | handled within visit_select(); this attribute was added in the 1.0 series to accommodate the subquery wrapping behavior of SQL Server and Oracle while also working with positional column targeting and no longer relying upon "key fallback" in order to target columns in such a statement. The IBM DB2 third-party dialect also has this use case, but its implementation is using regular expressions to rewrite the textual SELECT only and does not make use of a "wrapped" select at this time. The logic no longer attempts to reconcile proxy set collections as this was not deterministic, and instead assumes that the select() and the wrapper select() match their columns postionally, at least for the column positions they have in common, so it is now very simple and safe. fixes #3657. - as a side effect of #3657 it was also revealed that the strategy of calling upon a ResultProxy._getter was not correctly calling into NoSuchColumnError when an expected column was not present, and instead returned None up to loading.instances() to produce NoneType failures; added a raiseerr argument to _getter() which is called when we aren't expecting None, fixes #3658.
* - add literal_binds for delete() statements in addition to insert()/update()Mike Bayer2016-02-031-16/+25
| | | | | - move tests to CRUDTest - changelog, fixes #3643
* fix passing literal_binds flag through for update and insertpr/232Tim Tate2016-02-021-0/+16
|
* - calling str() on a core sql construct has been made more "friendly",Mike Bayer2016-01-191-4/+69
| | | | | | | | | | when the construct contains non-standard sql elements such as returning, array index operations, or dialect-specific or custom datatypes. a string is now returned in these cases rendering an approximation of the construct (typically the postgresql-style version of it) rather than raising an error. fixes #3631 - add within_group to top-level imports - add eq_ignore_whitespace to sqlalchemy.testing imports
* - Multi-tenancy schema translation for :class:`.Table` objects is added.Mike Bayer2016-01-081-0/+127
| | | | | | | | | This supports the use case of an application that uses the same set of :class:`.Table` objects in many schemas, such as schema-per-user. A new execution option :paramref:`.Connection.execution_options.schema_translate_map` is added. fixes #2685 - latest tox doesn't like the {posargs} in the profile rerunner
* - Fixed bug where CREATE TABLE with a no-column table, but a constraintMike Bayer2015-12-011-1/+25
| | | | | | | such as a CHECK constraint would render an erroneous comma in the definition; this scenario can occur such as with a Postgresql INHERITS table that has no columns of its own. fixes #3598
* - The system by which a :class:`.Column` considers itself to be anMike Bayer2015-10-071-0/+15
| | | | | | | | | | | | | | | | | "auto increment" column has been changed, such that autoincrement is no longer implicitly enabled for a :class:`.Table` that has a composite primary key. In order to accommodate being able to enable autoincrement for a composite PK member column while at the same time maintaining SQLAlchemy's long standing behavior of enabling implicit autoincrement for a single integer primary key, a third state has been added to the :paramref:`.Column.autoincrement` parameter ``"auto"``, which is now the default. fixes #3216 - The MySQL dialect no longer generates an extra "KEY" directive when generating CREATE TABLE DDL for a table using InnoDB with a composite primary key with AUTO_INCREMENT on a column that isn't the first column; to overcome InnoDB's limitation here, the PRIMARY KEY constraint is now generated with the AUTO_INCREMENT column placed first in the list of columns.
* - The :func:`.type_coerce` construct is now a fully fledged CoreMike Bayer2015-09-161-2/+4
| | | | | | | | | | | expression element which is late-evaluated at compile time. Previously, the function was only a conversion function which would handle different expression inputs by returning either a :class:`.Label` of a column-oriented expression or a copy of a given :class:`.BindParameter` object, which in particular prevented the operation from being logically maintained when an ORM-level expression transformation would convert a column to a bound parameter (e.g. for lazy loading). fixes #3531
* - The behavior of the :func:`.union` construct and related constructsMike Bayer2015-08-121-4/+63
| | | | | | | | | such as :meth:`.Query.union` now handle the case where the embedded SELECT statements need to be parenthesized due to the fact that they include LIMIT, OFFSET and/or ORDER BY. These queries **do not work on SQLite**, and will fail on that backend as they did before, but should now work on all other backends. fixes #2528
* - changelog for #3459, fixes #3459Mike Bayer2015-07-191-0/+2
| | | | | - test for .cast() method has no good place now except for test_cast in test_compiler.py
* - Fixed a regression that was incorrectly fixed in 1.0.0b4Mike Bayer2015-04-241-0/+13
| | | | | | | | | | | | | | | | | | (hence becoming two regressions); reports that SELECT statements would GROUP BY a label name and fail was misconstrued that certain backends such as SQL Server should not be emitting ORDER BY or GROUP BY on a simple label name at all; when in fact, we had forgotten that 0.9 was already emitting ORDER BY on a simple label name for all backends, as described in :ref:`migration_1068`, as 1.0 had rewritten this logic as part of :ticket:`2992`. In 1.0.2, the bug is fixed both that SQL Server, Firebird and others will again emit ORDER BY on a simple label name when passed a :class:`.Label` construct that is expressed in the columns clause, and no backend will emit GROUP BY on a simple label name in this case, as even Postgresql can't reliably do GROUP BY on a simple name in every case. fixes #3338, fixes #3385
* - Fixed support for "literal_binds" mode when using limit/offsetMike Bayer2015-04-231-3/+3
| | | | | | with Firebird, so that the values are again rendered inline when this is selected. Related to :ticket:`3034`. fixes #3381
* - Fixed issue where a straight SELECT EXISTS query would fail toMike Bayer2015-04-201-3/+3
| | | | | | | | | | | | | | | | assign the proper result type of Boolean to the result mapping, and instead would leak column types from within the query into the result map. This issue exists in 0.9 and earlier as well, however has less of an impact in those versions. In 1.0, due to #918 this becomes a regression in that we now rely upon the result mapping to be very accurate, else we can assign result-type processors to the wrong column. In all versions, this issue also has the effect that a simple EXISTS will not apply the Boolean type handler, leading to simple 1/0 values for backends without native boolean instead of True/False. The fix includes that an EXISTS columns argument will be anon-labeled like other column expressions; a similar fix is implemented for pure-boolean expressions like ``not_(True())``. fixes #3372
* PEP8 cleanup in /test/sqlEric Streeper2015-03-181-4/+0
|
* - rename _select_wrapsMike Bayer2015-03-081-0/+61
| | | | | - replace force_result_map with a mini-API for nested result sets, add coverage
* fooMike Bayer2015-03-081-9/+9
|
* - the refactor of the visit_alias() method in Oracle revealedMike Bayer2014-12-041-1/+1
| | | | that quoting should be applied in %(name)s under with_hint.
* - Fixed issue where the columns from a SELECT embedded in anMike Bayer2014-11-111-0/+29
| | | | | | | | | INSERT, either through the values clause or as a "from select", would pollute the column types used in the result set produced by the RETURNING clause when columns from both statements shared the same name, leading to potential errors or mis-adaptation when retrieving the returning rows. fixes #3248
* - The :attr:`.Column.key` attribute is now used as the source ofMike Bayer2014-11-101-0/+13
| | | | | | | | | | | anonymous bound parameter names within expressions, to match the existing use of this value as the key when rendered in an INSERT or UPDATE statement. This allows :attr:`.Column.key` to be used as a "substitute" string to work around a difficult column name that doesn't translate well into a bound parameter name. Note that the paramstyle is configurable on :func:`.create_engine` in any case, and most DBAPIs today support a named and positional style. fixes #3245
* - ensure kwargs are passed for limit clause on a compound select as well,Mike Bayer2014-10-311-0/+16
| | | | further fixes for #3034
* - changelog, migration for pr github:134Mike Bayer2014-10-041-91/+0
|
* Merge remote-tracking branch 'origin/pr/134' into pr134Mike Bayer2014-10-041-0/+91
|\
| * allow windowing filtered functionsIlja Everilä2014-09-111-0/+27
| |
| * renamed aggregatefilter to funcfilter, since it is thatIlja Everilä2014-09-111-1/+1
| |
| * tests for <aggregate_fun> FILTER (WHERE ...)Ilja Everilä2014-09-101-0/+64
| |
* | - Added new method :meth:`.Select.with_statement_hint` and ORMMike Bayer2014-09-181-0/+17
|/ | | | | | method :meth:`.Query.with_statement_hint` to support statement-level hints that are not specific to a table. fixes #3206
* - rework the previous "order by" system in terms of the new one,Mike Bayer2014-09-081-0/+21
| | | | | | | | unify everything. - create a new layer of separation between the "from order bys" and "column order bys", so that an OVER doesn't ORDER BY a label in the same columns clause - identify another issue with polymorphic for ref #3148, match on label keys rather than the objects
* - ensure literal_binds works with LIMIT clause, FOR UPDATEMike Bayer2014-09-031-1/+1
|
* - The :func:`~.expression.column` and :func:`~.expression.table`Mike Bayer2014-09-011-14/+19
| | | | | | | | | | | | | | | | | | | | | constructs are now importable from the "from sqlalchemy" namespace, just like every other Core construct. - The implicit conversion of strings to :func:`.text` constructs when passed to most builder methods of :func:`.select` as well as :class:`.Query` now emits a warning with just the plain string sent. The textual conversion still proceeds normally, however. The only method that accepts a string without a warning are the "label reference" methods like order_by(), group_by(); these functions will now at compile time attempt to resolve a single string argument to a column or label expression present in the selectable; if none is located, the expression still renders, but you get the warning again. The rationale here is that the implicit conversion from string to text is more unexpected than not these days, and it is better that the user send more direction to the Core / ORM when passing a raw string as to what direction should be taken. Core/ORM tutorials have been updated to go more in depth as to how text is handled. fixes #2992
* - update the flake8 rules againMike Bayer2014-07-181-863/+968
| | | | - apply autopep8 + manual fixes to most of test/sql/
* - more tests, including backend testsMike Bayer2014-05-161-0/+53
| | | | - implement for SQL server, use window functions when simple limit/offset not available
* - Fixed bug where :meth:`.Table.update` and :meth:`.Table.delete`Mike Bayer2014-05-081-0/+9
| | | | | | | would produce an empty WHERE clause when an empty :func:`.and_()` or :func:`.or_()` or other blank expression were applied. This is now consistent with that of :func:`.select`. fixes #3045
* - Fixed bug where the combination of "limit" rendering asMike Bayer2014-04-301-0/+29
| | | | | | | | | "SELECT FIRST n ROWS" using a bound parameter (only firebird has both), combined with column-level subqueries which also feature "limit" as well as "positional" bound parameters (e.g. qmark style) would erroneously assign the subquery-level positions before that of the enclosing SELECT, thus returning parameters which are out of order. Fixes #3038