Commit Graph

1101 Commits

Author SHA1 Message Date
Mike Bayer 212d93366d - The behavioral contract of the :attr:.ForeignKeyConstraint.columns
collection has been made consistent; this attribute is now a
:class:`.ColumnCollection` like that of all other constraints and
is initialized at the point when the constraint is associated with
a :class:`.Table`.
fixes #3243
2014-11-25 18:01:31 -05:00
Mike Bayer b013fb82f5 - Fixed issue where the columns from a SELECT embedded in an
INSERT, either through the values clause or as a "from select",
would pollute the column types used in the result set produced by
the RETURNING clause when columns from both statements shared the
same name, leading to potential errors or mis-adaptation when
retrieving the returning rows.
fixes #3248
2014-11-11 12:34:00 -05:00
Mike Bayer a19b2f419c - The :attr:.Column.key attribute is now used as the source of
anonymous bound parameter names within expressions, to match the
existing use of this value as the key when rendered in an INSERT
or UPDATE statement.   This allows :attr:`.Column.key` to be used
as a "substitute" string to work around a difficult column name
that doesn't translate well into a bound parameter name.   Note that
the paramstyle is configurable on :func:`.create_engine` in any case,
and most DBAPIs today support a named and positional style.
fixes #3245
2014-11-10 17:37:26 -05:00
Mike Bayer edec583b45 - Fixed bug regarding expression mutations which could express
itself as a "Could not locate column" error when using
:class:`.Query` to  select from multiple, anonymous column
entities when querying against SQLite, as a side effect of the
"join rewriting" feature used by the SQLite dialect.
fixes #3241
2014-11-05 04:22:30 -05:00
Mike Bayer 7bf5ac9c1e - ensure kwargs are passed for limit clause on a compound select as well,
further fixes for #3034
2014-10-31 20:00:42 -04:00
Mike Bayer 56d5732fbd - changelog for pullreq github:139
- add support for self-referential foreign keys to move over as well when
the table name is changed.
2014-10-21 17:58:51 -04:00
Mike Bayer 0ae140aa98 Merge remote-tracking branch 'origin/pr/139' into pr139 2014-10-21 17:29:40 -04:00
Mike Bayer ade27f35cb - Reversing a change that was made in 0.9, the "singleton" nature
of the "constants" :func:`.null`, :func:`.true`, and :func:`.false`
has been reverted.   These functions returning a "singleton" object
had the effect that different instances would be treated as the
same regardless of lexical use, which in particular would impact
the rendering of the columns clause of a SELECT statement.
fixes #3170
2014-10-19 18:26:14 -04:00
Mike Bayer 6f40eb37cb - Exception messages have been spiffed up a bit. The SQL statement
and parameters are not displayed if None, reducing confusion for
error messages that weren't related to a statement.  The full
module and classname for the DBAPI-level exception is displayed,
making it clear that this is a wrapped DBAPI exception.  The
statement and parameters themselves are bounded within a bracketed
sections to better isolate them from the error message and from
each other.
fixes #3172
2014-10-17 19:37:45 -04:00
Mike Bayer 198917237e - additional issues fixed in mysqlconnector 2.0.1 2014-10-13 12:37:42 -04:00
Mike Bayer 50d2432a9e - Mysqlconnector as of version 2.0, probably as a side effect of
the  python 3 merge, now does not expect percent signs (e.g.
as used as the modulus operator and others) to be doubled,
even when using the "pyformat" bound parameter format (this
change is not documented by Mysqlconnector).  The dialect now
checks for py2k and for mysqlconnector less than version 2.0
when detecting if the modulus operator should be rendered as
``%%`` or ``%``.
- Unicode SQL is now passed for MySQLconnector version 2.0 and above;
for Py2k and MySQL < 2.0, strings are encoded.  Note that mysqlconnector
as of 2.0.1 appears to have a bug with unicode DDL on py2k, so the tests here
are skipping until we observe it's fixed.
- take out profiling on mysqlconnector, callcounts vary too much with
its current development speed
2014-10-12 20:14:32 -04:00
Mike Bayer 95be42c06f - :meth:.Insert.from_select now includes Python and SQL-expression
defaults if otherwise unspecified; the limitation where non-
server column defaults aren't included in an INSERT FROM
SELECT is now lifted and these expressions are rendered as
constants into the SELECT statement.
2014-10-10 17:15:19 -04:00
Mike Bayer 81d1e0455a - Fixed bug where a fair number of SQL elements within
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
2014-10-09 17:20:30 -04:00
Mike Bayer 49e750a1d7 - changelog, migration for pr github:134 2014-10-04 12:18:20 -04:00
Mike Bayer be2541736d Merge remote-tracking branch 'origin/pr/134' into pr134 2014-10-04 11:51:52 -04:00
ndparker 7e0835409c add simple tests for new name argument for Table.tometadata() 2014-10-04 00:51:01 +02:00
Mike Bayer 19ec6c3368 - "column already assigned" message has been updated in 7f82c55f 2014-09-25 21:16:13 -04:00
Mike Bayer f82f6d55dc - Added new method :meth:.Select.with_statement_hint and ORM
method :meth:`.Query.with_statement_hint` to support statement-level
hints that are not specific to a table.
fixes #3206
2014-09-18 11:44:48 -04:00
Mike Bayer 2c46128a2f - use compat.u for python3.2, fixes #3198 2014-09-15 14:57:41 -04:00
Ilja Everilä 52a095ba66 allow windowing filtered functions 2014-09-11 15:39:56 +03:00
Ilja Everilä ab1c25266d renamed aggregatefilter to funcfilter, since it is that 2014-09-11 15:29:33 +03:00
Ilja Everilä a3cd517c95 add ClauseTest for aggregatefilter 2014-09-10 12:07:38 +03:00
Ilja Everilä a23264e1dc tests for <aggregate_fun> FILTER (WHERE ...) 2014-09-10 11:33:49 +03:00
Mike Bayer 7904ebc62e - rework the previous "order by" system in terms of the new one,
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
2014-09-08 16:31:11 -04:00
Mike Bayer c52580dede - rework ColumnAdapter and ORMAdapter to only provide the features
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
2014-09-07 14:55:44 -04: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 356d6659b1 - tiny refactors #1-#5 2014-09-05 16:28:20 -04:00
Mike Bayer 2b10aa45a1 - ensure literal_binds works with LIMIT clause, FOR UPDATE 2014-09-03 19:42:38 -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 d7131ffad3 - optional 'b' here for py3k 2014-08-31 18:02:24 -04:00
Mike Bayer 3c60d3b1ca - A new style of warning can be emitted which will "filter" up to
N occurrences of a parameterized string.   This allows parameterized
warnings that can refer to their arguments to be delivered a fixed
number of times until allowing Python warning filters to squelch them,
and prevents memory from growing unbounded within Python's
warning registries.
fixes #3178
2014-08-31 15:22:00 -04:00
Mike Bayer 71ca494f51 - The INSERT...FROM SELECT construct now implies `inline=True`
on :class:`.Insert`.  This helps to fix a bug where an
INSERT...FROM SELECT construct would inadvertently be compiled
as "implicit returning" on supporting backends, which would
cause breakage in the case of an INSERT that inserts zero rows
(as implicit returning expects a row), as well as arbitrary
return data in the case of an INSERT that inserts multiple
rows (e.g. only the first row of many).
A similar change is also applied to an INSERT..VALUES
with multiple parameter sets; implicit RETURNING will no longer emit
for this statement either.  As both of these constructs deal
with varible numbers of rows, the
:attr:`.ResultProxy.inserted_primary_key` accessor does not
apply.   Previously, there was a documentation note that one
may prefer ``inline=True`` with INSERT..FROM SELECT as some databases
don't support returning and therefore can't do "implicit" returning,
but there's no reason an INSERT...FROM SELECT needs implicit returning
in any case.   Regular explicit :meth:`.Insert.returning` should
be used to return variable numbers of result rows if inserted
data is needed.
fixes #3169
2014-08-20 20:14:20 -04:00
Mike Bayer 89ff6df7dc - pep8 2014-08-20 19:12:32 -04:00
Mike Bayer d768ec2c26 - don't add the parent attach event within _on_table_attach
if we already have a table; this prevents reentrant calls and
we aren't supporting columns/etc being moved around between different parents
2014-08-15 14:27:12 -04:00
Mike Bayer 7fc08fe89a - The `info` parameter has been added to the constructor for
:class:`.SynonymProperty` and :class:`.ComparableProperty`.
- The ``info`` parameter has been added as a constructor argument
to all schema constructs including :class:`.MetaData`,
:class:`.Index`, :class:`.ForeignKey`, :class:`.ForeignKeyConstraint`,
:class:`.UniqueConstraint`, :class:`.PrimaryKeyConstraint`,
:class:`.CheckConstraint`.

