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(schema): empty array name #2339

Merged
merged 1 commit into from
Aug 25, 2024
Merged

Conversation

Larkooo
Copy link
Collaborator

@Larkooo Larkooo commented Aug 23, 2024

Summary by CodeRabbit

  • New Features
    • Improved handling of array types for better clarity in type representation: empty arrays are now displayed as "Array," while non-empty arrays show the type of the first element.

These changes enhance the user experience by providing more meaningful and accurate type information.

Copy link

coderabbitai bot commented Aug 23, 2024

Walkthrough

Ohayo, sensei! The changes involve an update to the handling of the Ty::Array variant within the Ty implementation. The modification adds a conditional check for the array's contents, allowing for the correct formatting of output based on whether the array is empty or not.

Changes

File Path Change Summary
crates/dojo-types/src/schema.rs Modified Ty::Array handling to check for empty arrays; returns "Array" for empty arrays, or "Array" for non-empty arrays.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Ty
    User->>Ty: Request Type Representation
    Ty-->>User: Check if Array is Empty
    alt Array is Empty
        Ty-->>User: Return "Array"
    else Array is Non-Empty
        Ty-->>User: Return "Array<Type>"
    end
Loading

Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a3ddf39 and f1169dd.

Files selected for processing (1)
  • crates/dojo-types/src/schema.rs (1 hunks)
Additional comments not posted (1)
crates/dojo-types/src/schema.rs (1)

59-65: Ohayo, sensei! The array handling logic looks solid.

The conditional check for empty arrays in the Ty::Array variant is a smart move. It ensures that empty arrays are represented clearly as "Array", enhancing semantic clarity. Nice work!


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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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 Aug 23, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 67.26%. Comparing base (a3ddf39) to head (f1169dd).
Report is 2 commits behind head on main.

Files Patch % Lines
crates/dojo-types/src/schema.rs 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2339      +/-   ##
==========================================
- Coverage   67.26%   67.26%   -0.01%     
==========================================
  Files         357      357              
  Lines       46634    46637       +3     
==========================================
+ Hits        31367    31369       +2     
- Misses      15267    15268       +1     

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

if let Some(inner) = ty.first() {
format!("Array<{}>", inner.name())
} else {
"Array".to_string()
Copy link
Collaborator

Choose a reason for hiding this comment

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

How can we have an array without inner type?

Copy link
Collaborator Author

@Larkooo Larkooo Aug 24, 2024

Choose a reason for hiding this comment

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

The Ty is also used for values, like for arrays returned from GRPC. So we might have a model with an empty array, which in that case, would panic since we cannot get the inner type due to our array being empty

@glihm glihm merged commit f11b3a6 into dojoengine:main Aug 25, 2024
15 checks passed
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