Skip to content

fix: ForeignKey<Self> doesn't compileFix self foreignkey - #313

Merged
m4tx merged 6 commits into
cot-rs:masterfrom
eibrahim95:fix-self-foreignkey
May 13, 2025
Merged

fix: ForeignKey<Self> doesn't compileFix self foreignkey#313
m4tx merged 6 commits into
cot-rs:masterfrom
eibrahim95:fix-self-foreignkey

Conversation

@eibrahim95

Copy link
Copy Markdown
Contributor

In database models, if you used ForeignKey<Self> you'd get an error as described by #298

In this PR, I added a check in the symbol resolver to check for any generic Self and replace it with the struct name.
This also affects migration generation which now references Self with full struct crate name.

@github-actions github-actions Bot added C-macros Crate: cot-macros C-codegen Crate: cot-codegen labels May 2, 2025
@codecov

codecov Bot commented May 2, 2025

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Patch % Lines
cot-codegen/src/symbol_resolver.rs 97.22% 0 Missing and 1 partial ⚠️
Flag Coverage Δ
rust 88.02% <98.14%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
cot-codegen/src/model.rs 92.27% <100.00%> (+0.05%) ⬆️
cot-macros/src/model.rs 92.79% <100.00%> (+0.26%) ⬆️
cot-codegen/src/symbol_resolver.rs 97.37% <97.22%> (+0.18%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@m4tx m4tx left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry for my delay in reviewing this. Looks good; thanks a lot for the contribution!

@m4tx
m4tx enabled auto-merge (squash) May 13, 2025 11:16
@m4tx
m4tx merged commit f5055df into cot-rs:master May 13, 2025
@eibrahim95
eibrahim95 deleted the fix-self-foreignkey branch May 14, 2025 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-codegen Crate: cot-codegen C-macros Crate: cot-macros

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants