summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql
Commit message (Collapse)AuthorAgeFilesLines
* Spelling fixespr/299Ville Skyttä2016-08-081-1/+1
|
* Build string/int processors for JSONIndexType, JSONPathTypeMike Bayer2016-08-041-2/+40
| | | | | | | | | | | | 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-1/+3
| | | | | | | | | | | 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/+4
| | | | | | | | | | | | 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
* Allow Table._reset_exported to silently passMike Bayer2016-07-241-0/+3
| | | | | | | | | | | 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
* Ensure DML provides named_with_column for CTE(Alias)Mike Bayer2016-07-131-0/+1
| | | | | | | | | | | | 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-122-12/+29
| | | | | | | | | | | | | | | | | | | 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
* - fix typoMike Bayer2016-07-071-1/+1
| | | | Change-Id: Ie66d419a5188529a64fcb2e2463c15c26863889f
* Preserve type for math negationMike Bayer2016-07-011-1/+1
| | | | | | | | | | 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
* 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