929 Commits

Author SHA1 Message Date
Mike Bayer a81d3a23c0 - In the SQL Server pyodbc dialect, repaired the implementation
for the ``description_encoding`` dialect parameter, which when
not explicitly set was preventing  cursor.description from
being parsed correctly in the case of result sets that
contained names in alternate encodings.  This parameter
shouldn't be needed going forward.
fixes #3091

Conflicts:
	test/sql/test_unicode.py
2014-07-14 18:57:25 -04:00
Mike Bayer 703cda62d7 - adjust this to work on PG also 2014-07-13 23:59:32 -04:00
Mike Bayer 53b72c35f4 - Fixed bug in :class:.Enum and other :class:.SchemaType
subclasses where direct association of the type with a
:class:`.MetaData` would lead to a hang when events
(like create events) were emitted on the :class:`.MetaData`.
fixes #3124

Conflicts:
	lib/sqlalchemy/sql/sqltypes.py
	test/sql/test_types.py
2014-07-13 19:01:15 -04:00
Mike Bayer a96267639a - Fixed a bug within the custom operator plus :meth:.TypeEngine.with_variant
system, whereby using a :class:`.TypeDecorator` in conjunction with
variant would fail with an MRO error when a comparison operator was used.
fixes #3102

Conflicts:
	lib/sqlalchemy/sql/type_api.py