fixes #2963
2014-08-13 19:45:34 -04:00
Mike Bayer 7c80e521f0 - Fixed bug in CTE where `literal_binds` compiler argument would not
be always be correctly propagated when one CTE referred to another
aliased CTE in a statement.
Fixes #3154
2014-08-02 14:42:57 -04:00
Mike Bayer 0bf33068f4 - ensure all tests are named test_* 2014-07-30 12:18:33 -04:00
Mike Bayer 405c223ae5 - Fixed 0.9.7 regression caused by 🎫3067 in conjunction with
a mis-named unit test such that so-called "schema" types like
:class:`.Boolean` and :class:`.Enum` could no longer be pickled.
fixes #3144
2014-07-29 13:32:05 -04:00
Mike Bayer 8574d5051a - find the remaining not cleaning up correctly test 2014-07-28 13:11:04 -04:00
Mike Bayer 54592942c4 - add support for tags, including include/exclude support.
simplify tox again now that we can exclude tests more easily
2014-07-27 18:46:20 -04:00
Mike Bayer d2358629c9 - scale up for mysql, sqlite 2014-07-26 20:50:57 -04:00
Mike Bayer 0df977ccad - Added a supported :meth:.FunctionElement.alias method to functions,
e.g. the ``func`` construct.  Previously, behavior for this method
was undefined.  The current behavior mimics that of pre-0.9.4,
which is that the function is turned into a single-column FROM
clause with the given alias name, where the column itself is
anonymously named.
fixes #3137
2014-07-24 14:33:50 -04:00
Mike Bayer 63c6aa0104 - update some SQL server tests, support
- add support for IDENTITY INSERT setting for INSERT with inline VALUES
2014-07-22 13:42:38 -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
Mike Bayer 3d7b188638 - Fixed a SQLite join rewriting issue where a subquery that is embedded
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
2014-07-15 12:25:38 -04:00
Mike Bayer f4653729a6 - wrestle with conv() and tests some more 2014-07-14 22:44:33 -04:00
Mike Bayer dbc8bbfba3 - allow the compilation rule that gets the formatted name
to again have the chance to veto rendering, as the naming convention
can make the decision that the name is "none" or not now.
2014-07-14 21:11:51 -04:00
Mike Bayer d2193f53c1 - Fix bug in naming convention feature where using a check
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
2014-07-14 20:26:38 -04:00