8000 feat: null params return last record by outerlook · Pull Request #919 · trufnetwork/node · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: null params return last record #919

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 5, 2025
Merged

Conversation

outerlook
Copy link
Contributor

Description

This PR adjusts the behavior of stream query actions (get_record_primitive, get_index_primitive, get_record_composed, get_record_composed_index) to return only the latest record/index when both the from and to time parameters are omitted. This aligns the behavior with historical expectations. It also includes improvements to composed query logic and enhances test coverage and debugging for query functions.

  • SQL Migrations:
    • Modified get_record_primitive, get_index_primitive, get_record_composed, and get_record_composed_index to return the latest entry if from and to are NULL.
    • Refactored base value retrieval in get_record_composed_index into a new private helper action internal_get_base_value.
    • Fixed variable usage (@data_provider to $data_provider) in list_streams.
    • Prevented emission of closing weight deltas for open-ended intervals in composed queries.
  • Go Tests (query_test.go):
    • Added new test cases (test_GetLatestRecord, test_GetLatestIndex, test_GetLatestIndexChange, test_GetRecordFromSpecificTime, test_GetRecordUntilSpecificTime, test_GetIndexFromSpecificTime, test_GetIndexUntilSpecificTime, test_GetIndexChangeFromSpecificTime, test_GetIndexChangeUntilSpecificTime) to cover scenarios where from_time and/or to_time are omitted in query procedures.
    • Improved validateTableResult to output the actual result table in case of test failure, facilitating easier debugging.
    • Added helper FormatResultRows.

Related Problem

How Has This Been Tested?

  • Added comprehensive Go unit tests in tests/streams/query/query_test.go to cover the new logic for handling omitted time ranges in query procedures (get_record, get_index, get_index_change).
  • Existing tests for primitive and composed queries were run to ensure no regressions.

8000
outerlook added 4 commits May 5, 2025 09:27
This commit introduces logic to return the latest record when both 'from' and 'to' parameters are omitted in the `get_record_primitive`, `get_index_primitive`, and `get_last_record_composed` actions across multiple SQL migration scripts. These changes improve historical consistency in data retrieval, ensuring that the most recent records are accessible when no specific time range is provided.
This commit introduces a new action, `internal_get_base_value`, to improve the retrieval of base values in composed queries. It also adds logic to handle maximum integer values in the `get_index_primitive` and `get_last_record_composed` actions, ensuring that closing deltas for open intervals are not emitted. These changes enhance the accuracy and reliability of historical data retrieval in SQL migrations.
This commit adds new test cases to the query test suite, ensuring that when 'from_time' and 'to_time' are omitted, the latest available record, index, and index change are returned. Additionally, it introduces tests for retrieving records and indices based on specific time parameters, improving the coverage and reliability of the query functionality.
@outerlook outerlook changed the base branch from main to refactor/node-2.0 May 5, 2025 13:36
@outerlook outerlook self-assigned this May 5, 2025
@outerlook outerlook requested a review from MicBun May 5, 2025 13:37
Copy link
pr-time-tracker bot commented May 5, 2025

Time Submission Status

Member Status Time Action Last Update
outerlook ✅ Submitted 3h Update time May 5, 2025, 1:38 PM
MicBun ✅ Submitted 20min Update time May 6, 2025, 12:09 AM

@MicBun MicBun merged commit d6dc04b into refactor/node-2.0 May 5, 2025
2 checks passed
@MicBun MicBun deleted the fix/null-params branch May 5, 2025 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: get_record without parameter returned more than one value
2 participants
0