summaryrefslogtreecommitdiff
path: root/test/sql/test_selectable.py
Commit message (Collapse)AuthorAgeFilesLines
* Use consistent method signature for Alias.self_group()Mike Bayer2017-04-031-0/+14
| | | | | | | | | | | | Fixed bug where the use of an :class:`.Alias` object in a column context would raise an argument error when it tried to group itself into a parenthesized expression. Using :class:`.Alias` in this way is not yet a fully supported API, however it applies to some end-user recipes and may have a more prominent role in support of some future Postgresql features. Change-Id: I81717e30416e0350f08d1e022c3d84656e0a9735 Fixes: #3939
* Make all tests to be PEP8 compliantKhairi Hafsham2017-02-071-29/+32
| | | | | | | | tested using pycodestyle version 2.2.0 Fixes: #3885 Change-Id: I5df43adc3aefe318f9eeab72a078247a548ec566 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/343
* Repair foreign_keys population for Join._refresh_for_new_columnMike Bayer2016-09-151-0/+38
| | | | | | | | | | Fixed bug where setting up a single-table inh subclass of a joined-table subclass which included an extra column would corrupt the foreign keys collection of the mapped table, thereby interfering with the initialization of relationships. Change-Id: I04a0cf98fd456d12d5a5b9e77a46a01246969a63 Fixes: #3797
* - Fixed bug where the negation of an EXISTS expression would notMike Bayer2016-03-211-0/+27
| | | | | | | 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
* - calling str() on a core sql construct has been made more "friendly",Mike Bayer2016-01-191-4/+8
| | | | | | | | | | 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
* - Added support for "set-aggregate" functions of the formticket_3516Mike Bayer2015-08-261-2/+2
| | | | | | | | | | | ``<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.
* - The behavior of the :func:`.union` construct and related constructsMike Bayer2015-08-121-0/+20
| | | | | | | | | such as :meth:`.Query.union` now handle the case where the embedded SELECT statements need to be parenthesized due to the fact that they include LIMIT, OFFSET and/or ORDER BY. These queries **do not work on SQLite**, and will fail on that backend as they did before, but should now work on all other backends. fixes #2528
* - Fixed issue where a straight SELECT EXISTS query would fail toMike Bayer2015-04-201-1/+30
| | | | | | | | | | | | | | | | 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
* fooMike Bayer2015-03-081-3/+3
|
* - Fixed bug where a fair number of SQL elements withinMike Bayer2014-10-091-0/+24
| | | | | | | | the sql package would fail to ``__repr__()`` successfully, due to a missing ``description`` attribute that would then invoke a recursion overflow when an internal AttributeError would then re-invoke ``__repr__()``. fixes #3195
* - rework ColumnAdapter and ORMAdapter to only provide the featuresticket_3148Mike Bayer2014-09-071-0/+7
| | | | | | | | | | | 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
* - update the flake8 rules againMike Bayer2014-07-181-275/+349
| | | | - apply autopep8 + manual fixes to most of test/sql/
* - Fixed bug in SQLite join rewriting where anonymized column namesMike Bayer2014-05-251-0/+13
| | | | | | due to repeats would not correctly be rewritten in subqueries. This would affect SELECT queries with any kind of subquery + join. fixes #3057
* Fix many typos throughout the codebasepr/85Alex Gaynor2014-04-261-1/+1
| | | | Found using: https://github.com/intgr/topy
* - add further coverage for join_condition to make sure we get this case whereMike Bayer2014-03-281-0/+10
| | | | there are multiple, equivalent foreign keys
* - Some changes to how the :attr:`.FromClause.c` collection behavesMike Bayer2014-02-261-0/+35
| | | | | | | | | | | | | | | | | | | | | | | when presented with duplicate columns. The behavior of emitting a warning and replacing the old column with the same name still remains to some degree; the replacement in particular is to maintain backwards compatibility. However, the replaced column still remains associated with the ``c`` collection now in a collection ``._all_columns``, which is used by constructs such as aliases and unions, to deal with the set of columns in ``c`` more towards what is actually in the list of columns rather than the unique set of key names. This helps with situations where SELECT statements with same-named columns are used in unions and such, so that the union can match the columns up positionally and also there's some chance of :meth:`.FromClause.corresponding_column` still being usable here (it can now return a column that is only in selectable.c._all_columns and not otherwise named). The new collection is underscored as we still need to decide where this list might end up. Theoretically it would become the result of iter(selectable.c), however this would mean that the length of the iteration would no longer match the length of keys(), and that behavior needs to be checked out. fixes #2974 - add a bunch more tests for ColumnCollection
* - Fixed issue in new :meth:`.TextClause.columns` method where the orderingMike Bayer2014-02-261-0/+25
| | | | | | of columns given positionally would not be preserved. This could have potential impact in positional situations such as applying the resulting :class:`.TextAsFrom` object to a union.
* - for TextAsFrom, put the "inner" columns in the result map directly.Mike Bayer2014-02-101-0/+69
| | | | | | | Have also considered linking column.label() to the "column" itself being in the result map but this reveals some naming collision problems (that also seem to be very poorly tested...). This should be as far as we want to go right now with [ticket:2932].
* - Fixed an 0.9 regression where the automatic aliasing applied byMike Bayer2014-01-231-0/+23
| | | | | | | | | | :class:`.Query` and in other situations where selects or joins were aliased (such as joined table inheritance) could fail if a user-defined :class:`.Column` subclass were used in the expression. In this case, the subclass would fail to propagate ORM-specific "annotations" along needed by the adaptation. The "expression annotations" system has been corrected to account for this case. [ticket:2918]
* - add support for specifying tables or entities for "of"Mike Bayer2013-11-281-0/+7
| | | | | - implement Query with_for_update() - rework docs and tests
* - fix up rendering of "of"Mike Bayer2013-11-281-0/+54
| | | | | | - move out tests, dialect specific out of compiler, compiler tests use new API, legacy API tests in test_selecatble - add support for adaptation of ForUpdateArg, alias support in compilers
* A :func:`.select` that is made to refer to itself in its FROM clause,Mike Bayer2013-10-081-0/+12
| | | | | | typically via in-place mutation, will raise an informative error message rather than causing a recursion overflow. [ticket:2815]
* Fixed bug where using an annotation such as :func:`.remote` orMike Bayer2013-10-081-0/+7
| | | | | | | :func:`.foreign` on a :class:`.Column` before association with a parent :class:`.Table` could produce issues related to the parent table not rendering within joins, due to the inherent copy operation performed by an annotation. [ticket:2813]
* Fixed bug where the expression system relied upon the ``str()``Mike Bayer2013-07-121-0/+13
| | | | | | | | | | | | 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]
* - rework of correlation, continuing on #2668, #2746Mike Bayer2013-06-261-1/+43
| | | | | | | | | | | | | | | | | | | | | | | | - 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.
* The resolution of :class:`.ForeignKey` objects to theirMike Bayer2013-06-231-2/+4
| | | | | | | | | | | | | | | | | | target :class:`.Column` has been reworked to be as immediate as possible, based on the moment that the target :class:`.Column` is associated with the same :class:`.MetaData` as this :class:`.ForeignKey`, rather than waiting for the first time a join is constructed, or similar. This along with other improvements allows earlier detection of some foreign key configuration issues. Also included here is a rework of the type-propagation system, so that it should be reliable now to set the type as ``None`` on any :class:`.Column` that refers to another via :class:`.ForeignKey` - the type will be copied from the target column as soon as that other column is associated, and now works for composite foreign keys as well. [ticket:1765]
* - tests for the alias() APIMike Bayer2013-06-081-1/+74
| | | | - docs docs docs
* fix testMike Bayer2013-06-061-0/+1
|
* Merge branch 'ticket_2587'Mike Bayer2013-06-041-15/+19
|\ | | | | | | | | | | Conflicts: test/profiles.txt test/sql/test_selectable.py
| * repair these tests now that we allow join from selectable to fromgroupingMike Bayer2013-06-041-21/+26
| |
* | Fixed bug whereby joining a select() of a table "A" with multipleMike Bayer2013-06-031-7/+16
|/ | | | | | | | foreign key paths to a table "B", to that table "B", would fail to produce the "ambiguous join condition" error that would be reported if you join table "A" directly to "B"; it would instead produce a join condition with multiple criteria. [ticket:2738]
* Merge branch 'master' into rel_0_9Mike Bayer2013-05-261-1/+1
|\
| * fix this testMike Bayer2013-05-261-1/+1
| |
* | - the raw 2to3 runMike Bayer2013-04-271-17/+17
|/ | | | - went through examples/ and cleaned out excess list() calls
* A major fix to the way in which a select() object producesMike Bayer2013-04-111-0/+153
| | | | | | | | | | | | | | | | | | | labeled columns when apply_labels() is used; this mode produces a SELECT where each column is labeled as in <tablename>_<columnname>, to remove column name collisions for a multiple table select. The fix is that if two labels collide when combined with the table name, i.e. "foo.bar_id" and "foo_bar.id", anonymous aliasing will be applied to one of the dupes. This allows the ORM to handle both columns independently; previously, 0.7 would in some cases silently emit a second SELECT for the column that was "duped", and in 0.8 an ambiguous column error would be emitted. The "keys" applied to the .c. collection of the select() will also be deduped, so that the "column being replaced" warning will no longer emit for any select() that specifies use_labels, though the dupe key will be given an anonymous label which isn't generally user-friendly. [ticket:2702]
* Fixed a bug regarding column annotations which in particularMike Bayer2013-02-021-0/+31
| | | | | | | | 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]
* cleanup and pep8Mike Bayer2013-02-021-56/+52
|
* - BinaryExpression now keeps track of "left" and "right" as passed in,Mike Bayer2012-12-021-1/+3
| | | | | so that they can be compared in ``__nonzero__`` prior to their self_group() step. [ticket:2621]
* Fixed bug in type_coerce() whereby typing informationMike Bayer2012-11-121-0/+9
| | | | | | | | could be lost if the statement were used as a subquery inside of another statement, as well as other similar situations. Among other things, would cause typing information to be lost when the Oracle/mssql dialects would apply limit/offset wrappings. [ticket:2603]
* Fixed bug whereby the ".key" of a Column wasn't beingMike Bayer2012-10-311-0/+25
| | | | | | | used when producing a "proxy" of the column against a selectable. This probably didn't occur in 0.7 since 0.7 doesn't respect the ".key" in a wider range of scenarios. [ticket:2597]
* - remove remote_foreign annotationMike Bayer2012-10-281-0/+7
| | | | - support annotations on Column where name isn't immediately present
* - [feature] "scalar" selects now have a WHERE methodMike Bayer2012-10-151-2/+2
| | | | | | | | | | | | | | | | | | | | to help with generative building. Also slight adjustment regarding how SS "correlates" columns; the new methodology no longer applies meaning to the underlying Table column being selected. This improves some fairly esoteric situations, and the logic that was there didn't seem to have any purpose. - [feature] Some support for auto-rendering of a relationship join condition based on the mapped attribute, with usage of core SQL constructs. E.g. select([SomeClass]).where(SomeClass.somerelationship) would render SELECT from "someclass" and use the primaryjoin of "somerelationship" as the WHERE clause. This changes the previous meaning of "SomeClass.somerelationship" when used in a core SQL context; previously, it would "resolve" to the parent selectable, which wasn't generally useful. Related to [ticket:2245].
* trying different approaches to test layout. in this one, the testing modulesMike Bayer2012-09-271-3/+5
| | | | | | | become an externally usable package but still remains within the main sqlalchemy parent package. in this system, we use kind of an ugly hack to get the noseplugin imported outside of the "sqlalchemy" package, while still making it available within sqlalchemy for usage by third party libraries.
* - aaaaand fix one more glitch I just thought ofMike Bayer2012-08-181-1/+9
|
* - [bug] Declarative can now propagate a columnMike Bayer2012-08-151-0/+129
| | | | | | | | declared on a single-table inheritance subclass up to the parent class' table, when the parent class is itself mapped to a join() or select() statement, directly or via joined inheritane, and not just a Table. [ticket:2549]
* - [feature] Added reduce_columns() methodMike Bayer2012-07-281-5/+59
| | | | | | | | | | | | | | | 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].
* trailing whitespace bonanzaMike Bayer2012-07-281-41/+41
|
* - a big renaming of all the _Underscore classes to haveMike Bayer2012-07-171-1/+1
| | | | | | plain names. The old names are still defined for backwards compatibility. - _BindParamClause renamed to BindParameter
* - [bug] Fixed regression introduced in 0.7.6Mike Bayer2012-06-211-0/+27
| | | | | | whereby the FROM list of a SELECT statement could be incorrect in certain "clone+replace" scenarios. [ticket:2518]
* - [bug] Fixed bug whereby append_column()Mike Bayer2012-06-161-0/+7
| | | | | | | wouldn't function correctly on a cloned select() construct, courtesy Gunnlaugur Por Briem. [ticket:2482] Also in 0.7.8.