summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/elements.py
Commit message (Collapse)AuthorAgeFilesLines
* Allow for multiple FOLLOWING/PRECEDING in a window rangeMike Bayer2017-08-251-23/+15
| | | | | | | | | | | 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
* Repair WithinGroup.get_children()Mike Bayer2017-06-161-1/+1
| | | | | | | | Fixed AttributeError which would occur in :class:`.WithinGroup` construct during an iteration of the structure. Change-Id: I563882d93c8c32292463a605b636aa60c77e9406 Fixes: #4012
* Fix a few doc typosLele Gaifax2017-06-021-5/+5
|
* Add _negate() to Label to negate inner elementMike Bayer2017-04-211-1/+7
| | | | | | | | | Fixed the negation of a :class:`.Label` construct so that the inner element is negated correctly, when the :func:`.not_` modifier is applied to the labeled expression. Change-Id: Ia99917b2959bdfbff28689c962b4203911c57b85 Fixes: #3969
* Add new "expanding" feature to bindparam()Mike Bayer2017-04-071-0/+20
| | | | | | | | | | | | | | | | 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
* Recognize brackets, quoted_name in SQL Server schemaMike Bayer2017-04-041-2/+6
| | | | | | | | | | | | | The SQL Server dialect now allows for a database and/or owner name with a dot inside of it, using brackets explicitly in the string around the owner and optionally the database name as well. In addition, sending the :class:`.quoted_name` construct for the schema name will not split on the dot and will deliver the full string as the "owner". :class:`.quoted_name` is also now available from the ``sqlalchemy.sql`` import space. Change-Id: I77491d63ce47638bd23787d903ccde2f35a9d43d Fixes: #2626
* Treat collation names as identifiersMike Bayer2017-03-231-1/+7
| | | | | | | | | | | The expression used for COLLATE as rendered by the column-level :func:`.expression.collate` and :meth:`.ColumnOperators.collate` is now quoted as an identifier when the name is case sensitive, e.g. has uppercase characters. Note that this does not impact type-level collation, which is already quoted. Change-Id: I83d5d9cd1e66a4f20b96303bb84c5f360d5d6a1a Fixes: #3785
* Support python3.6Mike Bayer2017-01-131-25/+25
| | | | | | | | | | | 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
* update for 2017 copyrightMike Bayer2017-01-041-1/+1
| | | | Change-Id: I4e8c2aa8fe817bb2af8707410fa0201f938781de
* spelling: Postgresql -> PostgreSQLVille Skyttä2016-10-081-4/+4
|
* Support bindparam() with callable for primaryjoinMike Bayer2016-09-191-1/+2
| | | | | | | | | | | 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 clauselist comparison to account for clause orderingMike Bayer2016-09-021-5/+16
| | | | | | | | | | | | | | | | 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
* Check for supports_execution at ClauseElement baseMike Bayer2016-08-311-1/+4
| | | | | | | | | | Raise a more descriptive exception / message when ClauseElement or non-SQLAlchemy objects that are not "executable" are erroneously passed to ``.execute()``; a new exception ObjectNotExecutableError is raised consistently in all cases. Change-Id: I2dd393121e2c7e5b6b9e40286a2f25670876e8e4 Fixes: #3786
* Support range specification in window functionPhillip Cloud2016-06-071-5/+107
| | | | | | | Fixes: #3049 Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Change-Id: Ie572095c3e25f70a1e72e1af6858e5edd89fd25e Pull-request: https://github.com/zzzeek/sqlalchemy/pull/264
* 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
* - Fixed bug where the negation of an EXISTS expression would notMike Bayer2016-03-211-0/+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
* - 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
* - happy new yearMike Bayer2016-01-291-1/+1
|
* - calling str() on a core sql construct has been made more "friendly",Mike Bayer2016-01-191-1/+1
| | | | | | | | | | 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
* - A deep improvement to the recently added :meth:`.TextClause.columns`Mike Bayer2016-01-141-9/+54
| | | | | | | | | | | | | | | | | | | method, and its interaction with result-row processing, now allows the columns passed to the method to be positionally matched with the result columns in the statement, rather than matching on name alone. The advantage to this includes that when linking a textual SQL statement to an ORM or Core table model, no system of labeling or de-duping of common column names needs to occur, which also means there's no need to worry about how label names match to ORM columns and so-forth. In addition, the :class:`.ResultProxy` has been further enhanced to map column and string keys to a row with greater precision in some cases. fixes #3501 - reorganize the initialization of ResultMetaData for readability and complexity; use the name "cursor_description", define the task of "merging" cursor_description with compiled column information as its own function, and also define "name extraction" as a separate task. - fully change the name we use in the "ambiguous column" error to be the actual name that was ambiguous, modify the C ext also
* - fix some old verbiage that refers to text() as an "implicit" thingMike Bayer2016-01-141-8/+7
| | | | | for SQL fragments; we've deprecated that in 1.0 and its a good idea to document like this for 0.9 as well.
* - Added :class:`.mysql.JSON` for MySQL 5.7. The JSON type providesMike Bayer2016-01-061-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | persistence of JSON values in MySQL as well as basic operator support of "getitem" and "getpath", making use of the ``JSON_EXTRACT`` function in order to refer to individual paths in a JSON structure. fixes #3547 - Added a new type to core :class:`.types.JSON`. This is the base of the PostgreSQL :class:`.postgresql.JSON` type as well as that of the new :class:`.mysql.JSON` type, so that a PG/MySQL-agnostic JSON column may be used. The type features basic index and path searching support. fixes #3619 - reorganization of migration docs etc. to try to refer both to the fixes to JSON that helps Postgresql while at the same time indicating these are new features of the new base JSON type. - a rework of the Array/Indexable system some more, moving things that are specific to Array out of Indexable. - new operators for JSON indexing added to core so that these can be compiled by the PG and MySQL dialects individually - rename sqltypes.Array to sqltypes.ARRAY - as there is no generic Array implementation, this is an uppercase type for now, consistent with the new sqltypes.JSON type that is also not a generic implementation. There may need to be some convention change to handle the case of datatypes that aren't generic, rely upon DB-native implementations, but aren't necessarily all named the same thing.
* - The :func:`.type_coerce` construct is now a fully fledged CoreMike Bayer2015-09-161-61/+103
| | | | | | | | | | | 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
* - Added support for "set-aggregate" functions of the formticket_3516Mike Bayer2015-08-261-12/+129
| | | | | | | | | | | ``<function> WITHIN GROUP (ORDER BY <criteria>)``, using the method :class:`.FunctionElement.within_group`. A series of common set-aggregate functions with return types derived from the set have been added. This includes functions like :class:`.percentile_cont`, :class:`.dense_rank` and others. fixes #1370 - make sure we use func.name for all _literal_as_binds in functions.py so we get consistent naming behavior for parameters.
* - build out a new base type for Array, as well as new any/all operatorsMike Bayer2015-08-251-0/+91
| | | | | | - any/all work for Array as well as subqueries, accepted by MySQL - Postgresql ARRAY now subclasses Array - fixes #3516
* - Added new checks for the common error case of passing mapped classesMike Bayer2015-08-221-4/+2
| | | | | | or mapped instances into contexts where they are interpreted as SQL bound parameters; a new exception is raised for this. fixes #3321
* - merge of ticket_3499 indexed access branchMike Bayer2015-08-171-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - The "hashable" flag on special datatypes such as :class:`.postgresql.ARRAY`, :class:`.postgresql.JSON` and :class:`.postgresql.HSTORE` is now set to False, which allows these types to be fetchable in ORM queries that include entities within the row. fixes #3499 - The Postgresql :class:`.postgresql.ARRAY` type now supports multidimensional indexed access, e.g. expressions such as ``somecol[5][6]`` without any need for explicit casts or type coercions, provided that the :paramref:`.postgresql.ARRAY.dimensions` parameter is set to the desired number of dimensions. fixes #3487 - The return type for the :class:`.postgresql.JSON` and :class:`.postgresql.JSONB` when using indexed access has been fixed to work like Postgresql itself, and returns an expression that itself is of type :class:`.postgresql.JSON` or :class:`.postgresql.JSONB`. Previously, the accessor would return :class:`.NullType` which disallowed subsequent JSON-like operators to be used. part of fixes #3503 - The :class:`.postgresql.JSON`, :class:`.postgresql.JSONB` and :class:`.postgresql.HSTORE` datatypes now allow full control over the return type from an indexed textual access operation, either ``column[someindex].astext`` for a JSON type or ``column[someindex]`` for an HSTORE type, via the :paramref:`.postgresql.JSON.astext_type` and :paramref:`.postgresql.HSTORE.text_type` parameters. also part of fixes #3503 - The :attr:`.postgresql.JSON.Comparator.astext` modifier no longer calls upon :meth:`.ColumnElement.cast` implicitly, as PG's JSON/JSONB types allow cross-casting between each other as well. Code that makes use of :meth:`.ColumnElement.cast` on JSON indexed access, e.g. ``col[someindex].cast(Integer)``, will need to be changed to call :attr:`.postgresql.JSON.Comparator.astext` explicitly. This is part of the refactor in references #3503 for consistency in operator use.
* - changelog for #3459, fixes #3459Mike Bayer2015-07-191-1/+4
| | | | | - test for .cast() method has no good place now except for test_cast in test_compiler.py
* Merge branch 'bb_issue_3459' of https://bitbucket.org/xflr6/sqlalchemy into pr56Mike Bayer2015-07-191-0/+7
|\
| * add ClauseElement.cast() shortcut-methodSebastian Bank2015-06-191-0/+7
| |
* | - Fixed bug where coersion of literal ``True`` or ``False`` constantMike Bayer2015-07-191-2/+5
| | | | | | | | | | | | in conjunction with :func:`.and_` or :func:`.or_` would fail with an AttributeError. fixes #3490
* | - Fixed potential issue where a custom subclassMike Bayer2015-07-191-1/+8
|/ | | | | | | of :class:`.FunctionElement` or other column element that incorrectly states 'None' or any other invalid object as the ``.type`` attribute will report this exception instead of recursion overflow. fixes #3485
* - Fixed a bug where clause adaption as applied to a :class:`.Label`Mike Bayer2015-06-091-1/+2
| | | | | | | | | | | | object would fail to accommodate the labeled SQL expression in all cases, such that any SQL operation that made use of :meth:`.Label.self_group` would use the original unadapted expression. One effect of this would be that an ORM :func:`.aliased` construct would not fully accommodate attributes mapped by :obj:`.column_property`, such that the un-aliased table could leak out when the property were used in some kinds of SQL comparisons. fixes #3445
* - Fixed a regression that was incorrectly fixed in 1.0.0b4Mike Bayer2015-04-241-0/+10
| | | | | | | | | | | | | | | | | | (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 issue where a straight SELECT EXISTS query would fail toMike Bayer2015-04-201-7/+17
| | | | | | | | | | | | | | | | 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
* - Fixed bug in new "label resolution" feature of :ticket:`2992` whereMike Bayer2015-03-231-1/+3
| | | | | | | | a label that was anonymous, then labeled again with a name, would fail to be locatable via a textual label. This situation occurs naturally when a mapped :func:`.column_property` is given an explicit label in a query. fixes #3340
* - copyright 2015Mike Bayer2015-03-101-1/+1
|
* Merge remote-tracking branch 'origin/pr/150'Mike Bayer2015-01-261-1/+2
|\
| * Report the type of unexpected expression objectspr/150Ryan P. Kelly2014-11-201-1/+2
| |
* | - add MemoizedSlots, a generalized solution to using __getattr__Mike Bayer2015-01-051-5/+13
| | | | | | | | | | for memoization on a class that uses slots. - apply many more __slots__. mem use for nova now at 46% savings
* | - typo fixes #3269Mike Bayer2014-12-271-1/+1
| |
* | Maul the evaulate & friends typoPriit Laes2014-12-191-1/+1
| |
* | - The :meth:`.Operators.match` operator is now handled such that theMike Bayer2014-12-041-1/+1
|/ | | | | | | | | | | | | | | | return type is not strictly assumed to be boolean; it now returns a :class:`.Boolean` subclass called :class:`.MatchType`. The type will still produce boolean behavior when used in Python expressions, however the dialect can override its behavior at result time. In the case of MySQL, while the MATCH operator is typically used in a boolean context within an expression, if one actually queries for the value of a match expression, a floating point value is returned; this value is not compatible with SQLAlchemy's C-based boolean processor, so MySQL's result-set behavior now follows that of the :class:`.Float` type. A new operator object ``notmatch_op`` is also added to better allow dialects to define the negation of a match operation. fixes #3263
* - The :attr:`.Column.key` attribute is now used as the source ofMike Bayer2014-11-101-2/+2
| | | | | | | | | | | 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
* - Fixed bug regarding expression mutations which could expressMike Bayer2014-11-051-0/+7
| | | | | | | | itself as a "Could not locate column" error when using :class:`.Query` to select from multiple, anonymous column entities when querying against SQLite, as a side effect of the "join rewriting" feature used by the SQLite dialect. fixes #3241
* - Reversing a change that was made in 0.9, the "singleton" natureMike Bayer2014-10-191-14/+10
| | | | | | | | | of the "constants" :func:`.null`, :func:`.true`, and :func:`.false` has been reverted. These functions returning a "singleton" object had the effect that different instances would be treated as the same regardless of lexical use, which in particular would impact the rendering of the columns clause of a SELECT statement. fixes #3170
* Merge remote-tracking branch 'origin/pr/140' into pr140Mike Bayer2014-10-111-1/+1
|\
| * cleanup exception handling - use new exception hierarchy (since python 2.5)pr/140ndparker2014-10-021-3/+1
| |
| * improve exception vs. exit handlingndparker2014-09-231-0/+2
| |