Skip to content

Commit 7bc9c4b

Browse files
committed
Fixed unlimited row_limit parameter for SSO queries
1 parent 186a514 commit 7bc9c4b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

astroquery/esasky/core.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ def query_sso_maps(self, sso_name, *, sso_type="ALL", missions=__ALL_STRING,
463463
.astropy/astroquery/cache. Defaults to True.
464464
row_limit : int, optional
465465
Determines how many rows that will be fetched from the database
466-
for each mission.
466+
for each mission. Can be -1 to select maximum (currently 100 000).
467467
Defaults to 10000.
468468
469469
Returns
@@ -513,15 +513,18 @@ def query_sso_maps(self, sso_name, *, sso_type="ALL", missions=__ALL_STRING,
513513

514514
sso_type = self._get_sso_db_type(sso['sso_type'])
515515
sso_db_identifier = self._get_db_sso_identifier(sso['sso_type'])
516+
top = ""
517+
if sanitized_row_limit > 0:
518+
top = "TOP {row_limit} ".format(sanitized_row_limit)
516519
for name in sanitized_missions:
517520
data_table = self._find_mission_tap_table_name(sso_json, name)
518521
mission_json = self._find_mission_parameters_in_json(data_table, sso_json)
519522
x_match_table = mission_json['ssoXMatchTapTable']
520-
query = 'SELECT TOP {row_limit} * FROM {data_table} AS a JOIN {x_match_table} AS b ' \
523+
query = 'SELECT {top}* FROM {data_table} AS a JOIN {x_match_table} AS b ' \
521524
'ON a.observation_oid = b.observation_oid JOIN sso.ssoid AS c ' \
522525
'ON b.sso_oid = c.sso_oid WHERE c.{sso_db_identifier} = \'{sso_name}\' ' \
523526
'AND c.sso_type = \'{sso_type}\'' \
524-
.format(row_limit=sanitized_row_limit, data_table=data_table, x_match_table=x_match_table,
527+
.format(top=top, data_table=data_table, x_match_table=x_match_table,
525528
sso_db_identifier=sso_db_identifier, sso_name=sso['sso_name'], sso_type=sso_type)
526529
table = self.query(query)
527530
if len(table) > 0:

0 commit comments

Comments
 (0)