Skip to content

Simplify NewVersion::save() fn #11290

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

Merged
merged 4 commits into from
Jun 4, 2025
Merged

Simplify NewVersion::save() fn #11290

merged 4 commits into from
Jun 4, 2025

Conversation

Turbo87
Copy link
Member

@Turbo87 Turbo87 commented Jun 4, 2025

There is no need for this function to use a transaction since the only place that this is used in production is already using an outer transaction.

It is also questionable whether the INSERT INTO versions_published_by needs to happen in the same function, since there are plenty of other inserts that need to happen when a new version is published, but neither of them are part of this function either.

In the effort of making crates_io_database an easy to reason about data access layer, this PR adjusts the NewVersion::save() fn to only save the new version to the versions table, and moves the versions_published_by insert code outside of the function.

Turbo87 added 4 commits June 4, 2025 10:57
…Version::save()` fn

This prepares for the "Trusted Publishing" implementation, where there is no associated user account for a release and thus no email address either. Moving the call outside of the transaction is fine since the only production code call is already happening in an outer transaction.
Now that we only perform a single database query in this function we don't need this transaction anymore. The only caller in production code is already using an outer transaction anyway.
…ublished_by::insert()` call

We don't need this in the database for the test cases in this module.
@Turbo87 Turbo87 added C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear A-backend ⚙️ labels Jun 4, 2025
@Turbo87 Turbo87 merged commit 19759c7 into rust-lang:main Jun 4, 2025
10 checks passed
@Turbo87 Turbo87 deleted the version-save branch June 4, 2025 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-backend ⚙️ C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant