summaryrefslogtreecommitdiff
path: root/test/sql
Commit message (Collapse)AuthorAgeFilesLines
...
* Spelling fixesVille Skyttä2016-10-083-4/+4
|
* Change autoincrement compileerror to a warningMike Bayer2016-10-072-41/+60
| | | | | | | | Users are complaining that IntegrityError is no longer raised. Change-Id: I0855d5b7a98d4338f0910501b6e6d404ba33634d Fixes: #3216
* Propagate execution_options at compile stageMike Bayer2016-10-052-1/+41
| | | | | | | | Compiler can now set up execution options and additionally will propagate autocommit from embedded CTEs. Change-Id: I19db7b8fe4d84549ea95342e8d2040189fed1bbe Fixes: #3805
* Check for __clause_element__() in ORM insert/updateMike Bayer2016-10-051-0/+10
| | | | | | | | | | | | | | | | ORM attributes can now be assigned any object that is has a ``__clause_element__()`` attribute, which will result in inline SQL the way any :class:`.ClauseElement` class does. This covers other mapped attributes not otherwise transformed by further expression constructs. As part of this, it was considered that we could add __clause_element__() to ClauseElement, however this causes endless loops in a "while" pattern and this pattern has been identified in third party libraries. Add a test to ensure we never make that change. Change-Id: I9e15b3f1c4883fd3909acbf7dc81d034c6e3ce1d Fixes: #3802
* Add "eager_parenthesis" late-compilation rule, use w/ PG JSON/HSTOREMike Bayer2016-10-011-2/+27
| | | | | | | | | | | | Added compiler-level flags used by Postgresql to place additional parenthesis than would normally be generated by precedence rules around operations involving JSON, HSTORE indexing operators as well as within their operands since it has been observed that Postgresql's precedence rules for at least the HSTORE indexing operator is not consistent between 9.4 and 9.5. Fixes: #3806 Change-Id: I5899677b330595264543b055abd54f3c76bfabf2
* Escape literal string values passed to server_defaultMike Bayer2016-09-301-0/+28
| | | | | | | | | | | A string sent as a column default via the :paramref:`.Column.server_default` parameter is now escaped for quotes. This change is backwards compatible with code that may have been working around this previously. Change-Id: I341298a76cc67bc0a53df4ab51ab9379f2294cdd Fixes: #3809
* Merge "Exclude eq and ne from associative operators"mike bayer2016-09-201-0/+8
|\
| * Exclude eq and ne from associative operatorsJohn Passaro2016-09-191-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | The "eq" and "ne" operators are no longer part of the list of "associative" operators, while they remain considered to be "commutative". This allows an expression like ``(x == y) == z`` to be maintained at the SQL level with parenthesis. Pull request courtesy John Passaro. Fixes: #3799 Change-Id: I3759d8987b35649d7418b6524316c9e70c857e68 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/308
* | Support bindparam() with callable for primaryjoinMike Bayer2016-09-191-2/+31
|/ | | | | | | | | | | Fixes the comparison of bindparam() objects based on the "callable" parameter being present which helps to correctly detect use_get, and also checks for "callable" when detecting parameters for value substitution and will not impact the object if present. Change-Id: I4c93ee5d404d2648dd9835beeae0c5fb67e37d19 Fixes: #3767
* Repair foreign_keys population for Join._refresh_for_new_columnMike Bayer2016-09-151-0/+38
| | | | | | | | | | Fixed bug where setting up a single-table inh subclass of a joined-table subclass which included an extra column would corrupt the foreign keys collection of the mapped table, thereby interfering with the initialization of relationships. Change-Id: I04a0cf98fd456d12d5a5b9e77a46a01246969a63 Fixes: #3797
* Merge "Allow stringify compiler to render unnamed column"mike bayer2016-09-021-2/+11
|\
| * 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
* | Repair clauselist comparison to account for clause orderingMike Bayer2016-09-021-0/+78
|/ | | | | | | | | | | | | | | | Fixed bug where the "simple many-to-one" condition that allows lazy loading to use get() from identity map would fail to be invoked if the primaryjoin of the relationship had multiple clauses separated by AND which were not in the same order as that of the primary key columns being compared in each clause. This ordering difference occurs for a composite foreign key where the table-bound columns on the referencing side were not in the same order in the .c collection as the primary key columns on the referenced side....which in turn occurs a lot if one is using declarative mixins and/or declared_attr to set up columns. Change-Id: I66cce74f614c04ed693dc0d58ac8c952b2f8ae54 Fixes: #3788
* Spelling fixespr/299Ville Skyttä2016-08-081-1/+1
|
* Build string/int processors for JSONIndexType, JSONPathTypeMike Bayer2016-08-041-0/+71
| | | | | | | | | | | | Fixed regression in JSON datatypes where the "literal processor" for a JSON index value, that needs to take effect for example within DDL, would not be invoked for the value. The native String and Integer datatypes are now called upon from within the JSONIndexType and JSONPathType. This is applied to the generic, Postgresql, and MySQL JSON types. Change-Id: Ifa5f2acfeee57a79d01d7fc85d265a37bd27c716 Fixes: #3765
* Ensure post-__clause_element__() expression are used in IndexMike Bayer2016-07-311-0/+14
| | | | | | | | | | | The change in Index for 1.1 combined with the fix for ref #3763 still fails to deliver the correct object resolved by __clause_element__() to the list of expressions for compilation. Make sure we use the expression that's been unwrapped from __clause_element__(). Change-Id: Ie1df8db5090de665048331786f0024d52851923f Fixes: #3763
* Index should extract __clause_element__() earlyMike Bayer2016-07-301-1/+23
| | | | | | | | | | | | Fixed bug where :class:`.Index` would fail to extract columns from compound SQL expressions if those SQL expressions were wrapped inside of an ORM-style ``__clause_element__()`` construct. This bug exists in 1.0.x as well, however in 1.1 is more noticeable as hybrid_property @expression now returns a wrapped element. Fixes: #3763 Change-Id: I992536386503a1fb3f2305790abe008d72c44c4a
* - Consoliate test/sql/test_constraint ConstraintAPITestMike Bayer2016-07-302-371/+370
| | | | | | | and test/sql/test_metadata IndexTest into test/sql/test_metadata ConstraintTest Change-Id: I7aeee9a1edbbd889200afc393695f73d5fbac3f3
* Allow Table._reset_exported to silently passMike Bayer2016-07-241-0/+15
| | | | | | | | | | | Fixed bug in :class:`.Table` where the internal method ``_reset_exported()`` would corrupt the state of the object. This method is intended for selectable objects and is called by the ORM in some cases; an erroneous mapper configuration would could lead the ORM to call this on on a :class:`.Table` object. Change-Id: I63fa34ee0cdf16358bb125c556390df79758bcbc Fixes: #3755
* - a variety of test adjustments to accomodate for MySQL 5.7Mike Bayer2016-07-241-7/+7
| | | | Change-Id: Ied4245433d0d7b469dae6e7394c4931d8405f387
* Ensure DML provides named_with_column for CTE(Alias)Mike Bayer2016-07-131-0/+32
| | | | | | | | | | | | Fixed bug in new CTE feature for update/insert/delete whereby an anoymous (e.g. no name passed) :class:`.CTE` construct around the statement would fail. The Alias base class of CTE checks for the "named_with_column" attribute in order to detect if the underlying selectable has a name; UpdateBase now provides this as False. Change-Id: I4b0309db21379a4c0cb93085298c86da3cf840e4 Fixes: #3744
* Work w/ prefetch even for selects, if presentMike Bayer2016-07-121-0/+87
| | | | | | | | | | | | | | | | | | | Fixed bug in new CTE feature for update/insert/delete stated as a CTE inside of an enclosing statement (typically SELECT) whereby oninsert and onupdate values weren't called upon for the embedded statement. This is accomplished by consulting prefetch for all statements. The collection is also broken into separate insert/update collections so that we don't need to consult toplevel self.isinsert to determine if the prefetch is for an insert or an update. What we don't yet test for are CTE combinations that have both insert/update in one statement, though these should now work in theory provided the underlying database supports such a statement. Change-Id: I3b6a860e22c86743c91c56a7ec751ff706f66f64 Fixes: #3745
* Preserve type for math negationMike Bayer2016-07-011-0/+6
| | | | | | | | | | Fixed issue in SQL math negation operator where the type of the expression would no longer be the numeric type of the original. This would cause issues where the type determined result set behaviors. Change-Id: If0e339614a3686e251235fc94b6f59310c4630a5 Fixes: #3735
* Make boolean processors consistent between Py/C; coerce to 1/0Mike Bayer2016-06-231-0/+31
| | | | | | | | | | | | | The processing performed by the :class:`.Boolean` datatype for backends that only feature integer types has been made consistent between the pure Python and C-extension versions, in that the C-extension version will accept any integer value from the database as a boolean, not just zero and one; additionally, non-boolean integer values being sent to the database are coerced to exactly zero or one, instead of being passed as the original integer value. Change-Id: I01e647547fd7047bd549dd70e1fa202c51e8328b Fixes: #3730
* 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
* Disable Enum string validation by defaultMike Bayer2016-06-201-6/+65
| | | | | | | | | | | | | | Rolled back the validation rules a bit in :class:`.Enum` to allow unknown string values to pass through, unless the flag ``validate_string=True`` is passed to the Enum; any other kind of object is still of course rejected. While the immediate use is to allow comparisons to enums with LIKE, the fact that this use exists indicates there may be more unknown-string-comparsion use cases than we expected, which hints that perhaps there are some unknown string-INSERT cases too. Change-Id: I7d1d79b374a7d47966d410998f77cd19294ab7b0 Fixes: #3725
* 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
* Add TABLESAMPLE clause support.saarni2016-06-151-0/+54
| | | | | | | | | | The TABLESAMPLE clause allows randomly selecting an approximate percentage of rows from a table. At least DB2, Microsoft SQL Server and recent Postgresql support this standard clause. Fixes: #3718 Change-Id: I3fb8b9223e12a57100df30876b461884c58d72fa Pull-request: https://github.com/zzzeek/sqlalchemy/pull/277
* Deprecate FromClause.count()Mike Bayer2016-06-143-15/+4
| | | | | | | | | | | count() here is misleading in that it not only counts from an arbitrary column in the table, it also does not make accommodations for DISTINCT, JOIN, etc. as the ORM-level function does. Core should not be attempting to provide a function like this. Change-Id: I9916fc51ef744389a92c54660ab08e9695b8afc2 Fixes: #3724
* Ensure CTE internals are handled during cloneMike Bayer2016-06-101-0/+17
| | | | | | | | | The CTE construct was missing a _copy_internals() method which would handle CTE-specific structures including _cte_alias, _restates during a clone operation. Change-Id: I9aeac9cd24d8f7ae6b70e52650d61f7c96cb6d7e Fixes: #3722
* 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
* Add IS (NOT) DISTINCT FROM operatorsSebastian Bank2016-06-061-0/+66
| | | | | | | | | | | None / True / False render as literals. For SQLite, "IS" is used as SQLite lacks "IS DISTINCT FROM" but its "IS" operator acts this way for NULL. Doctext-author: Mike Bayer <mike_mp@zzzcomputing.com> Change-Id: I9227b81f7207b42627a0349d14d40b46aa756cce Pull-request: https://github.com/zzzeek/sqlalchemy/pull/248
* Skip UniqueConstraint marked by unique=True in tometadataMike Bayer2016-06-021-0/+28
| | | | | | | | | | | | | Fixes an issue where a Column would be copied with unique=True and at the same time the UniqueConstraint would also be copied, leading to duplicate UniqueConstraints in the target table, when tometadata() is used. Imitates the same logic used by index=True/Index to avoid duplicates. For some reason a fix was implemented for Index long ago but never for UniqueConstraint. Change-Id: Ie622ee912a6fb8bf0ea900a8b09d78c7ebc79fc0 Fixes: #3721
* Support "blank" schema when MetaData.schema is setMike Bayer2016-05-181-1/+4
| | | | | | | | | | | | | Previously, it was impossible to have a Table that has None for a schema name when the "schema" parameter on MetaData was set. A new symbol sqlalchemy.schema.BLANK_SCHEMA is added which indicates that the schema name should unconditionally be set to None. In particular, this value must be passed within cross-schema foreign key reflection, so that a Table which is in the "default" schema can be represented properly. Fixes: #3716 Change-Id: I3d24f99c22cded206c5379fd32a225e74edb7a8e
* Don't double-process ResultMetaData for BufferedColumnResultProxyMike Bayer2016-04-271-5/+47
| | | | | | | | | | | | Fixed a bug in the result proxy used mainly by Oracle when binary and other LOB types are in play, such that when query / statement caching were used, the type-level result processors, notably that required by the binary type itself but also any other processor, would become lost after the first run of the statement due to it being removed from the cached result metadata. Change-Id: I751940866cffb4f48de46edc8137482eab59790c Fixes: #3699
* Fix result set handling for case insensitive dupe colsMike Bayer2016-04-211-0/+15
| | | | | | | | | | | Fixed bug where when using ``case_sensitive=False`` with an :class:`.Engine`, the result set would fail to correctly accomodate for duplicate column names in the result set, causing an error when the statement is executed in 1.0, and preventing the "ambiguous column" exception from functioning in 1.1. Change-Id: If582bb9fdd057e4da3ae42f7180b17d1a1a2d98e Fixes: #3690
* - limit this to sqlite for nowMike Bayer2016-03-301-0/+1
|
* - move all resultproxy tests intio test_resultsetMike Bayer2016-03-301-1/+336
|
* - Added :meth:`.Select.lateral` and related constructs to allowMike Bayer2016-03-291-0/+134
| | | | | for the SQL standard LATERAL keyword, currently only supported by Postgresql. fixes #2857
* - 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-212-0/+42
| | | | | | | 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-023-48/+62
| | | | | | | test_update - establish consistent names between existing unconsumed names tests and new ones added per ref #3666
* Add test for inserting multiple valuesAthena Yao2016-03-021-0/+38
|
* - 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-202-1/+33
| | | | | | | | | | | | | | | | | | | | | | | 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.
* - CTE functionality has been expanded to support all DML, allowingMike Bayer2016-02-112-4/+153
| | | | | | | INSERT, UPDATE, and DELETE statements to both specify their own WITH clause, as well as for these statements themselves to be CTE expressions when they include a RETURNING clause. fixes #2551
* - Fixed bug in :func:`.expression.text` construct where a double-colonMike Bayer2016-02-091-0/+11
| | | | | | expression would not escape properly, e.g. ``some\:\:expr``, as is most commonly required when rendering Postgresql-style CAST expressions. fixes #3644
* - 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
|
* - add changelog and migration notes for new Enum features,Mike Bayer2016-02-021-27/+149
| | | | | | | | | | | | fixes #3095, #3292 - reorganize enum constructor to again work with the MySQL ENUM type - add a new create_constraint flag to Enum to complement that of Boolean - reinstate the CHECK constraint tests for enum, these already fail /skip against the MySQL backend - simplify lookup rules in Enum, have them apply to all varieties of Enum equally