Commit Graph

4477 Commits

Author SHA1 Message Date
Mike Bayer 2a25e42c08 - Fixed bug where :meth:.Query.get would fail to consistently
raise the :class:`.InvalidRequestError` that invokes when called
on a query with existing criterion, when the given identity is
already present in the identity map. [ticket:2951]
2014-02-10 16:33:48 -05:00
Mike Bayer ab738c21aa - Fixed an 0.9 regression where ORM instance or mapper events applied
to a base class such as a declarative base with the propagate=True
flag would fail to apply to existing mapped classes which also
used inheritance due to an assertion.  Addtionally, repaired an
attribute error which could occur during removal of such an event,
depending on how it was first assigned. [ticket:2949]
2014-02-09 16:47:20 -05:00
Mike Bayer ee88e648f7 - Fixed bug where the :class:.AutomapBase class of the
new automap extension would fail if classes
were pre-arranged in single or potentially joined inheritance patterns.
The repaired joined inheritance issue could also potentially apply when
using :class:`.DeferredReflection` as well.
2014-02-08 21:24:13 -05:00
Mike Bayer 5c188f6c1c - More issues with [ticket:2932] first resolved in 0.9.2 where
using a column key of the form ``<tablename>_<columnname>``
matching that of an aliased column in the text would still not
match at the ORM level, which is ultimately due to a core
column-matching issue.  Additional rules have been added so that the
column ``_label`` is taken into account when working with a
:class:`.TextAsFrom` construct or with literal columns.
[ticket:2932]
2014-02-05 19:25:13 -05:00
Mike Bayer c5dccd82da - Fixed regression in new "naming convention" feature where conventions
would fail if the referred table in a foreign key contained a schema
name.  Pull request courtesy Thomas Farvour. pullreq github:67
2014-02-05 16:54:31 -05:00
Mike Bayer 16cd07c4f8 - Fixed bug where so-called "literal render" of :func:.bindparam
constructs would fail if the bind were constructed with a callable,
rather than a direct value.  This prevented ORM expressions
from being rendered with the "literal_binds" compiler flag.
2014-02-05 12:03:46 -05:00
Mike Bayer b069127b2d - Improved the initialization logic of composite attributes such that
calling ``MyClass.attribute`` will not require that the configure
mappers step has occurred, e.g. it will just work without throwing
any error. [ticket:2935]
2014-02-03 19:13:16 -05:00
Mike Bayer 0326f3cf01 - Added :paramref:.MetaData.reflect.**dialect_kwargs
to support dialect-level reflection options for all :class:`.Table`
objects reflected.

- Added a new dialect-level argument ``postgresql_ignore_search_path``;
this argument is accepted by both the :class:`.Table` constructor
as well as by the :meth:`.MetaData.reflect` method.  When in use
against Postgresql, a foreign-key referenced table which specifies
a remote schema name will retain that schema name even if the name
is present in the ``search_path``; the default behavior since 0.7.3
has been that schemas present in ``search_path`` would not be copied
to reflected :class:`.ForeignKey` objects.  The documentation has been
updated to describe in detail the behavior of the ``pg_get_constraintdef()``
function and how the ``postgresql_ignore_search_path`` feature essentially
determines if we will honor the schema qualification reported by
this function or not. [ticket:2922]
2014-02-02 16:33:54 -05:00
Mike Bayer 4ed4266803 - use from_statement() for the ORM column test
- with select_from(), add external order by so that Oracle orders correctly
2014-02-02 14:40:23 -05:00
Mike Bayer 2d4b457924 - The behavior of :meth:.Table.tometadata has been adjusted such that
the schema target of a :class:`.ForeignKey` will not be changed unless
that schema matches that of the parent table.  That is, if
a table "schema_a.user" has a foreign key to "schema_b.order.id",
the "schema_b" target will be maintained whether or not the
"schema" argument is passed to :meth:`.Table.tometadata`.  However
if a table "schema_a.user" refers to "schema_a.order.id", the presence
of "schema_a" will be updated on both the parent and referred tables.
This is a behavioral change hence isn't likely to be backported to
0.8; it is assumed that the previous behavior is pretty buggy
however and that it's unlikely anyone was relying upon it.

Additionally, a new parameter has been added
:paramref:`.Table.tometadata.referred_schema_fn`.  This refers to a
callable function which will be used to determine the new referred
schema for any :class:`.ForeignKeyConstraint` encountered in the
tometadata operation.  This callable can be used to revert to the
previous behavior or to customize how referred schemas are treated
on a per-constraint basis.  [ticket:2913]

