Skip to content

Commit f465142

Browse files
committed
Merge branch '2.3-maintenance'
2 parents 5ac5ab4 + df7903e commit f465142

File tree

5 files changed

+32
-2
lines changed

5 files changed

+32
-2
lines changed

CHANGES.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ Changelog
22
=========
33

44

5+
Version 2.3.2
6+
-------------
7+
8+
Released on October 11, 2017
9+
10+
- Don't mask the parent table for single-table inheritance models. (`#561`_)
11+
12+
.. _#561: https://github.com/mitsuhiko/flask-sqlalchemy/pull/561
13+
14+
515
Version 2.3.1
616
-------------
717

flask_sqlalchemy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from ._compat import itervalues, string_types, to_str, xrange
3333
from .model import DefaultMeta
3434

35-
__version__ = '2.3.1'
35+
__version__ = '2.3.2'
3636

3737
# the best timer function for the platform
3838
if sys.platform == 'win32':

flask_sqlalchemy/model.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ def __init__(cls, name, bases, d):
6666

6767
super(NameMetaMixin, cls).__init__(name, bases, d)
6868

69+
# __table_cls__ has run at this point
70+
# if no table was created, use the parent table
71+
if (
72+
'__tablename__' not in cls.__dict__
73+
and '__table__' in cls.__dict__
74+
and cls.__dict__['__table__'] is None
75+
):
76+
del cls.__table__
77+
6978
def __table_cls__(cls, *args, **kwargs):
7079
"""This is called by SQLAlchemy during mapper setup. It determines the
7180
final table object that the model will use.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
setup(
1919
name='Flask-SQLAlchemy',
20-
version='2.3.1',
20+
version='2.3.2',
2121
url='http://github.com/mitsuhiko/flask-sqlalchemy',
2222
license='BSD',
2323
author='Armin Ronacher',

tests/test_table_name.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,14 @@ class User(db.Model):
213213
pass
214214

215215
assert 'could not assemble any primary key' in str(info.value)
216+
217+
218+
def test_single_has_parent_table(db):
219+
class Duck(db.Model):
220+
id = db.Column(db.Integer, primary_key=True)
221+
222+
class Call(Duck):
223+
pass
224+
225+
assert Call.__table__ is Duck.__table__
226+
assert '__table__' not in Call.__dict__

0 commit comments

Comments
 (0)