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

fix(torii): i64 deser #2636

Merged
merged 1 commit into from
Nov 5, 2024
Merged

fix(torii): i64 deser #2636

merged 1 commit into from
Nov 5, 2024

Conversation

Larkooo
Copy link
Collaborator

@Larkooo Larkooo commented Nov 5, 2024

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced efficiency in retrieving Primitive::I64 values by simplifying the conversion process.
    • Preserved error handling mechanisms for improved reliability during data retrieval.

Copy link

coderabbitai bot commented Nov 5, 2024

Walkthrough

Ohayo, sensei! The changes in this pull request primarily involve the map_row_to_ty function within the model.rs file. The function's handling of the Primitive::I64 type has been streamlined by directly retrieving values as i64, removing the previous need for string manipulation and hexadecimal conversion. While the overall structure and logic of the function remain intact, this modification enhances efficiency without altering any existing functionality or error handling.

Changes

File Path Change Summary
crates/torii/core/src/model.rs Modified map_row_to_ty to retrieve Primitive::I64 values directly as i64, eliminating string manipulation and hexadecimal conversion. Error handling remains unchanged.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Model
    participant Database

    Client->>Database: Request data
    Database-->>Client: Send data as String (hexadecimal)
    Client->>Model: Call map_row_to_ty
    Model->>Model: Convert String to i64 (old method)
    Model->>Client: Return i64 value

    Client->>Database: Request data
    Database-->>Client: Send data as i64
    Client->>Model: Call map_row_to_ty
    Model->>Client: Return i64 value (new method)
Loading

🪧 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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
crates/torii/core/src/model.rs (1)

509-510: LGTM! Efficient i64 deserialization.

Ohayo, sensei! The direct i64 retrieval is more efficient than the previous string manipulation approach. This change aligns well with how we handle other primitive integer types like i8, i16, and i32.

Consider applying similar optimizations to other integer types like u64, u128, and i128 that are still using string manipulation and hex conversion. For example:

 Primitive::U64(_) => {
-    let value = row.try_get::<String, &str>(&column_name)?;
-    let hex_str = value.trim_start_matches("0x");
-    primitive.set_u64(Some(
-        u64::from_str_radix(hex_str, 16).map_err(ParseError::ParseIntError)?,
-    ))?;
+    let value = row.try_get::<u64, &str>(&column_name)?;
+    primitive.set_u64(Some(value))?;
 }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 447ba4f and e63a54a.

📒 Files selected for processing (1)
  • crates/torii/core/src/model.rs (1 hunks)

Copy link

codecov bot commented Nov 5, 2024

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 56.78%. Comparing base (447ba4f) to head (e63a54a).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
crates/torii/core/src/model.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2636      +/-   ##
==========================================
- Coverage   56.79%   56.78%   -0.02%     
==========================================
  Files         397      397              
  Lines       49560    49557       -3     
==========================================
- Hits        28148    28141       -7     
- Misses      21412    21416       +4     

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

@Larkooo Larkooo merged commit f3276c3 into dojoengine:main Nov 5, 2024
12 of 14 checks passed
@Larkooo Larkooo deleted the fix-i64-sql branch November 5, 2024 19:25
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.

2 participants