- rework the tests in test.sql.test_metadata, all the "tometadata" tests
now under new class ToMetaDataTest
2014-02-02 14:37:43 -05:00
Mike Bayer 29de1077b3 - Fixed bug in new :class:.TextAsFrom construct where :class:.Column-
oriented row lookups were not matching up to the ad-hoc :class:`.ColumnClause`
objects that :class:`.TextAsFrom` generates, thereby making it not
usable as a target in :meth:`.Query.from_statement`.  Also fixed
:meth:`.Query.from_statement` mechanics to not mistake a :class:`.TextAsFrom`
for a :class:`.Select` construct.  This bug is also an 0.9 regression
as the :meth:`.Text.columns` method is called to accommodate the
:paramref:`.text.typemap` argument. [ticket:2932]
2014-02-02 11:06:08 -05:00
Mike Bayer 5b0919f3f5 - Added a new feature which allows automated naming conventions to be
applied to :class:`.Constraint` and :class:`.Index` objects.  Based
on a recipe in the wiki, the new feature uses schema-events to set up
names as various schema objects are associated with each other.  The
events then expose a configuration system through a new argument
:paramref:`.MetaData.naming_convention`.  This system allows production
of both simple and custom naming schemes for constraints and indexes
on a per-:class:`.MetaData` basis.  [ticket:2923]

commit 7e65e52c086652de3dd3303c723f98f09af54db8
Author: Mike Bayer <mike_mp@zzzcomputing.com>
Date:   Sat Feb 1 15:09:04 2014 -0500

    - first pass at new naming approach
