summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES95
-rw-r--r--lib/sqlalchemy/databases/mysql.py9
-rw-r--r--test/engine/reflection.py4
3 files changed, 61 insertions, 47 deletions
diff --git a/CHANGES b/CHANGES
index 7518c61c2..17f943ade 100644
--- a/CHANGES
+++ b/CHANGES
@@ -7,74 +7,75 @@ CHANGES
0.5.0rc3
========
- orm
- - "not equals" comparisons of simple many-to-one relation
- to an instance will not drop into an EXISTS clause
- and will compare foreign key columns instead.
-
- - removed not-really-working use cases of comparing
- a collection to an iterable. Use contains() to test
- for collection membership.
-
- - Improved weakref identity map memory management to no longer
- require mutexing, resurrects garbage collected instance
- on a lazy basis for an InstanceState with pending changes.
+ - "not equals" comparisons of simple many-to-one relation to an
+ instance will not drop into an EXISTS clause and will compare
+ foreign key columns instead.
+
+ - Removed not-really-working use cases of comparing a collection
+ to an iterable. Use contains() to test for collection
+ membership.
+
+ - Improved weakref identity map memory management to no longer
+ require mutexing, resurrects garbage collected instance on a
+ lazy basis for an InstanceState with pending changes.
- relation() won't hide unrelated ForeignKey errors inside of
- the "please specify primaryjoin" message when determining
- join condition.
-
- - When using Query.join() with an explicit clause for the
- ON clause, the clause will be aliased in terms of the left
- side of the join, allowing scenarios like query(Source).
+ the "please specify primaryjoin" message when determining join
+ condition.
+
+ - When using Query.join() with an explicit clause for the ON
+ clause, the clause will be aliased in terms of the left side
+ of the join, allowing scenarios like query(Source).
from_self().join((Dest, Source.id==Dest.source_id)) to work
properly.
-
- - polymorphic_union() function respects the "key" of each
- Column if they differ from the column's name.
-
- - Added more granularity to internal attribute access, such
- that cascade and flush operations will not initialize
- unloaded attributes and collections, leaving them intact for
- a lazy-load later on. Backref events still initialize
- attrbutes and collections for pending instances.
- [ticket:1202]
-
- - InstanceState object now removes circular references to
- itself upon disposal to keep it outside of cyclic garbage
- collection.
-
+
+ - polymorphic_union() function respects the "key" of each Column
+ if they differ from the column's name.
+
+ - Added more granularity to internal attribute access, such that
+ cascade and flush operations will not initialize unloaded
+ attributes and collections, leaving them intact for a
+ lazy-load later on. Backref events still initialize attrbutes
+ and collections for pending instances. [ticket:1202]
+
+ - InstanceState object now removes circular references to itself
+ upon disposal to keep it outside of cyclic garbage collection.
+
- sql
- - Further simplified SELECT compilation and its relationship
- to result row processing.
+ - Further simplified SELECT compilation and its relationship to
+ result row processing.
- Direct execution of a union() construct will properly set up
result-row processing. [ticket:1194]
- The internal notion of an "OID" or "ROWID" column has been
removed. It's basically not used by any dialect, and the
- possibility of its usage with psycopg2's cursor.lastrowid
- is basically gone now that INSERT..RETURNING is available.
-
- - Removed "default_order_by()" method on all FromClause
- objects.
+ possibility of its usage with psycopg2's cursor.lastrowid is
+ basically gone now that INSERT..RETURNING is available.
+
+ - Removed "default_order_by()" method on all FromClause objects.
- Slightly changed behavior of IN operator for comparing to
empty collections. Now results in inequality comparison
- against self. More portable, but breaks with stored
- procedures that aren't pure functions.
+ against self. More portable, but breaks with stored procedures
+ that aren't pure functions.
- oracle
- Removed FIRST_ROWS() optimize flag when using LIMIT/OFFSET,
can be reenabled with optimize_limits=True create_engine()
flag. [ticket:536]
- - Wrote a docstring for Oracle dialect. Apparently that
- Ohloh "few source code comments" label is starting to sting
- :).
+ - Wrote a docstring for Oracle dialect. Apparently that Ohloh
+ "few source code comments" label is starting to sting :).
+
+ - Setting the auto_convert_lobs to False on create_engine() will
+ also instruct the OracleBinary type to return the cx_oracle
+ LOB object unchanged.
- - Setting the auto_convert_lobs to False on create_engine()
- will also instruct the OracleBinary type to return the
- cx_oracle LOB object unchanged.
+- mysql
+ - Fixed foreign key reflection in the edge case where a Table's
+ explicit schema= is the same as the schema (database) the
+ connection is attached to.
0.5.0rc2
========
diff --git a/lib/sqlalchemy/databases/mysql.py b/lib/sqlalchemy/databases/mysql.py
index f1187b8ac..743ec96ea 100644
--- a/lib/sqlalchemy/databases/mysql.py
+++ b/lib/sqlalchemy/databases/mysql.py
@@ -2334,11 +2334,20 @@ class MySQLSchemaReflector(object):
def _set_constraints(self, table, constraints, connection, only):
"""Apply constraints to a ``Table``."""
+ default_schema = None
+
for spec in constraints:
# only FOREIGN KEYs
ref_name = spec['table'][-1]
ref_schema = len(spec['table']) > 1 and spec['table'][-2] or None
+ if not ref_schema:
+ if default_schema is None:
+ default_schema = connection.dialect.get_default_schema_name(
+ connection)
+ if table.schema == default_schema:
+ ref_schema = table.schema
+
loc_names = spec['local']
if only and not set(loc_names).issubset(only):
self.logger.info(
diff --git a/test/engine/reflection.py b/test/engine/reflection.py
index 5916e8cad..7963cc0e4 100644
--- a/test/engine/reflection.py
+++ b/test/engine/reflection.py
@@ -696,19 +696,23 @@ class SchemaTest(TestBase):
metadata = MetaData(engine)
table1 = Table('table1', metadata,
Column('col1', sa.Integer, primary_key=True),
+ test_needs_fk=True,
schema=schema)
table2 = Table('table2', metadata,
Column('col1', sa.Integer, primary_key=True),
Column('col2', sa.Integer,
sa.ForeignKey('%s.table1.col1' % schema)),
+ test_needs_fk=True,
schema=schema)
try:
metadata.create_all()
metadata.create_all(checkfirst=True)
+ assert len(metadata.tables) == 2
metadata.clear()
table1 = Table('table1', metadata, autoload=True, schema=schema)
table2 = Table('table2', metadata, autoload=True, schema=schema)
+ assert len(metadata.tables) == 2
finally:
metadata.drop_all()