Skip to content

Commit

Permalink
[irods#8249] Add support for order_asc to GenQuery1 string parser.
Browse files Browse the repository at this point in the history
GenQuery1 is documented as supporting `order` and `order_asc` for
sorting. However, the implementation rejects the `order_asc` keyword.
This commit corrects that.

Also, the test which caught this bug has been updated so that `irule`
reports errors appropriately.
  • Loading branch information
korydraughn committed Feb 28, 2025
1 parent e4ab260 commit 55f1aea
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/core/src/rcMisc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3103,7 +3103,7 @@ getSelVal( char * c ) {
}
// =-=-=-=-=-=-=-
// JMC - backport 4795
if ( !strcmp( c, "order" ) || !strcmp( c, "ORDER" ) ) {
if (!strcmp(c, "order") || !strcmp(c, "order_asc") || !strcmp(c, "ORDER") || !strcmp(c, "ORDER_ASC")) {
return ORDER_BY;
}
if ( !strcmp( c, "order_desc" ) || !strcmp( c, "ORDER_DESC" ) ) {
Expand Down
25 changes: 22 additions & 3 deletions scripts/irods/test/test_prep_genquery_iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,23 @@ def main(rule_args,callback,rei):
'''),
"iter_chained_queries_",
lambda : ast.literal_eval(output) is True
), ( #----------------
# The following rule text is derived from the rule text above. The only difference
# between the two is the keyword used for sorting (i.e. order vs order_asc). This helps
# protect against regressions.
frame_rule('''\
import itertools
q = Query(callback,
columns=["order(DATA_NAME)"],
conditions="DATA_NAME like '03%' and COLL_NAME = '{{c}}'".format(c=TestCollection)
)
q2 = q.copy(conditions="DATA_NAME like '05%' and COLL_NAME = '{{c}}'".format(c=TestCollection))
chained_queries = itertools.chain(q, q2)
compare_this = [x for x in ('%04o'%y for y in range({max_count}+1)) if x[:2] in ('03','05')]
callback.writeLine('stdout',repr([x for x in chained_queries] == compare_this and len(compare_this)==128))
'''),
"iter_chained_queries_with_order_",
lambda : ast.literal_eval(output) is True
), ( #----------------
frame_rule('''\
#import pprint # - for DEBUG only
Expand Down Expand Up @@ -314,11 +331,13 @@ def main(rule_args,callback,rei):
with generateRuleFile(names_list = self.to_unlink,
prefix = file_prefix) as f:
rule_file = f.name
print(rule_text.format(**locals()), file=f, end='')
output, err, rc = self.admin.run_icommand("irule -F " + rule_file)
populated_rule_text = rule_text.format(**locals())
print(populated_rule_text) # For debugging.
print(populated_rule_text, file=f, end='')
output, err, rc = self.admin.run_icommand("irule -r irods_rule_engine_plugin-python-instance -F " + rule_file)
self.assertTrue(rc == 0, "icommand status ret = {r} output = '{o}' err='{e}'".format(r=rc,o=output,e=err))
assertResult=assertion()
if not assertResult: print( "failing output ====> " + output + "\n<====" )
if not assertResult: print( "failing output ====> " + output + "\n<====" )
self.assertTrue(assertResult, "test failed for prefix: {}".format(file_prefix))

# remove the next line when msiGetMoreRows always returns an accurate value for continueInx
Expand Down

0 comments on commit 55f1aea

Please sign in to comment.