2014-02-01 18:21:04 -05:00
Mike Bayer 32a1db3685 add a skip for oracle on this 2014-02-01 13:22:43 -05:00
Mike Bayer 33c7cfff6e - Added a new directive used within the scope of an attribute "set" operation
to disable autoflush, in the case that the attribute needs to lazy-load
the "old" value, as in when replacing one-to-one values or some
kinds of many-to-one.  A flush at this point otherwise occurs
at the point that the attribute is None and can cause NULL violations.
[ticket:2921]
2014-01-31 19:57:38 -05:00
Mike Bayer 6b3ecd14ea - Added a new parameter :paramref:.Operators.op.is_comparison. This
flag allows a custom op from :meth:`.Operators.op` to be considered
as a "comparison" operator, thus usable for custom
:paramref:`.relationship.primaryjoin` conditions.
2014-01-31 19:14:08 -05:00
Mike Bayer b360dbf7eb - Fixed bug whereby SQLite compiler failed to propagate compiler arguments
such as "literal binds" into a CAST expression.
- Fixed bug whereby binary type would fail in some cases
if used with a "test" dialect, such as a DefaultDialect or other
dialect with no DBAPI.
- Fixed bug where "literal binds" wouldn't work with a bound parameter
that's a binary type.  A similar, but different, issue is fixed
in 0.8.
2014-01-31 17:57:17 -05:00
Mike Bayer 8afb69ced8 - Fixed regression whereby the "annotation" system used by the ORM was leaking
into the names used by standard functions in :mod:`sqlalchemy.sql.functions`,
such as ``func.coalesce()`` and ``func.max()``.  Using these functions
in ORM attributes and thus producing annotated versions of them could
corrupt the actual function name rendered in the SQL. [ticket:2927]
2014-01-29 17:33:28 -05:00
Mike Bayer 00e78f5f76 - better way to do it 2014-01-29 14:57:18 -05:00
Mike Bayer 7d56e4f135 - add TypeError handling to the tests here, ensure TypeError
for the control is a TypeError for the row, as is raised on py3k when
less/greater operators are used on incompatible types
2014-01-29 14:55:58 -05:00
Mike Bayer d4c908ded1 - Fixed 0.9 regression where the new sortable support for :class:.RowProxy
would lead to ``TypeError`` when compared to non-tuple types as it attempted
to apply tuple() to the "other" object unconditionally.  The
full range of Python comparison operators have now been implemented on
:class:`.RowProxy`, using an approach that guarantees a comparison
system that is equivalent to that of a tuple, and the "other" object
is only coerced if it's an instance of RowProxy. [ticket:2924]
2014-01-28 23:43:14 -05:00
Mike Bayer d8d03011b8 - repair the fixture/test here to make sure state isn't left over causing other tests to fail 2014-01-27 13:34:33 -05:00
Mike Bayer 15b23c7f71 - Fixed an 0.9 regression where the automatic aliasing applied by
:class:`.Query` and in other situations where selects or joins
were aliased (such as joined table inheritance) could fail if a
user-defined :class:`.Column` subclass were used in the expression.
In this case, the subclass would fail to propagate ORM-specific
"annotations" along needed by the adaptation.  The "expression
annotations" system has been corrected to account for this case.
[ticket:2918]
2014-01-23 14:49:04 -05:00
Mike Bayer 743ceb045e - Support is improved for supplying a :func:.join construct as the
target of :paramref:`.relationship.secondary` for the purposes
of creating very complex :func:`.relationship` join conditions.
The change includes adjustments to query joining, joined eager loading
to not render a SELECT subquery, changes to lazy loading such that
the "secondary" target is properly included in the SELECT, and
changes to declarative to better support specification of a
join() object with classes as targets.
2014-01-22 20:16:47 -05:00
Mike Bayer 1732414076 - Added new test coverage for so-called "down adaptions" of SQL types,
where a more specific type is adapted to a more generic one - this
use case is needed by some third party tools such as ``sqlacodegen``.
The specific cases that needed repair within this test suite were that
of :class:`.mysql.ENUM` being downcast into a :class:`.types.Enum`,
and that of SQLite date types being cast into generic date types.
The ``adapt()`` method needed to become more specific here to counteract
the removal of a "catch all" ``**kwargs`` collection on the base
:class:`.TypeEngine` class that was removed in 0.9. [ticket:2917]
2014-01-22 15:38:00 -05:00
Mike Bayer b9318c9863 - Fixed the multiple-table "UPDATE..FROM" construct, only usable on
MySQL, to correctly render the SET clause among multiple columns
with the same name across tables.  This also changes the name used for
the bound parameter in the SET clause to "<tablename>_<colname>" for
the non-primary table only; as this parameter is typically specified
using the :class:`.Column` object directly this should not have an
impact on applications.   The fix takes effect for both
:meth:`.Table.update` as well as :meth:`.Query.update` in the ORM.
[ticket:2912]
2014-01-20 21:17:42 -05:00
Mike Bayer 49f1807f8f - simplify the mechanics of PrimaryKeyConstraint with regards to reflection;
reflection now updates the PKC in place.
- support the use case of the empty PrimaryKeyConstraint in order to specify
constraint options; the columns marked as primary_key=True will now be gathered
into the columns collection, rather than being ignored. [ticket:2910]
- add validation such that column specification should only take place
in the PrimaryKeyConstraint directly, or by using primary_key=True flags;
if both are present, they have to match exactly, otherwise the condition is
assumed to be ambiguous, and a warning is emitted; the old behavior of
using the PKC columns only is maintained.
2014-01-20 18:06:18 -05:00
Mike Bayer 84b03137eb - ensure ordering is fully maintained, [ticket:2914] 2014-01-20 15:36:45 -05:00
Mike Bayer 3dc9f9b3db - alter behavior such that dialect_kwargs is still immutable, but
now represents exactly the kwargs that were passed, and not the defaults.
the defaults are still in dialect_options.  This allows repr() schemes such as that
of alembic to not need to look through and compare for defaults.
2014-01-19 16:32:36 -05:00
Mike Bayer 8e1a4fdced - some test fixes
- clean up some shenanigans in reflection
2014-01-19 00:34:37 -05:00
Mike Bayer 1af8e2491d - implement kwarg validation and type system for dialect-specific
arguments; [ticket:2866]
- add dialect specific kwarg functionality to ForeignKeyConstraint, ForeignKey
2014-01-18 19:26:56 -05:00
Mike Bayer 6e4fd0aea8 Merge branch 'patch-msql-pkc-clustered' of bitbucket.org:dharland/sqlalchemy into m 2014-01-18 15:06:08 -05:00
Mike Bayer 931655f417 cx_oracle is now "conditional" on py2k 2014-01-17 18:52:14 -05:00
donkopotamus cf8e5e3cf5 Bug Fix: Stop generating bad sql if an empty UniqueConstraint() is given 2014-01-17 11:00:24 +13:00
donkopotamus 3593548960 Support mssql_clustered option on UniqueConstraint (plus docs and test) 2014-01-17 10:46:16 +13:00
donkopotamus 1de7259093 Remove support for mssql_clustered on Table 2014-01-17 10:38:31 +13:00
Mike Bayer 789ab91743 - changelog + test for pullreq github 58 2014-01-14 20:22:11 -05:00
donkopotamus 40563e9355 Support mssql_clustered option in mssql dialect for both Table and PrimaryKeyConstraint 2014-01-14 12:44:05 +13:00
Mike Bayer bd74f81bb5 - Fixed a bug involving the new flattened JOIN structures which
are used with :func:`.joinedload()` (thereby causing a regression
in joined eager loading) as well as :func:`.aliased`
in conjunction with the ``flat=True`` flag and joined-table inheritance;
basically multiple joins across a "parent JOIN sub" entity using different
paths to get to a target class wouldn't form the correct ON conditions.
An adjustment / simplification made in the mechanics of figuring
out the "left side" of the join in the case of an aliased, joined-inh
class repairs the issue. [ticket:2908]
2014-01-13 17:53:37 -05:00
Mike Bayer 62ec682239 - a little bit of profile bump, just on insert not too concerned 2014-01-13 16:35:50 -05:00
Mike Bayer 1536bc4664 - The MySQL CAST compilation now takes into account aspects of a string
type such as "charset" and "collation".  While MySQL wants all character-
based CAST calls to use the CHAR type, we now create a real CHAR
object at CAST time and copy over all the parameters it has, so that
an expression like ``cast(x, mysql.TEXT(charset='utf8'))`` will
render ``CAST(t.col AS CHAR CHARACTER SET utf8)``.

