summaryrefslogtreecommitdiff
path: root/test/sql/test_selectable.py
Commit message (Collapse)AuthorAgeFilesLines
* - 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.
* - [bug] column.label(None) now produces anMike Bayer2012-04-241-6/+5
| | | | | | anonymous label, instead of returning the column object itself, consistent with the behavior of label(column, None). [ticket:2168]
* - [bug] The names of the columns on theMike Bayer2012-04-241-2/+11
| | | | | | | | .c. attribute of a select().apply_labels() is now based on <tablename>_<colkey> instead of <tablename>_<colname>, for those columns that have a distinctly named .key. [ticket:2397]
* - merged #1401 branch from bitbucketMike Bayer2012-04-221-7/+91
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - resolved some serious speed hits I missed, we need to ensure only deannotated columns are used in the local/remote collections and soforth so that hash lookups against mapped columns don't dig into __eq__() - fix some other parity mismatches regarding stuff from [ticket:2453], including finding another case where _deep_annotate() was doing the wrong thing, new tests. - [feature] Major rewrite of relationship() internals now allow join conditions which include columns pointing to themselves within composite foreign keys. A new API for very specialized primaryjoin conditions is added, allowing conditions based on SQL functions, CAST, etc. to be handled by placing the annotation functions remote() and foreign() inline within the expression when necessary. Previous recipes using the semi-private _local_remote_pairs approach can be upgraded to this new approach. [ticket:1401]
| * - figured out again why deannotate must clone()Mike Bayer2012-02-111-3/+33
| | | | | | | | | | - got everything working. just need to update error strings
| * - got m2m, local_remote_pairs, etc. workingMike Bayer2012-02-091-1/+3
| | | | | | | | | | | | | | | | - using new traversal that returns the product of both sides of a binary, starting to work with (a+b) == (c+d) types of joins. primaryjoins on functions working - annotations working, including reversing local/remote when doing backref
| * initial annotations approach to join conditions. all tests pass, plus ↵Mike Bayer2012-02-061-0/+19
| | | | | | | | | | | | additional tests in #1401 pass. would now like to reorganize RelationshipProperty more around the annotations concept.
* | - reopened #2453, needed to put in the original patch as well to cover the caseMike Bayer2012-04-031-2/+32
| | | | | | | | of column_property() objs building off each other
* | - [bug] Fixed bug in expression annotationMike Bayer2012-03-311-0/+24
| | | | | | | | | | | | | | mechanics which could lead to incorrect rendering of SELECT statements with aliases and joins, particularly when using column_property(). [ticket:2453]
* | - [bug] Fixed bug whereby a primaryjoinMike Bayer2012-03-121-0/+10
|/ | | | | | | | | condition with a "literal" in it would raise an error on compile with certain kinds of deeply nested expressions which also needed to render the same bound parameter name more than once. [ticket:2425]
* - [bug] Added support for using the .keyMike Bayer2012-02-051-0/+23
| | | | | | | | | | | | of a Column as a string identifier in a result set row. The .key is currently listed as an "alternate" name for a column, and is superseded by the name of a column which has that key value as its regular name. For the next major release of SQLAlchemy we may reverse this precedence so that .key takes precedence, but this is not decided on yet. [ticket:2392]