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(dojo-lang): ensure a model has at least one attribute that is not a key #1323

Merged
merged 1 commit into from
Dec 20, 2023

Conversation

glihm
Copy link
Collaborator

@glihm glihm commented Dec 20, 2023

Currently, a model that has only keys produces the following error:

error: Unexpected return type. Expected: "core::integer::u32", found: "()".
 --> /mnt/data/dojo-starter/src/models.cairo[Multi]:39:24
    fn size() -> usize {
                       ^

error: Compilation failed.

This PR aims at panicking explaining to the user what's happening.
From my understanding, it is not useful to have a model without any field in the database.

@glihm glihm requested a review from tarrencev December 20, 2023 20:12
@codecov-commenter
Copy link

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (792194c) 60.43% compared to head (158931c) 60.42%.
Report is 1 commits behind head on main.

Files Patch % Lines
crates/dojo-lang/src/introspect.rs 37.50% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1323      +/-   ##
==========================================
- Coverage   60.43%   60.42%   -0.01%     
==========================================
  Files         226      226              
  Lines       18777    18785       +8     
==========================================
+ Hits        11347    11350       +3     
- Misses       7430     7435       +5     

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

@glihm glihm requested review from kariy and removed request for kariy December 20, 2023 20:45
@tarrencev tarrencev merged commit e351f0f into dojoengine:main Dec 20, 2023
9 checks passed
Copy link
Member

@kariy kariy left a comment

Choose a reason for hiding this comment

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

Wouldnt this just panic the compilation process entirely? I'm not very familiar on this but wouldnt it better to have it as compiler diagnostics?

@tarrencev
Copy link
Contributor

Wouldnt this just panic the compilation process entirely? I'm not very familiar on this but wouldnt it better to have it as compiler diagnostics?

Ah yeah you're right. This should be a compiler diagnostic. My bad

@glihm glihm deleted the fix/model-only-keys branch February 17, 2024 20:51
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.

4 participants