Skip to content

Commit e9eac7e

Browse files
include_views feature of django 2.1 added
1 parent a9fabad commit e9eac7e

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

inspectdb_refactor/management/commands/inspectdb_refactor.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,11 @@ def strip_prefix(s):
142142

143143
with connection.cursor() as cursor:
144144
known_models = []
145-
tables_to_introspect = options['table'] or connection.introspection.table_names(cursor)
145+
table_info = connection.introspection.get_table_list(cursor)
146+
tables_to_introspect = (
147+
options['table'] or
148+
sorted(info.name for info in table_info if options['include_views'] or info.type == 't')
149+
)
146150

147151
for table_name in tables_to_introspect:
148152
if table_name in models_to_pass:
@@ -262,7 +266,8 @@ def strip_prefix(s):
262266
if comment_notes:
263267
field_desc += ' # ' + ' '.join(comment_notes)
264268
file_code += ' %s\n' % field_desc
265-
for meta_line in self.get_meta(table_name, constraints, column_to_field_name):
269+
is_view = any(info.name == table_name and info.type == 'v' for info in table_info)
270+
for meta_line in self.get_meta(table_name, constraints, column_to_field_name, is_view):
266271
file_code += "%s\n" % (meta_line)
267272

268273
handle.write(file_code)

setup.py

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

1010
setup(
1111
name='django-inspectdb-refactor',
12-
version='0.2',
12+
version='0.4',
1313
packages=find_packages(),
1414
include_package_data=True,
1515
license='BSD License', # example license

0 commit comments

Comments
 (0)