Skip to content
Closed
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions python_rules/test_258.r
Comment thread
trel marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import datetime
import pprint as pp
Comment thread
d-w-moore marked this conversation as resolved.
Outdated
from genquery import Query

class Err(Exception): pass

def main(rule_args, callback, rei):
colls = []
home='/tempZone/home/rods'
now = f'{datetime.datetime.now():%s.%f}'

# Keep the following an even number:
n_base_names = 10
Comment thread
d-w-moore marked this conversation as resolved.
Outdated

coll_names_lowercase = ['issue-258-'+str(i) for i in range(n_base_names)]

try:
for coll in (coll_names_lowercase + [_.capitalize() for _ in coll_names_lowercase]):
retv = callback.msiCollCreate((coll:=f'{home}/{now}/{coll}'), '1', -1)
if retv['arguments'][2] != 0:
raise Err(f'could not create test collection {coll}')
else:
colls.append(coll)

for limit_ in (None, 4, 14):
for case_sensitive_ in (False, True):
for offset_ in (0,3):
query = Query(
callback,
["COLL_NAME"],
f"""COLL_NAME like '%/issue%' and COLL_PARENT_NAME = '{home}/{now}'"""
, case_sensitive=case_sensitive_
, offset=offset_
, limit=limit_
)

expected_total_rows = n_base_names * (1 if case_sensitive_ else 2)
expected_result_rows = min(
max(0, expected_total_rows - offset_),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this always result in expected_total_rows - offset_?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it would, if limit_ were None. if limit_ were sufficiently small integer, say 0, then would get 0 returned

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm referring to max(0, expected_total_rows - offset_) on L41 only. limit_ doesn't affect the outcome of that expression.

@d-w-moore d-w-moore Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, as far as I can figure, if no effect being exerted by an integer value of limit_ , the end result should be that there will be expected result rows = max(0,expected_total_rows - offset_) returned from the query.

Is the formula as-given creating any ill effects in the table? Are the resulting expected_* table columns, as realized in the new comment block, looking as they should?

I may be misunderstanding the question still; if so, maybe we can real-time chat outside this forum.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If someone were to pass offset_ of more than expected_total_rows, the result would be no rows returned (0) rather than a negative value, hence the max (0, ...) part.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe that case should be included in the test?

@korydraughn korydraughn Jun 5, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After discussion, @d-w-moore and I decided it's worth adding a case which exercises the max expression. It might reveal something we hadn't considered.

limit_ if limit_ is not None else expected_total_rows
)
Comment thread
trel marked this conversation as resolved.

# Assert that offset=1 produced the correct number of row results.
if (got_result_rows:=len(list(query))) != expected_result_rows:
Comment thread
d-w-moore marked this conversation as resolved.
Outdated
raise Err(f'{expected_result_rows=}; {got_result_rows=}')

# Assert that total_rows found the correct number of total matching rows.
if (got_total_rows:=query.total_rows()) != expected_total_rows:
Comment thread
d-w-moore marked this conversation as resolved.
Outdated
raise Err(f'{expected_total_rows=}; {got_total_rows=}')
except:
return -1
finally:
callback.msiRmColl(f'{home}/{now}','forceFlag=',-1)

INPUT null
OUTPUT ruleExecOut
Loading