Commit 1745c404 authored by Serge S. Koval's avatar Serge S. Koval

Restored SQLAlchemy 0.7 support

parent a313e2a3
...@@ -32,6 +32,8 @@ def get_primary_key(model): ...@@ -32,6 +32,8 @@ def get_primary_key(model):
pks.append(get_column_for_current_model(p).key) pks.append(get_column_for_current_model(p).key)
else: else:
pks.append(p.key) pks.append(p.key)
elif p.is_primary():
pks.append(p.key)
if len(pks) == 1: if len(pks) == 1:
return pks[0] return pks[0]
...@@ -52,8 +54,12 @@ def is_inherited_primary_key(prop): ...@@ -52,8 +54,12 @@ def is_inherited_primary_key(prop):
:return: Boolean :return: Boolean
:raises: Exceptions as they occur - no ExceptionHandling here :raises: Exceptions as they occur - no ExceptionHandling here
""" """
if not hasattr(prop, 'expression'):
return False
if prop.expression.primary_key: if prop.expression.primary_key:
return len(prop._orig_columns) == len(prop.columns)-1 return len(prop._orig_columns) == len(prop.columns)-1
return False return False
def get_column_for_current_model(prop): def get_column_for_current_model(prop):
......
...@@ -326,6 +326,7 @@ class ModelView(BaseModelView): ...@@ -326,6 +326,7 @@ class ModelView(BaseModelView):
columns.append(p.key) columns.append(p.key)
elif hasattr(p, 'columns'): elif hasattr(p, 'columns'):
column_inherited_primary_key = False column_inherited_primary_key = False
if len(p.columns) != 1: if len(p.columns) != 1:
if is_inherited_primary_key(p): if is_inherited_primary_key(p):
column = get_column_for_current_model(p) column = get_column_for_current_model(p)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment