Commit Graph

929 Commits

Author SHA1 Message Date
Mike Bayer 236db85f96 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]
2013-08-18 14:46:04 -04:00
Mike Bayer f6198d9abf - A large refactoring of the `sqlalchemy.sql` package has reorganized
the import structure of many core modules.
``sqlalchemy.schema`` and ``sqlalchemy.types``
remain in the top-level package, but are now just lists of names
that pull from within ``sqlalchemy.sql``.  Their implementations
are now broken out among ``sqlalchemy.sql.type_api``, ``sqlalchemy.sql.sqltypes``,
``sqlalchemy.sql.schema`` and ``sqlalchemy.sql.ddl``, the last of which was
moved from ``sqlalchemy.engine``.  ``sqlalchemy.sql.expression`` is also
a namespace now which pulls implementations mostly from ``sqlalchemy.sql.elements``,
``sqlalchemy.sql.selectable``, and ``sqlalchemy.sql.dml``.
Most of the "factory" functions
used to create SQL expression objects have been moved to classmethods
or constructors, which are exposed in ``sqlalchemy.sql.expression``
using a programmatic system.  Care has been taken such that all the
original import namespaces remain intact and there should be no impact
on any existing applications.   The rationale here was to break out these
very large modules into smaller ones, provide more manageable lists
of function names, to greatly reduce "import cycles" and clarify the
up-front importing of names, and to remove the need for redundant
functions and documentation throughout the expression package.
2013-08-12 17:50:37 -04:00
Mike Bayer 34ef21909b - 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:28:45 -05:00
Mike Bayer 8b0f4d2a92 - 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.8.3, 0.7.11.
[ticket:2783]
2013-07-31 18:42:58 -04:00
Mike Bayer d64b09b15c - fix issue in join rewriting whereby we need to ensure the .key and .name
are transferred correctly for when .key is present; tests have been enhanced
to test this condition for render, result map construction, statement
execution.  [ticket:2790]
2013-07-27 17:05:01 -04:00
Mike Bayer 0a54a4a4b0 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:18:59 -04:00
Mike Bayer 0ca7b53b42 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.  Also in 0.8.3.
[ticket:2780]
2013-07-12 11:32:34 -04:00
Mike Bayer cd8a40284d - we dont actually need this unicode cast, on py3k + linux it seems the
has_table issues are OK.  On OSX forget it.
- still some issues with PY3k + pyodbc + decimal values it doesn't expect, not sure
2013-07-09 11:52:31 -04:00
Mike Bayer cec89cae15 - 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.  Also in 0.8.3.
2013-07-05 15:51:24 -04:00
Mike Bayer b1e1bf8e67 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:24:58 -04:00
Mike Bayer 3e52710a79 add an ORDER BY here 2013-06-26 15:03:50 -04:00
Mike Bayer f76cae4bc9 - 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.
2013-06-26 13:19:45 -04:00
Mike Bayer 28a3f15206 tweak this for now, would need a test 2013-06-23 16:08:01 -04:00
Mike Bayer e288aff8ea The resolution of :class:.ForeignKey objects to their
target :class:`.Column` has been reworked to be as
immediate as possible, based on the moment that the
target :class:`.Column` is associated with the same
:class:`.MetaData` as this :class:`.ForeignKey`, rather
than waiting for the first time a join is constructed,
or similar. This along with other improvements allows
earlier detection of some foreign key configuration
issues.  Also included here is a rework of the
type-propagation system, so that
it should be reliable now to set the type as ``None``
on any :class:`.Column` that refers to another via
:class:`.ForeignKey` - the type will be copied from the
target column as soon as that other column is associated,
and now works for composite foreign keys as well.
[ticket:1765]
2013-06-23 15:58:07 -04:00
Mike Bayer eba9d1b58f 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]
2013-06-22 12:19:41 -04:00
Mike Bayer 31063d16f2 - tests for the alias() API
- docs docs docs
2013-06-08 18:41:59 -04:00
Mike Bayer 1188edccf6 fix test 2013-06-06 18:53:44 -04:00
Mike Bayer 9a736a4c6e genericize tests here 2013-06-04 23:20:02 -04:00
Mike Bayer 26ec0507be Merge branch 'ticket_2587'
Conflicts:
	test/profiles.txt
	test/sql/test_selectable.py
