Skip to content
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

feat(torii/processor): support integer type column for key #2424

Closed
wants to merge 2 commits into from

Conversation

lambda-0x
Copy link
Contributor

@lambda-0x lambda-0x commented Sep 13, 2024

If the type of external_* column in the query was not text the try_get would error out because it cannot decode to string, so now we check the column time and decode the value based on it

and also call execute on db before fetching entity keys because the query which inserts these key could be in queue

Stack:

⚠️ Part of a stack created by spr. Do not merge manually using the UI - doing so may have unexpected results.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Improved error handling for entity key fetching and deserialization, providing clearer error messages.
    • Enhanced database management after setting entity records to ensure proper operation of subsequent events.
    • Added type checking for SQL query results, improving data handling and preventing failures from unexpected data types.
    • Introduced new processors for handling update events for members and records, expanding event processing capabilities.
    • Added a new test case to validate the handling of update operations, ensuring reliability of the new functionality.
  • Bug Fixes

    • Enhanced robustness in SQL processing logic by raising errors for unsupported column types.

Copy link

coderabbitai bot commented Sep 13, 2024

Walkthrough

Ohayo, sensei! The changes in this pull request enhance error handling and control flow across several files, including store_update_record.rs, sql.rs, and store_set_record.rs. Key updates involve improved error messages for entity key retrieval and deserialization, refined SQL query result processing with type checking for columns, and the introduction of new processors for handling update events in sql_test.rs. These modifications collectively aim to strengthen the robustness of database operations and event processing.

Changes

File Path Change Summary
crates/torii/core/src/processors/store_update_record.rs
crates/torii/core/src/sql.rs
Enhanced error handling with additional context in error messages for entity key retrieval and deserialization. Improved SQL query result processing by adding type checking for TEXT and INTEGER columns, raising errors for unsupported types.
crates/torii/core/src/processors/store_set_record.rs
crates/torii/core/src/sql_test.rs
Introduced a call to db.execute().await? to flush the queue early in set_record. Added new processors for handling update events and a test case to validate the new functionality in sql_test.rs.

Possibly related PRs


Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 838082e and 4fa99ad.

Files selected for processing (2)
  • crates/torii/core/src/processors/store_set_record.rs (1 hunks)
  • crates/torii/core/src/sql_test.rs (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • crates/torii/core/src/processors/store_set_record.rs
Additional comments not posted (2)
crates/torii/core/src/sql_test.rs (2)

25-26: Ohayo sensei! The new processors look good to me.

The StoreUpdateRecordProcessor and StoreUpdateMemberProcessor are correctly added to the event processors map in the bootstrap_engine function. This will allow the system to handle update events for records and members.

Also applies to: 47-48


377-462: Ohayo sensei! The new test case looks great.

The test_update_with_set_record function is a comprehensive test that validates the behavior of the system when handling updates. It correctly sets up the environment, performs the necessary transactions, and asserts that the bootstrap_engine function does not fail.

This test will help ensure the reliability of the update operations and prevent regressions in the future.


Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Sep 13, 2024

Codecov Report

Attention: Patch coverage is 94.44444% with 6 lines in your changes missing coverage. Please review.

Project coverage is 68.04%. Comparing base (ed2aa83) to head (4fa99ad).

Files with missing lines Patch % Lines
crates/torii/core/src/sql.rs 63.63% 4 Missing ⚠️
...s/torii/core/src/processors/store_update_record.rs 71.42% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2424      +/-   ##
==========================================
+ Coverage   67.91%   68.04%   +0.13%     
==========================================
  Files         364      364              
  Lines       47910    48013     +103     
==========================================
+ Hits        32539    32672     +133     
+ Misses      15371    15341      -30     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lambda-0x lambda-0x changed the title torii(processor): support integer type column for key feat(torii/processor): support integer type column for key Sep 14, 2024
@lambda-0x
Copy link
Contributor Author

better fix: #2427

@lambda-0x lambda-0x closed this Sep 14, 2024
@glihm glihm deleted the spr/main/a13ac0db branch January 16, 2025 22:08
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.

1 participant