2014-06-27 16:11:56 -04:00
Mike Bayer 83b2e9e8d2 - Fixed bug in INSERT..FROM SELECT construct where selecting from a
UNION would wrap the union in an anonymous (e.g. unlabled) subquery.
fixes #3044
2014-05-25 14:10:34 -04:00
Mike Bayer 93e11a9d7d - Fixed bug where :meth:.Table.update and :meth:.Table.delete
would produce an empty WHERE clause when an empty :func:`.and_()`
or :func:`.or_()` or other blank expression were applied.  This is
now consistent with that of :func:`.select`.
fixes #3045
2014-05-08 22:45:01 -04:00
Alex Gaynor 43d99ac61b Fix many typos throughout the codebase
cherry pick of those parts of 1caa7fa which went in without issue
Found using: https://github.com/intgr/topy
2014-04-26 16:26:56 -04:00
Mike Bayer df7fe021a9 - reverse order of columns in sample CTEs as this is a UNION and the cols need to line up
- alter this in the unit tests as well as these queries were just copied from the tests
- remove the included_parts.join(parts) from the core CTE doc (also just copied from the
test, where we want to make sure joins don't get screwed up with the CTE) as it doesn't
contribute to the query itself
fixes #3014
2014-04-02 18:13:52 -04:00
Mike Bayer 3ba1385520 - Fixed bug in :func:.tuple_ construct where the "type" of essentially
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

Conflicts:
	lib/sqlalchemy/sql/elements.py
	test/sql/test_operators.py
2014-02-27 19:57:20 -05:00
Mike Bayer 506817a84e - Fixed bug where calling :meth:.Insert.values with an empty list
or tuple would raise an IndexError.   It now produces an empty
insert construct as would be the case with an empty dictionary.

Conflicts:
	lib/sqlalchemy/sql/dml.py
2014-02-19 15:23:04 -05:00
Mike Bayer b87935ed44 - Fixed bug where :meth:.in_() would go into an endless loop if
erroneously passed a column expression whose comparator included
the ``__getitem__()`` method, such as a column that uses the
:class:`.postgresql.ARRAY` type. [ticket:2957]
2014-02-13 15:21:28 -05:00
Mike Bayer 5283b0cb31 - add a test for pullreq github:63 2014-01-31 17:27:35 -05:00
Mike Bayer 66fe0880ba - add a test for [ticket:2927], which is an 0.9 issue but only because 0.8
isn't annotating correctly
2014-01-29 17:09:50 -05:00
Mike Bayer 2866577231 - add tests for [ticket:2918], confirm this is an 0.9 regression 2014-01-23 14:30:34 -05:00
Mike Bayer ae3c57f492 - Fixed issue where a primary key column that has a Sequence on it,
yet the column is not the "auto increment" column, either because
it has a foreign key constraint or ``autoincrement=False`` set,
would attempt to fire the Sequence on INSERT for backends that don't
support sequences, when presented with an INSERT missing the primary
key value.  This would take place on non-sequence backends like
SQLite, MySQL. [ticket:2896]
2013-12-20 10:26:35 -05:00
Mike Bayer 2042493228 - Fixed bug with :meth:.Insert.from_select method where the order
of the given names would not be taken into account when generating
the INSERT statement, thus producing a mismatch versus the column
names in the given SELECT statement.  Also noted that
:meth:`.Insert.from_select` implies that Python-side insert defaults
cannot be used, since the statement has no VALUES clause. [ticket:2895]
2013-12-19 16:05:15 -05:00
Mike Bayer 0fefc6e226 - for [ticket:2651], leaving CheckConstraint alone, preferring to keep
backwards compatibility.  A note about backslashing escapes is added.
Because the Text() construct now supports bind params better, the example
given in the code raises an exception now, so that should cover us.
The exception itself has been enhanced to include the key name of the
bound param.  We're backporting this to 0.8 but 0.8 doesn't have the
text->bind behavior that raises.

Conflicts:
	lib/sqlalchemy/sql/schema.py
2013-12-16 19:34:48 -05:00
Mike Bayer ad85ab12d6 - Fixed bug where SQL statement would be improperly ASCII-encoded
when a pre-DBAPI :class:`.StatementError` were raised within
:meth:`.Connection.execute`, causing encoding errors for
non-ASCII statements.  The stringification now remains within
Python unicode thus avoiding encoding errors. [ticket:2871]

Conflicts:
	test/engine/test_execute.py
2013-11-22 18:37:35 -05:00
Mike Bayer 038f93a49b disable this test for py3k, this is better fixed in 0.9 2013-11-21 17:22:55 -05:00
Mike Bayer 34478fbb0b - add a sanity-check test for repr(), comparing against what we get
in 0.9 for [ticket:2868]
2013-11-21 13:13:40 -05:00
Mike Bayer 622772b469 - Fixed bug where :func:.type_coerce would not interpret ORM
elements with a ``__clause_element__()`` method properly.
[ticket:2849]

Conflicts:
	lib/sqlalchemy/sql/elements.py
2013-10-21 15:08:04 -04:00
Mike Bayer d0c2b9593a fix python 2.5 ism 2013-10-20 20:15:22 -04:00
Mike Bayer 45ad8af3f9 - add a type_coerce() step within Enum, Boolean to the CHECK constraint,
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...

Conflicts:
	lib/sqlalchemy/sql/elements.py
	lib/sqlalchemy/sql/sqltypes.py
2013-10-20 16:31:45 -04:00
Mike Bayer 621c22ca31 The `.unique flag on :class:.Index could be produced as None`
if it was generated from a :class:`.Column` that didn't specify ``unique``
(where it defaults to ``None``).  The flag will now always be ``True`` or
``False``. [ticket:2825]

Conflicts:
	lib/sqlalchemy/sql/schema.py
2013-10-14 14:56:45 -04:00
Mike Bayer d8c17e2a6f - Fixed bug in default compiler plus those of postgresql, mysql, and
mssql to ensure that any literal SQL expression values are
rendered directly as literals, instead of as bound parameters,
within a CREATE INDEX statement. [ticket:2742]
- don't need expression_as_ddl(); literal_binds and include_table
take care of this functionality.

Conflicts:
	lib/sqlalchemy/sql/util.py
2013-10-12 20:13:27 -04:00
Mike Bayer e488bb47e4 A :func:.select that is made to refer to itself in its FROM clause,
typically via in-place mutation, will raise an informative error
message rather than causing a recursion overflow.
[ticket:2815]

Conflicts:
	lib/sqlalchemy/sql/selectable.py
2013-10-08 20:08:35 -04:00
Mike Bayer 79f55eb20b Fixed bug where using an annotation such as :func:.remote or
: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]

Conflicts:
	lib/sqlalchemy/sql/elements.py
2013-10-08 19:49:09 -04:00
Mike Bayer c1a69ab841 Non-working "schema" argument on :class:.ForeignKey is deprecated;
raises a warning.  Removed in 0.9. [ticket:2831]
2013-10-08 19:25:28 -04:00
Mike Bayer cd6cfe36d2 forgot to add system to the copy() method 2013-08-25 12:33:37 -04:00
Mike Bayer f0ac7e20d8 added "system=True" to Column, so that we generally don't have to bother
with CreateColumn rules
2013-08-25 12:31:58 -04:00
Mike Bayer 06fd903af8 apply test skips for pypy issue #1573 in 0.8 [ticket:2805] 2013-08-20 23:32:23 -04:00
Mike Bayer 4f0bda7c45 Fixed regression dating back to 0.7.9 whereby the name of a CTE might
not be properly quoted if it was referred to in multiple FROM clauses.
Also in 0.8.3, 0.7.11. [ticket:2801]

Conflicts:
	doc/build/changelog/changelog_09.rst
