Skip to content

Commit

Permalink
Providing an autoload_with info automatically sets autoload to True
Browse files Browse the repository at this point in the history
  • Loading branch information
malikdiarra committed Aug 9, 2014
1 parent cca4d8f commit ad8f921
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/sqlalchemy/sql/schema.py
Expand Up @@ -401,8 +401,8 @@ def _init(self, name, metadata, *args, **kwargs):
else:
self.fullname = self.name

autoload = kwargs.pop('autoload', False)
autoload_with = kwargs.pop('autoload_with', None)
autoload = kwargs.pop('autoload', autoload_with is not None)
# this argument is only used with _init_existing()
kwargs.pop('autoload_replace', True)
include_columns = kwargs.pop('include_columns', None)
Expand Down Expand Up @@ -460,8 +460,8 @@ def _sorted_constraints(self):
return sorted(self.constraints, key=lambda c: c._creation_order)

def _init_existing(self, *args, **kwargs):
autoload = kwargs.pop('autoload', False)
autoload_with = kwargs.pop('autoload_with', None)
autoload = kwargs.pop('autoload', autoload_with is not None)
autoload_replace = kwargs.pop('autoload_replace', True)
schema = kwargs.pop('schema', None)
if schema and schema != self.schema:
Expand Down
16 changes: 16 additions & 0 deletions test/engine/test_reflection.py
Expand Up @@ -64,6 +64,22 @@ def test_basic_reflection(self):
self.assert_tables_equal(users, reflected_users)
self.assert_tables_equal(addresses, reflected_addresses)

@testing.provide_metadata
def test_autoload_with_imply_autoload(self,):
meta = self.metadata
t = Table(
't',
meta,
Column('id', sa.Integer, primary_key=True),
Column('x', sa.String(20)),
Column('y', sa.Integer))
meta.create_all()

meta2 = MetaData()
reflected_t = Table('t', meta2,
autoload_with=testing.db)
self.assert_tables_equal(t, reflected_t)

@testing.provide_metadata
def test_two_foreign_keys(self):
meta = self.metadata
Expand Down

0 comments on commit ad8f921

Please sign in to comment.