summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql
Commit message (Collapse)AuthorAgeFilesLines
* Don't reorder PrimaryKeyConstraint columns if explicitMike Bayer2016-06-202-2/+9
| | | | | | | | | | | 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-2/+23
| | | | | | | | | | | | | | 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-1/+10
| | | | | | | Allows custom dialects to add keywords after the CREATE TABLE section. Change-Id: I6fa66dfcf00ef95122f491a9115410df2746cf88
* Merge "Add TABLESAMPLE clause support."mike bayer2016-06-154-2/+108
|\
| * Add TABLESAMPLE clause support.saarni2016-06-154-2/+108
| | | | | | | | | | | | | | | | | | | | 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
* | Merge "Interpret lateral, alias as from clauses"mike bayer2016-06-151-2/+2
|\ \ | |/ |/|
| * Interpret lateral, alias as from clausesMike Bayer2016-06-151-2/+2
| | | | | | | | | | | | Also add doc members for Lateral. Change-Id: Ic801c296377ce84230139c6a43ecb3e93a852832
* | Add `sqlalchemy.ext.index` for indexed attributes for ORMJeong YunWon2016-06-151-0/+4
|/ | | | | | | | | Add `sqlalchemy.ext.index.index_property` which subscribe an index of a column with `Indexable` type. Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Change-Id: I238c23131e4fded5dc7f7a25eb02e26008099d00 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/235
* Merge "Add ON CONFLICT support for Postgresql"mike bayer2016-06-142-0/+7
|\
| * Add ON CONFLICT support for PostgresqlRobin Thomas2016-06-142-0/+7
| | | | | | | | | | | | | | Fixes: #3529 Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Change-Id: Ie3bf6ad70d9be9f0e44938830e922db03573991a Pull-request: https://github.com/zzzeek/sqlalchemy/pull/258
* | Deprecate FromClause.count()Mike Bayer2016-06-141-16/+25
| | | | | | | | | | | | | | | | | | | | | | 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/+8
|/ | | | | | | | | 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
* Merge "Add 'FOR NO KEY UPDATE' / 'FOR KEY SHARE' support for Postgresql"mike bayer2016-06-081-5/+12
|\
| * Add 'FOR NO KEY UPDATE' / 'FOR KEY SHARE' support for PostgresqlSergey Skopin2016-06-081-5/+12
| | | | | | | | | | | | | | | | Adds ``key_share=True`` for with_for_update(). Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Change-Id: I74e0c3fcbc023e1dc98a1fa0c7db67b4c3693a31 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/279
* | Support range specification in window functionPhillip Cloud2016-06-073-9/+142
|/ | | | | | | 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-063-2/+46
| | | | | | | | | | | 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
* Add SKIP LOCKED support for Postgresql, OracleJack Zhou2016-06-021-3/+14
| | | | | | | | This adds `SELECT ... FOR UPDATE SKIP LOCKED`/ `SELECT ... FOR SHARE SKIP LOCKED` rendering. Change-Id: Id1dc4f1cafc1de23f397a6f73d54ab2c58d5910d Pull-request: https://bitbucket.org/zzzeek/sqlalchemy/pull-requests/86
* Skip UniqueConstraint marked by unique=True in tometadataMike Bayer2016-06-021-1/+7
| | | | | | | | | | | | | 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
* Merge remote-tracking branch 'origin/pr/270'Mike Bayer2016-05-241-1/+1
|\
| * Spelling fixes: "an SQL" -> "a SQL", see #266pr/270Ville Skyttä2016-05-051-1/+1
| |
* | Support "blank" schema when MetaData.schema is setMike Bayer2016-05-181-4/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Fix label referencing in SQL Server OFFSET logicMike Bayer2016-05-101-0/+10
| | | | | | | | | | | | | | | | | | | | Fixed bug where by ROW_NUMBER OVER clause applied for OFFSET selects in SQL Server would inappropriately substitute a plain column from the local statement that overlaps with a label name used by the ORDER BY criteria of the statement. Change-Id: Ic2500c886cbfc83a1ad5a2681783f008b9f23838 Fixes: #3711
* | Repair _orm_columns() to accommodate text()Mike Bayer2016-05-051-0/+2
|/ | | | | | | | | Fixed bug whereby passing a :func:`.text` construct to the :meth:`.Query.group_by` method would raise an error, instead of intepreting the object as a SQL fragment. Change-Id: I5fc2f590b76508d52e23b5fa9cf037ddea8080c3 fixes: #3706
* Adds parentheses around prints in documentationpr/263jfinkels2016-04-271-7/+7
| | | This makes the docstring example code compatible with both Python 2 and Python 3.
* - Added :meth:`.Select.lateral` and related constructs to allowMike Bayer2016-03-294-10/+77
| | | | | 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-282-11/+33
| | | | Pull request courtesy Stefan Urbanek. fixes #1957
* - Fixed bug where the negation of an EXISTS expression would notMike Bayer2016-03-212-1/+13
| | | | | | | 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
* Raise exception when we have multiple values with an unknown column. Fixes ↵Athena Yao2016-03-021-1/+1
| | | | #3666.
* - unfortunately calling upon "_label" here makes it unclear ifMike Bayer2016-02-261-2/+4
| | | | | | | we're trying to hit columns without names yet and such, to suit the bug right now just make it specific to FunctionElement (cherry picked from commit 785224a92f39bd5bdd05bbc66f4dd79736abded5)
* - Anonymous labeling is applied to a :attr:`.func` construct that isMike Bayer2016-02-261-1/+1
| | | | | | | | | passed to :func:`.column_property`, so that if the same attribute is referred to as a column expression twice the names are de-duped, thus avoiding "ambiguous column" errors. Previously, the ``.label(None)`` would need to be applied in order for the name to be de-anonymized. fixes #3663
* - additional adjustment to the fix made in ↵Mike Bayer2016-02-211-1/+4
| | | | | | | | | | | | | | | 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-7/+3
| | | | | | | | | | | | | | | | | | | | | | | 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.
* - further edit the unnest() example to suit PG's esoteric requirementsMike Bayer2016-02-181-4/+6
| | | | exactly
* - handle parameter sets that aren't correctly formed, so thatMike Bayer2016-02-171-1/+1
| | | | | for example an exception object made within a test suite can still repr (error seen in Keystone)
* - do the trailing comma logic of tuple repr() exactlyMike Bayer2016-02-171-4/+7
|
* - All string formatting of bound parameter sets and result rows forMike Bayer2016-02-171-10/+107
| | | | | | | | | logging, exception, and ``repr()`` purposes now truncate very large scalar values within each collection, including an "N characters truncated" notation, similar to how the display for large multiple-parameter sets are themselves truncated. fixes #2837
* - use same colname as the alias we give to the PG functionMike Bayer2016-02-161-2/+2
| | | | here, fixes #3652
* - CTE functionality has been expanded to support all DML, allowingMike Bayer2016-02-115-170/+272
| | | | | | | 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
* - A refinement to the logic which adds columns to the resulting SQL whenMike Bayer2016-02-091-0/+22
| | | | | | | | | | | | | :meth:`.Query.distinct` is combined with :meth:`.Query.order_by` such that columns which are already present will not be added a second time, even if they are labeled with a different name. Regardless of this change, the extra columns added to the SQL have never been returned in the final result, so this change only impacts the string form of the statement as well as its behavior when used in a Core execution context. Additionally, columns are no longer added when the DISTINCT ON format is used, provided the query is not wrapped inside a subquery due to joined eager loading. fixes #3641
* - oracle requires GLOBAL hereMike Bayer2016-02-031-1/+1
|
* - add literal_binds for delete() statements in addition to insert()/update()Mike Bayer2016-02-031-1/+1
| | | | | - move tests to CRUDTest - changelog, fixes #3643
* fix passing literal_binds flag through for update and insertpr/232Tim Tate2016-02-022-4/+5
|
* - add changelog and migration notes for new Enum features,Mike Bayer2016-02-021-49/+126
| | | | | | | | | | | | 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
* - Initial implementation of support for PEP-435 enumerated typesAlex Grönholm2016-02-021-5/+72
| | | | within the Enum type.
* - Fixed issue where inadvertent use of the Python ``__contains__``Mike Bayer2016-02-022-1/+5
| | | | | | | | | override with a column expression (e.g. by using ``'x' in col``) would cause an endless loop in the case of an ARRAY type, as Python defers this to ``__getitem__`` access which never raises for this type. Overall, all use of ``__contains__`` now raises NotImplementedError. fixes #3642
* - happy new yearMike Bayer2016-01-2919-19/+19
|
* - unfortunately we need to match within join where col.key does not matchMike Bayer2016-01-261-2/+1
| | | | | what's given so we need to use a set() here. contains_column is not within any performance paths
* - rework ColumnCollection to no longer persist "all_col_set"; we don'tMike Bayer2016-01-261-20/+9
| | | | | | | | | | | | | need this collection except in the extend/update uses where we create it ad-hoc. simplifies pickling. Compatibility with 1.0 should be OK as ColumnColleciton uses __getstate__ in any case and the __setstate__ contract hasn't changed. - Fixed bug in :class:`.Table` metadata construct which appeared around the 0.9 series where adding columns to a :class:`.Table` that was unpickled would fail to correctly establish the :class:`.Column` within the 'c' collection, leading to issues in areas such as ORM configuration. This could impact use cases such as ``extend_existing`` and others. fixes #3632
* - The workaround for right-nested joins on SQLite, where they are rewrittenMike Bayer2016-01-261-1/+1
| | | | | | | | | | as subqueries in order to work around SQLite's lack of support for this syntax, is lifted when SQLite version 3.7.16 or greater is detected. fixes #3634 - The workaround for SQLite's unexpected delivery of column names as ``tablename.columnname`` for some kinds of queries is now disabled when SQLite version 3.10.0 or greater is detected. fixes #3633
* - generalize the verbiage on LargeBinary so that it doesn'tMike Bayer2016-01-201-10/+5
| | | | create confusion for inherited classes such as BYTEA, fixes