Skip to content

Commit

Permalink
fix: metadata option sql
Browse files Browse the repository at this point in the history
  • Loading branch information
杨国璇 authored and 杨国璇 committed Jan 9, 2025
1 parent 31558c9 commit 66f2b85
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions repo_metadata/view_data_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def _get_option_name_by_id(self, option_id):
for op in options:
if op.get('id') == option_id:
return op.get('name')
raise SQLGeneratorOptionInvalidError('option is invalid.')
return ''

def op_is(self):
if not self.filter_term:
Expand Down Expand Up @@ -302,7 +302,7 @@ def op_is_any_of(self):
if not isinstance(filter_term, list):
filter_term = [filter_term, ]
filter_term = [self._get_option_name_by_id(f) for f in filter_term]
option_names = ["'%s'" % (op_name) for op_name in filter_term]
option_names = ["'%s'" % (op_name) for op_name in filter_term if op_name]
if not option_names:
return ""
return "`%(column_name)s` in (%(option_names)s)" % ({
Expand All @@ -317,7 +317,7 @@ def op_is_none_of(self):
if not isinstance(filter_term, list):
filter_term = [filter_term, ]
filter_term = [self._get_option_name_by_id(f) for f in filter_term]
option_names = ["'%s'" % (op_name) for op_name in filter_term]
option_names = ["'%s'" % (op_name) for op_name in filter_term if op_name]
if not option_names:
return ""
return "`%(column_name)s` not in (%(option_names)s)" % ({
Expand Down Expand Up @@ -346,13 +346,13 @@ def _get_option_name_by_id(self, option_id):
for op in options:
if op.get('id') == option_id:
return op.get('name')
raise SQLGeneratorOptionInvalidError('option is invalid')
return ''

def op_has_any_of(self):
if not self.filter_term:
return ""
filter_term = [self._get_option_name_by_id(f) for f in self.filter_term]
option_names = ["'%s'" % op_name for op_name in filter_term]
option_names = ["'%s'" % op_name for op_name in filter_term if op_name]
option_names_str = ', '.join(option_names)
return "`%(column_name)s` in (%(option_names_str)s)" % ({
"column_name": self.column_name,
Expand All @@ -363,7 +363,7 @@ def op_has_none_of(self):
if not self.filter_term:
return ""
filter_term = [self._get_option_name_by_id(f) for f in self.filter_term]
option_names = ["'%s'" % op_name for op_name in filter_term]
option_names = ["'%s'" % op_name for op_name in filter_term if op_name]
option_names_str = ', '.join(option_names)
return "`%(column_name)s` has none of (%(option_names_str)s)" % ({
"column_name": self.column_name,
Expand All @@ -374,7 +374,7 @@ def op_has_all_of(self):
if not self.filter_term:
return ""
filter_term = [self._get_option_name_by_id(f) for f in self.filter_term]
option_names = ["'%s'" % op_name for op_name in filter_term]
option_names = ["'%s'" % op_name for op_name in filter_term if op_name]
option_names_str = ', '.join(option_names)
return "`%(column_name)s` has all of (%(option_names_str)s)" % ({
"column_name": self.column_name,
Expand All @@ -385,7 +385,7 @@ def op_is_exactly(self):
if not self.filter_term:
return ""
filter_term = [self._get_option_name_by_id(f) for f in self.filter_term]
option_names = ["'%s'" % op_name for op_name in filter_term]
option_names = ["'%s'" % op_name for op_name in filter_term if op_name]
option_names_str = ', '.join(option_names)
return "`%(column_name)s` is exactly (%(option_names_str)s)" % ({
"column_name": self.column_name,
Expand Down

0 comments on commit 66f2b85

Please sign in to comment.