summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/expression.py
Commit message (Collapse)AuthorAgeFilesLines
* Recognize brackets, quoted_name in SQL Server schemaMike Bayer2017-04-041-2/+3
| | | | | | | | | | | | | 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
* update for 2017 copyrightMike Bayer2017-01-041-1/+1
| | | | Change-Id: I4e8c2aa8fe817bb2af8707410fa0201f938781de
* Correct any_, all_ spellingMike Bayer2016-12-281-1/+1
| | | | | | | | | - Fixed 1.1 regression where "import *" would not work for sqlalchemy.sql.expression, due to mis-spelled "any_" and "all_" functions. Change-Id: I25d1cd34c9239dbdcdb1889c5cda2474557e1418 Fixes: #3878
* Add TABLESAMPLE clause support.saarni2016-06-151-2/+3
| | | | | | | | | | 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
* - Added :meth:`.Select.lateral` and related constructs to allowMike Bayer2016-03-291-4/+6
| | | | | for the SQL standard LATERAL keyword, currently only supported by Postgresql. fixes #2857
* - CTE functionality has been expanded to support all DML, allowingMike Bayer2016-02-111-2/+2
| | | | | | | 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
* - happy new yearMike Bayer2016-01-291-1/+1
|
* - The :func:`.type_coerce` construct is now a fully fledged CoreMike Bayer2015-09-161-1/+2
| | | | | | | | | | | 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-2/+3
| | | | | | | | | | | ``<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-2/+4
| | | | | | - any/all work for Array as well as subqueries, accepted by MySQL - Postgresql ARRAY now subclasses Array - fixes #3516
* - copyright 2015Mike Bayer2015-03-101-1/+1
|
* - correctionsMike Bayer2014-12-271-1/+1
| | | | - attempt to add a script to semi-automate the fixing of links
* - Reversing a change that was made in 0.9, the "singleton" natureMike Bayer2014-10-191-3/+3
| | | | | | | | | 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
* renamed aggregatefilter to funcfilter, since it is thatIlja Everilä2014-09-111-3/+3
|
* implementation for <aggregate_fun> FILTER (WHERE ...)Ilja Everilä2014-09-101-1/+3
|
* - The :func:`~.expression.column` and :func:`~.expression.table`Mike Bayer2014-09-011-1/+2
| | | | | | | | | | | | | | | | | | | | | 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
* - apply pep8 formatting to sqlalchemy/sql, sqlalchemy/util, sqlalchemy/dialects,Brian Jarrett2014-07-201-20/+26
| | | | sqlalchemy/orm, sqlalchemy/event, sqlalchemy/testing
* - break up the <authors> copyright comment as part of a passMike Bayer2014-07-091-1/+2
| | | | to get all flake8 passing
* - Restored the import for :class:`.Function` to the ↵Mike Bayer2014-04-051-1/+1
| | | | | | ``sqlalchemy.sql.expression`` import namespace, which was removed at the beginning of 0.9.
* - happy new yearMike Bayer2014-01-051-1/+1
|
* make generativeselect availableMike Bayer2013-11-291-1/+1
|
* - New improvements to the :func:`.text` construct, includingMike Bayer2013-11-291-2/+2
| | | | | | | | more flexible ways to set up bound parameters and return types; in particular, a :func:`.text` can now be turned into a full FROM-object, embeddable in other statements as an alias or CTE using the new method :meth:`.TextClause.columns`. [ticket:2877]
* Import CTE so that API doc can be generatedVraj Mohan2013-11-141-1/+1
|
* An overhaul of expression handling for special symbols particularlyMike Bayer2013-10-231-5/+6
| | | | | | | | | | with conjunctions, e.g. ``None`` :func:`.expression.null` :func:`.expression.true` :func:`.expression.false`, including consistency in rendering NULL in conjunctions, "short-circuiting" of :func:`.and_` and :func:`.or_` expressions which contain boolean constants, and rendering of boolean constants and expressions as compared to "1" or "0" for backends that don't feature ``true``/``false`` constants. [ticket:2804]
* - The ``version_id_generator`` parameter of ``Mapper`` can now be specifiedMike Bayer2013-08-251-1/+2
| | | | | | | | | | | | | | | | | | | | | to rely upon server generated version identifiers, using triggers or other database-provided versioning features, by passing the value ``False``. The ORM will use RETURNING when available to immediately load the new version identifier, else it will emit a second SELECT. [ticket:2793] - The ``eager_defaults`` flag of :class:`.Mapper` will now allow the newly generated default values to be fetched using an inline RETURNING clause, rather than a second SELECT statement, for backends that support RETURNING. - Added a new variant to :meth:`.ValuesBase.returning` called :meth:`.ValuesBase.return_defaults`; this allows arbitrary columns to be added to the RETURNING clause of the statement without interfering with the compilers usual "implicit returning" feature, which is used to efficiently fetch newly generated primary key values. For supporting backends, a dictionary of all fetched values is present at :attr:`.ResultProxy.returned_defaults`. - add a glossary entry for RETURNING - add documentation for version id generation, [ticket:867]
* - apply an import refactoring to the ORM as wellMike Bayer2013-08-141-32/+31
| | | | | | | | | - rework the event system so that event modules load after their targets, dependencies are reversed - create an improved strategy lookup system for the ORM - rework the ORM to have very few import cycles - move out "importlater" to just util.dependency - other tricks to cross-populate modules in as clear a way as possible
* fix missing savepoint structuresMike Bayer2013-08-121-0/+3
|
* - A large refactoring of the ``sqlalchemy.sql`` package has reorganizedMike Bayer2013-08-121-6606/+79
| | | | | | | | | | | | | | | | | | | | | | the import structure of many core modules. ``sqlalchemy.schema`` and ``sqlalchemy.types`` remain in the top-level package, but are now just lists of names that pull from within ``sqlalchemy.sql``. Their implementations are now broken out among ``sqlalchemy.sql.type_api``, ``sqlalchemy.sql.sqltypes``, ``sqlalchemy.sql.schema`` and ``sqlalchemy.sql.ddl``, the last of which was moved from ``sqlalchemy.engine``. ``sqlalchemy.sql.expression`` is also a namespace now which pulls implementations mostly from ``sqlalchemy.sql.elements``, ``sqlalchemy.sql.selectable``, and ``sqlalchemy.sql.dml``. Most of the "factory" functions used to create SQL expression objects have been moved to classmethods or constructors, which are exposed in ``sqlalchemy.sql.expression`` using a programmatic system. Care has been taken such that all the original import namespaces remain intact and there should be no impact on any existing applications. The rationale here was to break out these very large modules into smaller ones, provide more manageable lists of function names, to greatly reduce "import cycles" and clarify the up-front importing of names, and to remove the need for redundant functions and documentation throughout the expression package.
* - The :meth:`.Operators.notin_` operator added in 0.8 now properlyMike Bayer2013-08-071-1/+4
| | | | | produces the negation of the expression "IN" returns when used against an empty collection. Also in 0.8.3.
* - Fixed bug in common table expression system where if the CTE wereMike Bayer2013-07-311-4/+4
| | | | | | used only as an ``alias()`` construct, it would not render using the WITH keyword. Also in 0.8.3, 0.7.11. [ticket:2783]
* - use inline=True for the insert..select here so it works on oracleMike Bayer2013-07-121-0/+11
|
* Fixed bug where the expression system relied upon the ``str()``Mike Bayer2013-07-121-1/+4
| | | | | | | | | | | | form of a some expressions when referring to the ``.c`` collection on a ``select()`` construct, but the ``str()`` form isn't available since the element relies on dialect-specific compilation constructs, notably the ``__getitem__()`` operator as used with a Postgresql ``ARRAY`` element. The fix also adds a new exception class :class:`.UnsupportedCompilationError` which is raised in those cases where a compiler is asked to compile something it doesn't know how to. Also in 0.8.3. [ticket:2780]
* - Added new method to the :func:`.insert` constructMike Bayer2013-07-051-2/+49
| | | | | | | | | | :meth:`.Insert.from_select`. Given a list of columns and a selectable, renders ``INSERT INTO (table) (columns) SELECT ..``. While this feature is highlighted as part of 0.9 it is also backported to 0.8.3. [ticket:722] - The :func:`.update`, :func:`.insert`, and :func:`.delete` constructs will now interpret ORM entities as FROM clauses to be operated upon, in the same way that select() already does. Also in 0.8.3.
* - rework of correlation, continuing on #2668, #2746Mike Bayer2013-06-261-43/+111
| | | | | | | | | | | | | | | | | | | | | | | | - add support for correlations to propagate all the way in; because correlations require context now, need to make sure a select enclosure of any level takes effect any number of levels deep. - fix what we said correlate_except() was supposed to do when we first released #2668 - "the FROM clause is left intact if the correlated SELECT is not used in the context of an enclosing SELECT..." - it was not considering the "existing_froms" collection at all, and prohibited additional FROMs from being placed in an any() or has(). - add test for multilevel any() - lots of docs, including glossary entries as we really need to define "WHERE clause", "columns clause" etc. so that we can explain correlation better - based on the insight that a SELECT can correlate anything that ultimately came from an enclosing SELECT that links to this one via WHERE/columns/HAVING/ORDER BY, have the compiler keep track of the FROM lists that correspond in this way, link it to the asfrom flag, so that we send to _get_display_froms() the exact list of candidate FROMs to correlate. no longer need any asfrom logic in the Select() itself - preserve 0.8.1's behavior for correlation when no correlate options are given, not to mention 0.7 and prior's behavior of not propagating implicit correlation more than one level.. this is to reduce surprises/hard-to-debug situations when a user isn't trying to correlate anything.
* Provided a new attribute for :class:`.TypeDecorator`Mike Bayer2013-06-221-2/+5
| | | | | | | | | called :attr:`.TypeDecorator.coerce_to_is_types`, to make it easier to control how comparisons using ``==`` or ``!=`` to ``None`` and boolean types goes about producing an ``IS`` expression, or a plain equality expression with a bound parameter. [ticket:2744]
* - tests for the alias() APIMike Bayer2013-06-081-11/+90
| | | | - docs docs docs
* Merge branch 'ticket_2587'Mike Bayer2013-06-041-9/+19
|\ | | | | | | | | | | Conflicts: test/profiles.txt test/sql/test_selectable.py
| * - improve overlapping selectables, apply to both query and relationshipMike Bayer2013-06-041-1/+2
| | | | | | | | | | | | - clean up inspect() calls within query._join() - make sure join.alias(flat) propagates - fix almost all assertion tests
| * here's the flat join thing. it just works. Changing the existing compiled ↵Mike Bayer2013-06-041-5/+14
| | | | | | | | | | | | SQL assertions might even be most of the tests we need (though dedicated sql tests would be needed anyway)
| * getting things to join without subqueries, but some glitches in the compiler ↵Mike Bayer2013-06-021-4/+4
| | | | | | | | | | | | step when we do query.count() are showing
* | Merge branch 'master' into ticket_1068Mike Bayer2013-06-031-59/+47
|\ \ | |/
| * - the distinct hash code logic here is entirely obsolete as you canMike Bayer2013-05-301-11/+0
| | | | | | | | | | do eq_() on columnelements now with a meaningful bool; jython is entirely a non-starter right now in any case as 2.7 doesn't support common accessors like __defaults__
| * Merge branch 'master' into rel_0_9Mike Bayer2013-05-261-1/+1
| |\
| * \ Merge branch 'master' into rel_0_9Mike Bayer2013-05-261-2/+2
| |\ \
| * | | most of ORM passing...Mike Bayer2013-05-041-0/+1
| | | |
| * | | - test_types, test_compiler, with sqlite at leastMike Bayer2013-04-281-2/+1
| | | |
| * | | - endless isinstance(x, str)s....Mike Bayer2013-04-281-50/+45
| | | |
| * | | - the raw 2to3 runMike Bayer2013-04-271-40/+44
| | | | | | | | | | | | | | | | - went through examples/ and cleaned out excess list() calls
* | | | magic accessors to the rescueMike Bayer2013-05-271-0/+13
| |_|/ |/| |
* | | fix this testMike Bayer2013-05-261-1/+1
| |/ |/|