summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/util.py
Commit message (Collapse)AuthorAgeFilesLines
* Support python3.6Mike Bayer2017-01-131-1/+1
| | | | | | | | | | | 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
* 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
* - 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
* - 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
* - happy new yearMike Bayer2016-01-291-1/+1
|
* - Added support for parameter-ordered SET clauses in an UPDATEMike Bayer2015-11-281-1/+0
| | | | | | | | | | statement. This feature is available by passing the :paramref:`~.sqlalchemy.sql.expression.update.preserve_parameter_order` flag either to the core :class:`.Update` construct or alternatively adding it to the :paramref:`.Query.update.update_args` dictionary at the ORM-level, also passing the parameters themselves as a list of 2-tuples. Thanks to Gorka Eguileor for implementation and tests. adapted from pullreq github:200
* - correct the commit from ref #3582 to refer to the correct sub-elementMike Bayer2015-11-111-1/+1
|
* - Fixed bug where the "single table inheritance" criteria would beMike Bayer2015-11-111-0/+15
| | | | | | | added onto the end of a query in some inappropriate situations, such as when querying from an exists() of a single-inheritance subclass. fixes #3582
* - Added support for "set-aggregate" functions of the formticket_3516Mike Bayer2015-08-261-2/+5
| | | | | | | | | | | ``<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.
* - altered part of the use contract first set up in #2992; weMike Bayer2015-04-271-1/+4
| | | | | | | | now skip textual label references when copying ORDER BY elements to the joined-eager-load subquery, as we can't know that these expressions are compatible with this placement; either because they are meant for text(), or because they refer to label names already stated and aren't bound to a table. fixes #3392
* - copyright 2015Mike Bayer2015-03-101-1/+1
|
* - rework the previous "order by" system in terms of the new one,Mike Bayer2014-09-081-1/+3
| | | | | | | | 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
* - rework ColumnAdapter and ORMAdapter to only provide the featuresticket_3148Mike Bayer2014-09-071-76/+66
| | | | | | | | | | | we're now using; rework them fully so that their behavioral contract is consistent regarding adapter.traverse() vs. adapter.columns[], add a full suite of tests including advanced wrapping scenarios previously only covered by test/orm/test_froms.py and test/orm/inheritance/test_relationships.py - identify several cases where label._order_by_label_clause would be corrupted, e.g. due to adaption or annotation separately - add full tests for #3148
* - enhance ClauseAdapter / ColumnAdapter to have new behaviors with labels.Mike Bayer2014-09-071-10/+18
| | | | | | | | | | | | | | | | | | | | | 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
|
* - apply pep8 formatting to sqlalchemy/sql, sqlalchemy/util, sqlalchemy/dialects,Brian Jarrett2014-07-201-56/+60
| | | | 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
* Fix many typos throughout the codebasepr/85Alex Gaynor2014-04-261-2/+2
| | | | Found using: https://github.com/intgr/topy
* - happy new yearMike Bayer2014-01-051-1/+1
|
* - Fixed bug in default compiler plus those of postgresql, mysql, andMike Bayer2013-10-121-20/+0
| | | | | | | | mssql to ensure that any literal SQL expression values are rendered directly as literals, instead of as bound parameters, within a CREATE INDEX statement. [ticket:2742] - don't need expression_as_ddl(); literal_binds and include_table take care of this functionality.
* - A rework to the way that "quoted" identifiers are handled, in thatMike Bayer2013-08-271-1/+0
| | | | | | | | | | | | | | | | instead of relying upon various ``quote=True`` flags being passed around, these flags are converted into rich string objects with quoting information included at the point at which they are passed to common schema constructs like :class:`.Table`, :class:`.Column`, etc. This solves the issue of various methods that don't correctly honor the "quote" flag such as :meth:`.Engine.has_table` and related methods. The :class:`.quoted_name` object is a string subclass that can also be used explicitly if needed; the object will hold onto the quoting preferences passed and will also bypass the "name normalization" performed by dialects that standardize on uppercase symbols, such as Oracle, Firebird and DB2. The upshot is that the "uppercase" backends can now work with force-quoted names, such as lowercase-quoted names and new reserved words. [ticket:2812]
* - apply an import refactoring to the ORM as wellMike Bayer2013-08-141-1/+3
| | | | | | | | | - 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
* - A large refactoring of the ``sqlalchemy.sql`` package has reorganizedMike Bayer2013-08-121-351/+42
| | | | | | | | | | | | | | | | | | | | | | 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.
* Fixed bug in :class:`.CheckConstraint` DDL where the "quote" flag from aMike Bayer2013-07-171-1/+3
| | | | | :class:`.Column` object would not be propagated. Also in 0.8.3, 0.7.11. [ticket:2784]
* cleanupMike Bayer2013-06-081-4/+1
|
* - Fixed an obscure bug where the wrong results would beMike Bayer2013-06-071-0/+2
| | | | | | | | | | | fetched when joining/joinedloading across a many-to-many relationship to a single-table-inheriting subclass with a specific discriminator value, due to "secondary" rows that would come back. The "secondary" and right-side tables are now inner joined inside of parenthesis for all ORM joins on many-to-many relationships so that the left->right join can accurately filtered. [ticket:2369]
* dial back the default "flatness" a bit, it will be there for joinedload and ↵Mike Bayer2013-06-061-6/+5
| | | | | | | query.join(), but if you're dealing with aliased() or with_polymorphic() you need to say "flat=True". Just the one flag though, "flat" implies "aliased".
* - improve overlapping selectables, apply to both query and relationshipMike Bayer2013-06-041-5/+18
| | | | | | - clean up inspect() calls within query._join() - make sure join.alias(flat) propagates - fix almost all assertion tests
* OK this is the broken version, need to think a lot more about thisMike Bayer2013-06-031-1/+2
|
* - figured out what the from_self() thing was about, part of query.statement, ↵Mike Bayer2013-06-021-1/+0
| | | | | | but would like to improve upon query.statement needing to do this
* getting things to join without subqueries, but some glitches in the compiler ↵Mike Bayer2013-06-021-0/+1
| | | | | | step when we do query.count() are showing
* implement join rewriting inside of visit_select(). Currently this is global ↵Mike Bayer2013-06-021-2/+5
| | | | or not based on fixing nested_join_translation as True or not.
* sqlite testsMike Bayer2013-05-261-2/+2
|
* - the raw 2to3 runMike Bayer2013-04-271-8/+8
| | | | - went through examples/ and cleaned out excess list() calls
* everything passes with this!!!!!!! holy crap !!!!! and its the simplest of allMike Bayer2013-04-251-1/+1
|
* - Fixed bug in unit of work whereby a joined-inheritanceMike Bayer2013-04-011-1/+3
| | | | | | | | | | | subclass could insert the row for the "sub" table before the parent table, if the two tables had no ForeignKey constraints set up between them. Also in 0.7.11. [ticket:2689] - fix a glitch in the assertsql.CompiledSQL fixture regarding when a multiparam compiledSQL is used within an AllOf - add a new utility function randomize_unitofwork() which does the function of --reversetop
* A meaningful :attr:`.QueryableAttribute.info` attribute isMike Bayer2013-03-091-0/+3
| | | | | | | | added, which proxies down to the ``.info`` attribute on either the :class:`.schema.Column` object if directly present, or the :class:`.MapperProperty` otherwise. The full behavior is documented and ensured by tests to remain stable. [ticket:2675]
* Fixed a bug regarding column annotations which in particularMike Bayer2013-02-021-1/+1
| | | | | | | | could impact some usages of the new :func:`.orm.remote` and :func:`.orm.local` annotation functions, where annotations could be lost when the column were used in a subsequent expression. [ticket:2660]
* happy new year (see #2645)Diana Clarke2013-01-011-1/+1
|
* just a pep8 pass of lib/sqlalchemy/sql/Diana Clarke2012-11-191-15/+42
|
* - remove remote_foreign annotationMike Bayer2012-10-281-5/+26
| | | | - support annotations on Column where name isn't immediately present
* - fix the fixture here that wasn't creating consistentlyMike Bayer2012-10-011-3/+4
| | | | | | | - rewrite --dropfirst to be more industrial strength, includes views - fix order_by="foreign_key" to maintain the same ordering as metadata.sorted_tables. Not ideal that this was the other way throughout 0.7 but this is still a little-used method, in contrast to metadata.sorted_tables.
* - use our new Cls.memoized_name._reset(self) method in place of all those ↵Mike Bayer2012-09-231-2/+2
| | | | | | __dict__.pop(), remove reset_memoized
* - we're going to attempt to get the type/operator system to eat its own ↵Mike Bayer2012-08-161-0/+2
| | | | | | | | dogfood and use the type-based comparator in all cases. will attempt to remove the _adapt_expression() method entirely as this represents an incomplete and redundant system (though it might be a lot faster)
* - [feature] Added reduce_columns() methodMike Bayer2012-07-281-47/+12
| | | | | | | | | | | | | | | to select() construct, replaces columns inline using the util.reduce_columns utility function to remove equivalent columns. reduce_columns() also adds "with_only_synonyms" to limit the reduction just to those columns which have the same name. The deprecated fold_equivalents() feature is removed [ticket:1729]. - [feature] Added with_labels and reduce_columns keyword arguments to Query.subquery(), to provide two alternate strategies for producing queries with uniquely- named columns. [ticket:1729].
* - a big renaming of all the _Underscore classes to haveMike Bayer2012-07-171-7/+7
| | | | | | plain names. The old names are still defined for backwards compatibility. - _BindParamClause renamed to BindParameter
* - [bug] ORM will perform extra effort to determineMike Bayer2012-07-051-58/+60
| | | | | | | | | that an FK dependency between two tables is not significant during flush if the tables are related via joined inheritance and the FK dependency is not part of the inherit_condition, saves the user a use_alter directive. [ticket:2527]