Skip to content

Commit

Permalink
Merge pull request #8 from Caleydo/update_main
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickAdelberger authored Dec 7, 2021
2 parents 0dc4242 + a5bbfe3 commit f2a6e36
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions coral/sql_query_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,18 @@ def get_cohorts_by_id_sql(self, args, error_msg):
raise RuntimeError(error_msg)
values_split = values.split(VALUE_LIST_DELIMITER)

cnt = 0
for val in values_split:
curr_val = "{val}".format(val=val)
str_values = str_values + ("{val}, ".format(val=curr_val))
# check for if value is interger
if curr_val.isdigit():
str_values = str_values + ("{val}, ".format(val=curr_val))
cnt += 1

str_values = str_values[:-2] # remove the last ', ' from the value list
if cnt > 0:
str_values = str_values[:-2] # remove the last ', ' from the value list
else:
str_values = "-1" # returns no cohorts -> ids are only positiv

sql_text = 'SELECT id, name, is_initial, previous_cohort, entity_database, entity_schema, entity_table FROM cohort.cohort c WHERE c.id IN ({str_values})'.format(str_values=str_values)
# print('sql_text', sql_text)
Expand Down

0 comments on commit f2a6e36

Please sign in to comment.