2013-06-04 21:38:56 -04:00
Mike Bayer 69e9574fef - add coverage for result map rewriting
- fix the result map rewriter for col mismatches, since the rewritten
select at the moment typically has more columns than the original
2013-06-04 21:36:34 -04:00
Mike Bayer 92e599f42f - if the select() does not have use_labels on, then we just render
the joins as is, regardless of the dialect not supporting it.  use_labels=True
indicates a higher level of automation and also can maintain the labels
between rewritten and not.  use_labels=False indicates a manual use case.
2013-06-04 19:52:53 -04:00
Mike Bayer d8a3883948 - support for a__b_dc, i.e. two levels of nesting 2013-06-04 19:44:57 -04:00
Mike Bayer 66b8ed40c3 repair these tests now that we allow join from selectable to fromgrouping 2013-06-04 18:58:24 -04:00
Mike Bayer c7b52003fb - add a flag to DefaultDialect for this so that people will have some
workaround
2013-06-04 18:43:59 -04:00
Mike Bayer 9998e9e013 rewriting scheme now works. 2013-06-04 14:30:29 -04:00
Mike Bayer 822786dfae capture the really hard one in a test (hooray) 2013-06-04 13:11:03 -04:00
Mike Bayer 8a865a4d1f 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]
2013-06-03 17:03:15 -04:00
Mike Bayer d993bdeac8 - remove the `__iter__()` with notimplemented since it interferes
with legitimate iterable detection, [ticket:2726]
2013-06-03 16:32:12 -04:00
Mike Bayer f2328d6df4 test tweak 2013-06-03 13:45:28 -04:00
Mike Bayer 74c98bf182 Merge branch 'master' into ticket_1068 2013-06-03 13:13:16 -04:00
Mike Bayer c2a158c137 - some tweaks to try to help out mssql+pyodbc support a bit, py3k is really
not happening too well (I need to stick with linux + freetds 0.91, I know)
2013-06-03 12:54:56 -04:00
Mike Bayer ff399ac750 magic accessors to the rescue 2013-05-27 21:43:29 -04:00
Mike Bayer 0adcfea0d3 still not locating more nested expressions, may need to match on name 2013-05-27 21:05:16 -04:00
Mike Bayer a9ed16f80d attempt number one, doesn't detect though if the label in the order by is not directly present there. 2013-05-27 19:22:59 -04:00
Mike Bayer 2ddcd20267 Merge branch 'master' into rel_0_9 2013-05-26 17:18:27 -04:00
Mike Bayer e2b8c893ca fix this test 2013-05-26 17:18:04 -04:00
Mike Bayer cca97433c1 merge default 2013-05-05 01:42:26 -04:00
Mike Bayer c7ce62cf65 - OK we have -w sql passing for: sqlite, postgresql, oursql 2.7 + 3.3, mysqldb 2.7 2013-05-04 15:26:28 -04:00
Mike Bayer afcbd7419c and int types here... 2013-05-04 15:10:41 -04:00
Mike Bayer 2a8fcfaa42 update test 2013-05-04 15:09:04 -04:00
Mike Bayer ee9723d7d7 cleanup 2013-05-04 15:08:08 -04:00
Mike Bayer 9db36c36aa cleanup and formatting 2013-05-04 15:06:47 -04:00
Mike Bayer 2a99b770dd - unicode literals need to just be handled differently if they have utf-8
encoded in them vs. unicode escaping.  not worth figuring out how to combine
these right now
2013-05-04 14:59:26 -04:00
Mike Bayer e9ea5acc51 formatting stuff 2013-05-04 14:23:29 -04:00
Mike Bayer 8f9b7ad31f formatting stuff 2013-05-04 14:23:29 -04:00
Mike Bayer fc624dcfa4 - test_types, test_compiler, with sqlite at least 2013-04-28 14:44:21 -04:00
Mike Bayer 4b614b9b35 - the raw 2to3 run
- went through examples/ and cleaned out excess list() calls
2013-04-27 19:53:57 -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