mitsuhiko/flask-sqlalchemy — pull request #222 by ryanss (2014-09-10 19:24:07+00:00)
Title: Fix #26 Use unique MetaData object for each bind

An InvalidRequestError occurs when subclassing db.Model with two objects
that have the same `__tablename__` but different `__bind_key__`.

````python
sqlalchemy.exc.InvalidRequestError: Table 'users' is already defined for
this MetaData instance. Specify 'extend_existing=True' to redefine
options and columns on an existing Table object.
```

This could happen, for example, if you had a `users` table in two
different databases that you needed to access. This patch creates a
unique MetaData object for each bind_key which stops this error from
happening and allows access to tables with the same name in different
databases. It also includes a test to verify the error is
fixed.