2013-08-18 14:46:34 -04:00
Mike Bayer 3302187fea - The :meth:.Operators.notin_ operator added in 0.8 now properly
produces the negation of the expression "IN" returns
when used against an empty collection.  Also in 0.8.3.
2013-08-07 13:29:19 -05:00
Mike Bayer 834d18ca04 - Fixed bug in common table expression system where if the CTE were
used only as an ``alias()`` construct, it would not render using the
WITH keyword.  Also in 0.7.11.
[ticket:2783]
2013-07-31 18:44:12 -04:00
Mike Bayer 436ba1601d Fixed bug in :class:.CheckConstraint DDL where the "quote" flag from a
:class:`.Column` object would not be propagated.  Also in 0.8.3, 0.7.11.
[ticket:2784]
2013-07-17 11:19:50 -04:00
Mike Bayer 574dba8e61 Fixed bug where the expression system relied upon the `str()`
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.
[ticket:2780]
2013-07-12 11:33:24 -04:00
Mike Bayer 8373d7599e - Added new method to the :func:.insert construct
:meth:`.Insert.from_select`.  Given a list of columns and
a selectable, renders ``INSERT INTO (table) (columns) SELECT ..``.
While this feature is highlighted as part of 0.9 it is also
backported to 0.8.3. [ticket:722]
- The :func:`.update`, :func:`.insert`, and :func:`.delete` constructs
will now interpret ORM entities as FROM clauses to be operated upon,
in the same way that select() already does.
2013-07-05 15:52:34 -04:00
Mike Bayer a4e59730d5 genericize tests here 2013-07-02 19:06:30 -04:00
Mike Bayer 9c5a13f049 Fixed bug when using multi-table UPDATE where a supplemental
table is a SELECT with its own bound parameters, where the positioning
of the bound parameters would be reversed versus the statement
itself when using MySQL's special syntax.
[ticket:2768]
2013-07-02 18:25:35 -04:00
Mike Bayer d64c945eae add an ORDER BY here 2013-06-26 15:04:08 -04:00
Mike Bayer b4697e9e18 - rework of correlation, continuing on #2668, #2746
- 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.

Conflicts:
	doc/build/changelog/changelog_08.rst
	doc/build/changelog/changelog_09.rst
	lib/sqlalchemy/sql/compiler.py
2013-06-26 13:32:39 -04:00
Mike Bayer aa5cc5a2cc Provided a new attribute for :class:.TypeDecorator
called :attr:`.TypeDecorator.coerce_to_is_types`,
to make it easier to control how comparisons using
``==`` or ``!=`` to ``None`` and boolean types goes
about producing an ``IS`` expression, or a plain
equality expression with a bound parameter.
[ticket:2744]

Conflicts:
	doc/build/changelog/changelog_09.rst
2013-06-22 12:20:20 -04:00
Mike Bayer 1fc2611e20 Fixed bug whereby joining a select() of a table "A" with multiple
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]

Conflicts:
	doc/build/changelog/changelog_09.rst
2013-06-03 17:04:03 -04:00
Mike Bayer 33d3e11cbf - remove the `__iter__()` with notimplemented since it interferes
with legitimate iterable detection, [ticket:2726]

Conflicts:
	doc/build/changelog/changelog_09.rst
2013-06-03 16:42:46 -04:00
Mike Bayer e2b8c893ca fix this test 2013-05-26 17:18:04 -04:00
Mike Bayer ee9723d7d7 cleanup 2013-05-04 15:08:08 -04:00
Mike Bayer e9ea5acc51 formatting stuff 2013-05-04 14:23:29 -04:00
Mike Bayer 5884c2e7e5 Fully implemented the IS and IS NOT operators with
regards to the True/False constants.  An expression like
``col.is_(True)`` will now render ``col IS true``
on the target platform, rather than converting the True/
False constant to an integer bound parameter.
This allows the ``is_()`` operator to work on MySQL when
given True/False constants.
[ticket:2682]
2013-04-22 19:12:47 -04:00
Mike Bayer 23c744b54e - Improvements to the operation of the pymysql dialect on
Python 3, including some important decode/bytes steps.
Issues remain with BLOB types due to driver issues.
Courtesy Ben Trofatter.
- start using util.py3k, we will eventually remove the
sa2to3 fixer entirely
2013-04-21 17:09:45 -04:00
Mike Bayer d5af821b5d Merged in bentrofatter/sqlalchemy-2663 (pull request #49)
Fixed PyMySQL problems for Python 2.x and mitigated some issues with Python 3.x
2013-04-21 16:58:55 -04:00