Commit Graph

21 Commits

Author SHA1 Message Date
Mike Bayer 2392ae1900 Apply percent sign escaping to literal binds, comments
Fixed bug in new percent-sign support (e.g. 🎫`3740`) where a bound
parameter rendered with literal_binds would fail to escape percent-signs
for relevant dialects.  In addition, ensured new table / column comment
support feature also fully makes use of literal-rendered parameters so that
this percent sign support takes place with table / column comment DDL as
well, allowing percent sign support for the mysql / psycopg2 backends that
require escaping of percent signs.

Change-Id: Ia4136a300933e9bc6a01a7b9afd5c7b9a3fee4e3
Fixes: #4054
Fixes: #4052
2017-08-25 16:53:49 -04:00
Mike Bayer 86ef507cc7 Double percent signs based on paramstyle, not dialect
This patch moves the "doubling" of percent signs into
the base compiler and makes it completely a product
of whether or not the paramstyle is format/pyformat or
not.   Without this paramstyle, percent signs
are not doubled across text(), literal_column(), and
column().

Change-Id: Ie2f278ab1dbb94b5078f85c0096d74dbfa049197
Fixes: #3740
2017-04-05 12:18:36 -04:00
Mike Bayer fa6dd376bb Support python3.6
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
2017-01-13 10:57:41 -05:00
Mike Bayer 29dcaa2b0a - Fixed bug in :func:.expression.text construct where a double-colon
expression would not escape properly, e.g. ``some\:\:expr``, as is most
commonly required when rendering Postgresql-style CAST expressions.
fixes #3644
2016-02-09 18:05:40 -05:00
Mike Bayer 623e5b2149 Merge remote-tracking branch 'origin/pr/163' into pr163 2015-04-12 14:56:15 -04:00
Mike Bayer 04545727d4 - Fixed bug in new "label resolution" feature of 🎫2992 where
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
2015-03-23 12:33:48 -04:00
Mike Bayer c09c21c9f3 - Fixed bug in new "label resolution" feature of 🎫2992 where
the string label placed in the order_by() or group_by() of a statement
would place higher priority on the name as found
inside the FROM clause instead of a more locally available name
inside the columns clause.
fixes #3335
2015-03-21 13:12:15 -04:00
Eric Streeper e467db9edb PEP8 cleanup in /test/sql 2015-03-18 21:38:57 -07:00
Mike Bayer 9854114f57 foo 2015-03-08 11:34:14 -04:00
Mike Bayer 140e8254a2 - expect_warnings was not expecting and neither was assert_warnings
asserting.
2015-02-19 12:01:48 -05:00
Mike Bayer 7950270cf2 - enhance ClauseAdapter / ColumnAdapter to have new behaviors with labels.
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)
2014-09-07 00:01:34 -04:00
Mike Bayer e80c7cc5c1 wip for #3148 2014-09-06 17:56:53 -04:00
Mike Bayer c0af2ee6c9 - add logic to compiler such that if stack is empty, we just
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.
2014-09-02 10:49:46 -04:00
Mike Bayer 7c6a45c480 - The :func:~.expression.column and :func:~.expression.table
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
2014-09-01 20:19:54 -04:00
Mike Bayer bb5f4392a4 - update the flake8 rules again
- apply autopep8 + manual fixes to most of test/sql/
2014-07-18 17:40:58 -04:00
Alex Gaynor 1caa7fafbd Fix many typos throughout the codebase
Found using: https://github.com/intgr/topy
2014-04-26 13:13:13 -07:00
Mike Bayer bf67069d26 - Fixed issue in new :meth:.TextClause.columns method where the ordering
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.
2014-02-26 13:28:14 -05:00
Mike Bayer bf934018a5 - for TextAsFrom, put the "inner" columns in the result map directly.
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].
2014-02-10 19:17:00 -05:00
Mike Bayer d5384d6011 - implement "literal binds" for the text() clause, [ticket:2882] 2013-12-11 20:00:39 -05:00
Mike Bayer 207fafe7e3 - add support for bindparam() called from AsFromText
- get PG dialect to work around "no nonexistent binds" rule for now,
though we might want to reconsider this behavior
2013-11-29 19:06:33 -05:00
Mike Bayer 6c83ef761b - New improvements to the :func:.text construct, including
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]
2013-11-29 15:05:19 -05:00