summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/elements.py
Commit message (Collapse)AuthorAgeFilesLines
* - rework ColumnAdapter and ORMAdapter to only provide the featuresticket_3148Mike Bayer2014-09-071-2/+3
| | | | | | | | | | | 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-3/+13
| | | | | | | | | | | | | | | | | | | | | 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/+25
|
* - document all the varities of _label on the base ColumnElementMike Bayer2014-09-061-10/+54
| | | | | - replace out _columns_clause_label with a straight boolean flag to reduce the proliferation of labels
* - add logic to compiler such that if stack is empty, we justMike Bayer2014-09-021-1/+5
| | | | | | | | | | | | | | | | 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-17/+93
| | | | | | | | | | | | | | | | | | | | | 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
* - more updates to text docs, literal_column, column etc. in prepMike Bayer2014-09-011-9/+20
| | | | for ticket 2992.
* - Fixed 0.9.7 regression caused by :ticket:`3067` in conjunction withMike Bayer2014-07-291-0/+3
| | | | | | a mis-named unit test such that so-called "schema" types like :class:`.Boolean` and :class:`.Enum` could no longer be pickled. fixes #3144
* - apply pep8 formatting to sqlalchemy/sql, sqlalchemy/util, sqlalchemy/dialects,Brian Jarrett2014-07-201-263/+279
| | | | sqlalchemy/orm, sqlalchemy/event, sqlalchemy/testing
* - Fixed a SQLite join rewriting issue where a subquery that is embeddedMike Bayer2014-07-151-0/+1
| | | | | | | | 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
* - wrestle with conv() and tests some moreMike Bayer2014-07-141-0/+48
|
* - allow the compilation rule that gets the formatted nameMike Bayer2014-07-141-1/+3
| | | | | 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-0/+16
| | | | | | | | | | | | | 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
* - break up the <authors> copyright comment as part of a passMike Bayer2014-07-091-1/+2
| | | | to get all flake8 passing
* - Fixed bug in SQLite join rewriting where anonymized column namesMike Bayer2014-05-251-0/+3
| | | | | | due to repeats would not correctly be rewritten in subqueries. This would affect SELECT queries with any kind of subquery + join. fixes #3057
* - Fixed bug where the :meth:`.Operators.__and__`,Mike Bayer2014-05-241-7/+21
| | | | | | | :meth:`.Operators.__or__` and :meth:`.Operators.__invert__` operator overload methods could not be overridden within a custom :class:`.TypeEngine.Comparator` implementation. fixes #3012
* - document the compiler_kwargs accessorMike Bayer2014-05-231-0/+20
| | | | - add new FAQ for rendering SQL as a string
* Documentation fix-up: "its" vs. "it's"pr/91Matthias Urlichs2014-05-111-1/+1
| | | | | | | | | Removed ungrammatical apostrophes from documentation, replacing "it's" with "its" where appropriate (but in a few cases with "it is" when that read better). While doing that, I also fixed a couple of minor typos etc. as I noticed them.
* Fix many typos throughout the codebasepr/85Alex Gaynor2014-04-261-5/+5
| | | | Found using: https://github.com/intgr/topy
* - Added new flag :paramref:`.expression.between.symmetric`, when set to TrueMike Bayer2014-03-301-2/+7
| | | | | | | renders "BETWEEN SYMMETRIC". Also added a new negation operator "notbetween_op", which now allows an expression like ``~col.between(x, y)`` to render as "col NOT BETWEEN x AND y", rather than a parentheiszed NOT string. fixes #2990
* - Fixed bug in :func:`.tuple_` construct where the "type" of essentiallyMike Bayer2014-02-271-5/+6
| | | | | | | | | | | the first SQL expression would be applied as the "comparison type" to a compared tuple value; this has the effect in some cases of an inappropriate "type coersion" occurring, such as when a tuple that has a mix of String and Binary values improperly coerces target values to Binary even though that's not what they are on the left side. :func:`.tuple_` now expects heterogeneous types within its list of values. fixes #2977
* - Adjusted the logic which applies names to the .c collection whenMike Bayer2014-02-261-6/+9
| | | | | | | | | a no-name :class:`.BindParameter` is received, e.g. via :func:`.sql.literal` or similar; the "key" of the bind param is used as the key within .c. rather than the rendered name. Since these binds have "anonymous" names in any case, this allows individual bound parameters to have their own name within a selectable if they are otherwise unlabeled. fixes #2974
* - Fixed issue in new :meth:`.TextClause.columns` method where the orderingMike Bayer2014-02-261-7/+7
| | | | | | 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.
* - More issues with [ticket:2932] first resolved in 0.9.2 whereMike Bayer2014-02-051-2/+2
| | | | | | | | | | using a column key of the form ``<tablename>_<columnname>`` matching that of an aliased column in the text would still not match at the ORM level, which is ultimately due to a core column-matching issue. Additional rules have been added so that the column ``_label`` is taken into account when working with a :class:`.TextAsFrom` construct or with literal columns. [ticket:2932]
* - Fixed bug in new :class:`.TextAsFrom` construct where :class:`.Column`-Mike Bayer2014-02-021-2/+5
| | | | | | | | | | oriented row lookups were not matching up to the ad-hoc :class:`.ColumnClause` objects that :class:`.TextAsFrom` generates, thereby making it not usable as a target in :meth:`.Query.from_statement`. Also fixed :meth:`.Query.from_statement` mechanics to not mistake a :class:`.TextAsFrom` for a :class:`.Select` construct. This bug is also an 0.9 regression as the :meth:`.Text.columns` method is called to accommodate the :paramref:`.text.typemap` argument. [ticket:2932]
* - docsMike Bayer2014-01-261-37/+115
|
* updatesMike Bayer2014-01-261-52/+87
|
* tweak textMike Bayer2014-01-251-2/+16
|
* caseMike Bayer2014-01-251-47/+139
|
* - start building out very comprehensive docstrings for core functionsMike Bayer2014-01-251-102/+447
|
* - happy new yearMike Bayer2014-01-051-1/+1
|
* - conjunctions like and_() and or_() can now accept generators as arguments.Mike Bayer2014-01-051-0/+1
|
* - adjust the behavior of cast() to only provide a type for the bindparam()Mike Bayer2013-12-281-9/+1
| | | | | if we are coercing straight from string. [ticket:2899] - rework the tests here to be individual
* - rework the JSON expression system so that "astext" is called *after*Mike Bayer2013-12-271-15/+29
| | | | | | | | | the indexing. this is for more natural operation. - also add cast() to the JSON expression to complement astext. This integrates the CAST call which will be needed frequently. Part of [ticket:2687]. - it's a little unclear how more advanced unicode attribute-access is going to go, some quick attempts at testing yielded strange error messages from psycopg2. - do other cross linking as mentioned in [ticket:2687].
* - The :func:`.cast` function, when given a plain literal value,Mike Bayer2013-12-171-1/+4
| | | | | | | | | | | | will now apply the given type to the given literal value on the bind parameter side according to the type given to the cast. This essentially replaces what would normally be the detected type of the literal value. This only takes effect if the auto-detected type of the literal value is either "nulltype" (e.g. couldn't detect) or a type that is of the same "affinity" as the cast type. The net change here is that the :func:`.cast` function includes more of the functionality already present in the :func:`.type_coerce` function.
* - rework JSON expressions to be based off __getitem__ exclusivelyMike Bayer2013-12-171-0/+4
| | | | | | | | | - add support for "standalone" JSON objects; this involves getting CAST to upgrade the given type of a bound parameter. should add a core-only test for this. - add tests for "standalone" json round trips both with and without unicode - add mechanism by which we remove psycopg2's "json" handler in order to get the effect of using our non-native result handlers
* convert to a list here for py3kMike Bayer2013-11-291-1/+1
|
* more fixMike Bayer2013-11-291-1/+1
|
* - New improvements to the :func:`.text` construct, includingMike Bayer2013-11-291-68/+269
| | | | | | | | 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]
* fix [ticket:2868] some moreMike Bayer2013-11-211-2/+4
|
* - Fixed a regression caused by :ticket:`2812` where the repr() forMike Bayer2013-11-211-1/+1
| | | | | table and column names would fail if the name contained non-ascii characters. [ticket:2868]
* Fix cross referenceVraj Mohan2013-11-141-1/+1
|
* An overhaul of expression handling for special symbols particularlyMike Bayer2013-10-231-66/+230
| | | | | | | | | | 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]
* - Fixed bug where :func:`.type_coerce` would not interpret ORMMike Bayer2013-10-211-2/+2
| | | | | elements with a ``__clause_element__()`` method properly. [ticket:2849]
* - add a type_coerce() step within Enum, Boolean to the CHECK constraint,Mike Bayer2013-10-201-0/+3
| | | | | | | | so that the custom type isn't exposed to an operation that is against the "impl" type's constraint, [ticket:2842] - this change showed up as some recursion overflow in pickling with labels, add a __reduce__() there....pickling of expressions is less and less something that's very viable...
* Fixed bug where using an annotation such as :func:`.remote` orMike Bayer2013-10-081-1/+6
| | | | | | | :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]
* - fix propagation of quote flag within _gen_label() so that if theMike Bayer2013-10-051-1/+8
| | | | | | name is already an instance of _anonymous_label(), we don't downgrade it to a plain quoted_name - fixes regression from [ticket:2812]. [ticket:2834]
* Replace a big loop + dict lookup in Connection.execute() with a simple visitorpr/30Alex Gaynor2013-09-251-0/+3
| | | | pattern
* comment this alternative approach...Mike Bayer2013-08-281-0/+7
|
* - A rework to the way that "quoted" identifiers are handled, in thatMike Bayer2013-08-271-11/+105
| | | | | | | | | | | | | | | | 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]