summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/compiler.py
Commit message (Collapse)AuthorAgeFilesLines
* add CYCLE support to Sequence() and docstrings for NO MINVALUE and NO MAXVALUEpr/186jakeogh2015-06-271-2/+4
|
* add NO MINVALUE and NO MAXVALUE support to Sequence()jakeogh2015-06-271-0/+4
|
* add MAXVALUE support to Sequence()jakeogh2015-06-271-0/+2
|
* add MINVALUE support to Sequence()jakeogh2015-06-271-0/+2
|
* - Added official support for a CTE used by the SELECT presentMike Bayer2015-05-081-1/+15
| | | | | | | | | | | inside of :meth:`.Insert.from_select`. This behavior worked accidentally up until 0.9.9, when it no longer worked due to unrelated changes as part of :ticket:`3248`. Note that this is the rendering of the WITH clause after the INSERT, before the SELECT; the full functionality of CTEs rendered at the top level of INSERT, UPDATE, DELETE is a new feature targeted for a later release. fixes #3418
* - Fixed bug where the truncation of long labels in SQL could produceMike Bayer2015-04-281-1/+1
| | | | | | | | | | a label that overlapped another label that is not truncated; this because the length threshhold for truncation was greater than the portion of the label that remains after truncation. These two values have now been made the same; label_length - 6. The effect here is that shorter column labels will be "truncated" where they would not have been truncated before. fixes #3396
* - Fixed support for "literal_binds" mode when using limit/offsetMike Bayer2015-04-231-2/+2
| | | | | | with Firebird, so that the values are again rendered inline when this is selected. Related to :ticket:`3034`. fixes #3381
* - Fixed issue where a straight SELECT EXISTS query would fail toMike Bayer2015-04-201-4/+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/+0
| | | | | | | | 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
|
* - rename _select_wrapsMike Bayer2015-03-081-13/+33
| | | | | - replace force_result_map with a mini-API for nested result sets, add coverage
* fooMike Bayer2015-03-081-16/+5
|
* - the change for #918 was of course not nearly that simple.Mike Bayer2015-03-071-33/+45
| | | | | | | | | | | | | | | | | | The "wrapping" employed by the mssql and oracle dialects using the "iswrapper" argument was not being used intelligently by the compiler, and the result map was being written incorrectly, using *more* columns in the result map than were actually returned by the statement, due to "row number" columns that are inside the subquery. The compiler now writes out result map on the "top level" select in all cases fully, and for the mssql/oracle wrapping case extracts out the "proxied" columns in a second step, which only includes those columns that are proxied outwards to the top level. This change might have implications for 3rd party dialects that might be imitating oracle's approach. They can safely continue to use the "iswrapper" kw which is now ignored, but they may need to also add the _select_wraps argument as well.
* - The SQL compiler now generates the mapping of expected columnspositional_targetingMike Bayer2015-03-071-13/+29
| | | | | | | | | | | | | | | | | such that they are matched to the received result set positionally, rather than by name. Originally, this was seen as a way to handle cases where we had columns returned with difficult-to-predict names, though in modern use that issue has been overcome by anonymous labeling. In this version, the approach basically reduces function call count per-result by a few dozen calls, or more for larger sets of result columns. The approach still degrades into a modern version of the old approach if textual elements modify the result map, or if any discrepancy in size exists between the compiled set of columns versus what was received, so there's no issue for partially or fully textual compilation scenarios where these lists might not line up. fixes #918 - callcounts still need to be adjusted down for this so zoomark tests won't pass at the moment
* - Literal values within a :class:`.DefaultClause`, which is invokedMike Bayer2015-02-091-1/+2
| | | | | | | when using the :paramref:`.Column.server_default` parameter, will now be rendered using the "inline" compiler, so that they are rendered as-is, rather than as bound parameters. fixes #3087
* - Custom dialects that implement :class:`.GenericTypeCompiler` canMike Bayer2015-01-161-66/+69
| | | | | | | | | | | | | | now be constructed such that the visit methods receive an indication of the owning expression object, if any. Any visit method that accepts keyword arguments (e.g. ``**kw``) will in most cases receive a keyword argument ``type_expression``, referring to the expression object that the type is contained within. For columns in DDL, the dialect's compiler class may need to alter its ``get_column_specification()`` method to support this as well. The ``UserDefinedType.get_col_spec()`` method will also receive ``type_expression`` if it provides ``**kw`` in its argument signature. fixes #3074
* - restate sort_tables in terms of a more fine grainedMike Bayer2015-01-011-4/+25
| | | | | | | | | | | | | sort_tables_and_constraints function. - The DDL generation system of :meth:`.MetaData.create_all` and :meth:`.Metadata.drop_all` has been enhanced to in most cases automatically handle the case of mutually dependent foreign key constraints; the need for the :paramref:`.ForeignKeyConstraint.use_alter` flag is greatly reduced. The system also works for constraints which aren't given a name up front; only in the case of DROP is a name required for at least one of the constraints involved in the cycle. fixes #3282
* - Added support for CTEs under Oracle. This includes some tweaksMike Bayer2014-12-041-3/+14
| | | | | | | to the aliasing syntax, as well as a new CTE feature :meth:`.CTE.suffix_with`, which is useful for adding in special Oracle-specific directives to the CTE. fixes #3220
* - The :meth:`.Operators.match` operator is now handled such that theMike Bayer2014-12-041-2/+7
| | | | | | | | | | | | | | | | 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 behavioral contract of the :attr:`.ForeignKeyConstraint.columns`Mike Bayer2014-11-251-3/+3
| | | | | | | | collection has been made consistent; this attribute is now a :class:`.ColumnCollection` like that of all other constraints and is initialized at the point when the constraint is associated with a :class:`.Table`. fixes #3243
* - Fixed issue where the columns from a SELECT embedded in anMike Bayer2014-11-111-0/+8
| | | | | | | | | INSERT, either through the values clause or as a "from select", would pollute the column types used in the result set produced by the RETURNING clause when columns from both statements shared the same name, leading to potential errors or mis-adaptation when retrieving the returning rows. fixes #3248
* - ensure kwargs are passed for limit clause on a compound select as well,Mike Bayer2014-10-311-1/+1
| | | | further fixes for #3034
* - :meth:`.Insert.from_select` now includes Python and SQL-expressionMike Bayer2014-10-101-1/+1
| | | | | | | defaults if otherwise unspecified; the limitation where non- server column defaults aren't included in an INSERT FROM SELECT is now lifted and these expressions are rendered as constants into the SELECT statement.
* Merge remote-tracking branch 'origin/pr/134' into pr134Mike Bayer2014-10-041-0/+6
|\
| * 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-0/+6
| |
* | - cyclomatic complexity; break up visit_select, goes from F to DMike Bayer2014-09-271-52/+69
| |
* | - cyclomatic complexity: _get_colparams() becomes sql.crud._get_crud_params,Mike Bayer2014-09-271-421/+38
| | | | | | | | CC goes from F to D
* | - Added new method :meth:`.Select.with_statement_hint` and ORMMike Bayer2014-09-181-0/+12
|/ | | | | | method :meth:`.Query.with_statement_hint` to support statement-level hints that are not specific to a table. fixes #3206
* - rework the previous "order by" system in terms of the new one,Mike Bayer2014-09-081-36/+40
| | | | | | | | unify everything. - create a new layer of separation between the "from order bys" and "column order bys", so that an OVER doesn't ORDER BY a label in the same columns clause - identify another issue with polymorphic for ref #3148, match on label keys rather than the objects
* - enhance ClauseAdapter / ColumnAdapter to have new behaviors with labels.Mike Bayer2014-09-071-8/+2
| | | | | | | | | | | | | | | | | | | | | The "anonymize label" logic is now generalized to ClauseAdapter, and takes place when the anonymize_labels flag is sent, taking effect for all .columns lookups as well as within traverse() calls against the label directly. - traverse() will also memoize what it gets in columns, so that calling upon traverse() / .columns against the same Label will produce the same anonymized label. This is so that AliasedClass produces the same anonymized label when it is accessed per-column (e.g. SomeAlias.some_column) as well as when it is applied to a Query, and within column loader strategies (e.g. query(SomeAlias)); the former uses traverse() while the latter uses .columns - AliasedClass now calls onto ColumnAdapter - Query also makes sure to use that same ColumnAdapter from the AliasedClass in all cases - update the logic from 0.9 in #1068 to make use of the same _label_resolve_dict we use for #2992, simplifying how that works and adding support for new scenarios that were pretty broken (see #3148, #3188)
* wip for #3148Mike Bayer2014-09-061-1/+5
|
* - tiny refactors #1-#5Mike Bayer2014-09-051-3/+12
|
* - ensure literal_binds works with LIMIT clause, FOR UPDATEMike Bayer2014-09-031-6/+6
|
* - add logic to compiler such that if stack is empty, we justMike Bayer2014-09-021-1/+7
| | | | | | | | | | | | | | | | stringify a _label_reference() as is. - add .key to _label_reference(), so that when _make_proxy() is called, we don't call str() on it anyway. - add a test to exercise Query's behavior of adding all the order_by expressions to the columns list of the select, assert that things work out when we have a _label_reference there, that it gets sucked into the columns list and spit out on the other side, it's referred to appropriately, etc. _label_reference() could theoretically be resolved at the point we iterate _raw_columns() but it's better to just let things work as they already do (except nicer, since we get "tablename.colname" instead of just "somename" in the columns list) so that we aren't adding a ton of overhead to _columns_plus_names in the common case.
* - The :func:`~.expression.column` and :func:`~.expression.table`Mike Bayer2014-09-011-4/+24
| | | | | | | | | | | | | | | | | | | | | 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
* - The INSERT...FROM SELECT construct now implies ``inline=True``Mike Bayer2014-08-201-1/+3
| | | | | | | | | | | | | | | | | | | | | | | on :class:`.Insert`. This helps to fix a bug where an INSERT...FROM SELECT construct would inadvertently be compiled as "implicit returning" on supporting backends, which would cause breakage in the case of an INSERT that inserts zero rows (as implicit returning expects a row), as well as arbitrary return data in the case of an INSERT that inserts multiple rows (e.g. only the first row of many). A similar change is also applied to an INSERT..VALUES with multiple parameter sets; implicit RETURNING will no longer emit for this statement either. As both of these constructs deal with varible numbers of rows, the :attr:`.ResultProxy.inserted_primary_key` accessor does not apply. Previously, there was a documentation note that one may prefer ``inline=True`` with INSERT..FROM SELECT as some databases don't support returning and therefore can't do "implicit" returning, but there's no reason an INSERT...FROM SELECT needs implicit returning in any case. Regular explicit :meth:`.Insert.returning` should be used to return variable numbers of result rows if inserted data is needed. fixes #3169
* - Fixed bug in CTE where ``literal_binds`` compiler argument would notMike Bayer2014-08-021-1/+1
| | | | | | be always be correctly propagated when one CTE referred to another aliased CTE in a statement. Fixes #3154
* - apply pep8 formatting to sqlalchemy/sql, sqlalchemy/util, sqlalchemy/dialects,Brian Jarrett2014-07-201-504/+515
| | | | sqlalchemy/orm, sqlalchemy/event, sqlalchemy/testing
* - Fixed a SQLite join rewriting issue where a subquery that is embeddedMike Bayer2014-07-151-8/+10
| | | | | | | | as a scalar subquery such as within an IN would receive inappropriate substitutions from the enclosing query, if the same table were present inside the subquery as were in the enclosing query such as in a joined inheritance scenario. fixes #3130
* - allow the compilation rule that gets the formatted nameMike Bayer2014-07-141-13/+19
| | | | | to again have the chance to veto rendering, as the naming convention can make the decision that the name is "none" or not now.
* - Fix bug in naming convention feature where using a checkMike Bayer2014-07-141-1/+7
| | | | | | | | | | | | | constraint convention that includes ``constraint_name`` would then force all :class:`.Boolean` and :class:`.Enum` types to require names as well, as these implicitly create a constraint, even if the ultimate target backend were one that does not require generation of the constraint such as Postgresql. The mechanics of naming conventions for these particular constraints has been reorganized such that the naming determination is done at DDL compile time, rather than at constraint/table construction time. fixes #3067
* -Fixed bug in common table expressions whereby positional boundMike Bayer2014-07-141-7/+10
| | | | | | parameters could be expressed in the wrong final order when CTEs were nested in certain ways. fixes #3090
* - Fixed bug where multi-valued :class:`.Insert` construct would failMike Bayer2014-07-141-2/+4
| | | | | | to check subsequent values entries beyond the first one given for literal SQL expressions. fixes #3069
* - break up the <authors> copyright comment as part of a passMike Bayer2014-07-091-1/+2
| | | | to get all flake8 passing
* - attach the ResultMetaData to the Compiled object, when we detect thatMike Bayer2014-06-291-0/+2
| | | | | the compiled cache is used. That allows us to cache the whole metadata and save on creating it at result time, when compiled cache is used.
* Update compiler.pyBY-jk2014-06-081-1/+2
| | | | | | Moved initialization into else block Conflicts: lib/sqlalchemy/sql/compiler.py
* Merge branch 'issue_3034' of ↵Mike Bayer2014-05-161-7/+7
|\ | | | | | | https://bitbucket.org/dobesv/sqlalchemy/branch/issue_3034 into ticket_3034
| * Remove unused importDobes Vandermeer2014-04-251-1/+0
| |
| * Use _offset_clause and _limit_clause, which are always Visitable and usually ↵Dobes Vandermeer2014-04-251-7/+7
| | | | | | | | a BindParameter, instead of _offset and _limit in GenerativeSelect.