Commit Graph

1111 Commits

Author SHA1 Message Date
Mike Bayer c24423bc2e - enhance only_on() to work with compound specs
- fix "temporary_tables" requirement
2014-12-06 13:33:57 -05:00
Mike Bayer 6017414641 - the refactor of the visit_alias() method in Oracle revealed
that quoting should be applied in %(name)s under with_hint.
2014-12-04 19:45:14 -05:00
Mike Bayer e46c71b419 - Added support for CTEs under Oracle. This includes some tweaks
to the aliasing syntax, as well as a new CTE feature
:meth:`.CTE.suffix_with`, which is useful for adding in special
Oracle-specific directives to the CTE.
fixes #3220
2014-12-04 19:35:00 -05:00
Mike Bayer f5ff86983f - The :meth:.Operators.match operator is now handled such that the
return type is not strictly assumed to be boolean; it now
returns a :class:`.Boolean` subclass called :class:`.MatchType`.
The type will still produce boolean behavior when used in Python
expressions, however the dialect can override its behavior at
result time.  In the case of MySQL, while the MATCH operator
is typically used in a boolean context within an expression,
if one actually queries for the value of a match expression, a
floating point value is returned; this value is not compatible
with SQLAlchemy's C-based boolean processor, so MySQL's result-set
behavior now follows that of the :class:`.Float` type.
A new operator object ``notmatch_op`` is also added to better allow
dialects to define the negation of a match operation.
fixes #3263
2014-12-04 18:29:56 -05:00
Mike Bayer 156f473de0 Merge remote-tracking branch 'origin/pr/151' into pr151 2014-12-01 13:31:48 -05:00
Mike Bayer 98c2a67970 - Fixed bug in :meth:.Table.tometadata method where the
:class:`.CheckConstraint` associated with a :class:`.Boolean`
or :class:`.Enum` type object would be doubled in the target table.
The copy process now tracks the production of this constraint object
as local to a type object.
fixes #3260
2014-11-29 14:46:34 -05:00
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
Scott Dugas b31ab00689 Merge branch 'master' into fdbsql-tests
Conflicts:
	lib/sqlalchemy/testing/exclusions.py
2014-11-03 14:54:51 -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
Scott Dugas 5b3fc87435 Added requirement for temporary tables 2014-10-30 11:06:45 -04:00
Scott Dugas e01dab9b1f Set the length for MyType implementation
Mysql drops the type in these tests, when it does visit_typeclause,
 since it's an unkown type it just says none,
and doesn't do a cast.
Firebird also doesn't support varchar with length, it throws an
error on these types.
2014-10-29 17:42:52 -04:00
Scott Dugas fdbea87958 require check constraints for tests 2014-10-23 17:59:27 -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