- Added new "unicode returns" detection to the MySQL dialect and
to the default dialect system overall, such that any dialect
can add extra "tests" to the on-first-connect "does this DBAPI
return unicode directly?" detection. In this case, we are
adding a check specifically against the "utf8" encoding with
an explicit "utf8_bin" collation type (after checking that
this collation is available) to test for some buggy unicode
behavior observed with MySQLdb version 1.2.3.  While MySQLdb
has resolved this issue as of 1.2.4, the check here should
guard against regressions.  The change also allows the "unicode"
checks to log in the engine logs, which was not previously
the case. [ticket:2906]
2014-01-13 14:05:05 -05:00
Mike Bayer 232e3762b7 revert r2775c95b1ee30831216cc5 which was mostly an inadvertent commit, except for the changelog part 2014-01-13 10:37:15 -05:00
Mike Bayer bebf30e34d - continue with [ticket:2907] and further clean up how we set up
_reset_agent, so that it's local to the various begin_impl(),
rollback_impl(), etc.  this allows setting/resetting of the flag
to be symmetric.
- don't set _reset_agent if it's not None, don't unset it if it isn't
our own transaction.
- make sure we clean it out in close().
- basically, we're dealing here with pools using "threadlocal" that have a
counter, other various mismatches that the tests bring up
- test for recover() now has to invalidate() the previous connection,
because closing it actually rolls it back (e.g. this test was relying
on the broken behavior).
2014-01-13 03:22:11 -05:00
Mike Bayer 578df5b86b - dont run deletes here 2014-01-13 02:38:41 -05:00
Mike Bayer 9c64607572 - :class:.Connection now associates a new
:class:`.RootTransaction` or :class:`.TwoPhaseTransaction`
with its immediate :class:`._ConnectionFairy` as a "reset handler"
for the span of that transaction, which takes over the task
of calling commit() or rollback() for the "reset on return" behavior
of :class:`.Pool` if the transaction was not otherwise completed.
This resolves the issue that a picky transaction
like that of MySQL two-phase will be
properly closed out when the connection is closed without an
explicit rollback or commit (e.g. no longer raises "XAER_RMFAIL"
in this case - note this only shows up in logging as the exception
is not propagated within pool reset).
This issue would arise e.g. when using an orm
:class:`.Session` with ``twophase`` set, and then
:meth:`.Session.close` is called without an explicit rollback or
commit.   The change also has the effect that you will now see
an explicit "ROLLBACK" in the logs when using a :class:`.Session`
object in non-autocommit mode regardless of how that session was
discarded.  Thanks to Jeff Dairiki and Laurence Rowe for isolating
the issue here. [ticket:2907]
2014-01-12 19:43:13 -05:00
Mike Bayer c91fd822bc - add new event PoolEvents.invalidate(). allows interception of invalidation
events including auto-invalidation, which is useful both for tests here as well as
detecting failure conditions within the "reset" or "close" cases.
- rename the argument for PoolEvents.reset() to dbapi_connection and connection_record
to be consistent with everything else.
- add new documentation sections on invalidation, including auto-invalidation
and the invalidation process within the pool.
- add _ConnectionFairy and _ConnectionRecord to the pool documentation.  Establish
docs for common _ConnectionFairy/_ConnectionRecord methods and accessors and
have PoolEvents docs refer to _ConnectionRecord,
since it is passed to all events.  Rename a few _ConnectionFairy methods that are actually
private to pool such as _checkout(), _checkin() and _checkout_existing(); there should not
be any external code calling these
2014-01-12 17:34:20 -05:00
Mike Bayer c427d24d74 - add a CLI to determine waht kind of test to run 2014-01-11 19:43:50 -05:00
Mike Bayer 2775c95b1e new changelog 2014-01-11 13:12:40 -05:00
Mike Bayer fa5970c265 - these tests are really old but trying to make sure everything is closed out 2014-01-05 18:25:51 -05:00
Mike Bayer 21bc2c2a5b - docs + tests 2014-01-05 16:48:01 -05:00
Mike Bayer daafd63c3a Merge branch 'automap'
Conflicts:
	doc/build/changelog/changelog_09.rst
2014-01-05 16:47:15 -05:00