Skip to content

Commit

Permalink
Merge pull request #631 from jgao54/fab-airflow
Browse files Browse the repository at this point in the history
Add binary column support for sqlalchemy
  • Loading branch information
dpgaspar committed Oct 29, 2017
2 parents fd19e0e + 1f79b84 commit 877f273
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions flask_appbuilder/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class FieldConverter(object):
('is_gridfs_file', MongoFileField, BS3FileUploadFieldWidget),
('is_gridfs_image', MongoImageField, BS3ImageUploadFieldWidget),
('is_text', TextAreaField, BS3TextAreaFieldWidget),
('is_binary', TextAreaField, BS3TextAreaFieldWidget),
('is_string', StringField, BS3TextFieldWidget),
('is_integer', IntegerField, BS3TextFieldWidget),
('is_numeric', DecimalField, BS3TextFieldWidget),
Expand Down
3 changes: 3 additions & 0 deletions flask_appbuilder/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ def is_string(self, col_name):
def is_text(self, col_name):
return False

def is_binary(self, col_name):
return False

def is_integer(self, col_name):
return False

Expand Down
8 changes: 8 additions & 0 deletions flask_appbuilder/models/sqla/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ class SQLAFilterConverter(BaseFilterConverter):
FilterNotEndsWith,
FilterNotContains,
FilterNotEqual]),
('is_binary', [FilterStartsWith,
FilterEndsWith,
FilterContains,
FilterEqual,
FilterNotStartsWith,
FilterNotEndsWith,
FilterNotContains,
FilterNotEqual]),
('is_string', [FilterStartsWith,
FilterEndsWith,
FilterContains,
Expand Down
6 changes: 6 additions & 0 deletions flask_appbuilder/models/sqla/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ def is_text(self, col_name):
except:
return False

def is_binary(self, col_name):
try:
return isinstance(self.list_columns[col_name].type, sa.types.LargeBinary)
except:
return False

def is_integer(self, col_name):
try:
return isinstance(self.list_columns[col_name].type, sa.types.Integer)
Expand Down

0 comments on commit 877f273

Please sign in to comment.