Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix migration for files with no number befor _#2906

Closed
indlin wants to merge 1 commit into
transact-rs:main from
indlin:main
Closed

Fix migration for files with no number befor _ #2906
indlin wants to merge 1 commit into
transact-rs:main from
indlin:main

Conversation

@indlin

@indlin indlin commented Nov 27, 2023

Copy link
Copy Markdown

Hello,
As a noob, I lost a few hours of my life with this cryptic error message

#[cfg(test)]
mod tests {
 use sqlx::SqlitePool;
 use super::*;
 
 #[sqlx::test]
 async fn auth_test(pool: SqlitePool) -> sqlx::Result<()> {
 ...
 }
}

error: macros that expand to items must be delimited with braces or followed by a semicolon
 --> src/app_tokens.rs:128:5
 |
128 | #[sqlx::test]
 | ^^^^^^^^^^^^^
 |
 = note: this error originates in the attribute macro `sqlx::test` (in Nightly builds, run with -Z macro-backtrace for more info)
error: invalid digit found in string
 --> src/app_tokens.rs:128:5
 |
128 | #[sqlx::test]
 | ^^^^^^^^^^^^^
 |
 = note: this error originates in the attribute macro `sqlx::test` (in Nightly builds, run with -Z macro-backtrace for more info)

This error was result of wrong naming in my migration file. I copied file app_user.sql into the migrations dir.
After some digging, I make this small pr.

Thanks.

@abonander abonander left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Sorry for taking so long to get to this.

However, I think silently ignoring the file is going to be just as annoying if not more so. Imagine how confused you might have been then!

It would be better if this returned an error mentioning the name of the file and explaining why it's invalid.

indlin commented Jan 22, 2024

Copy link
Copy Markdown
Author

This will break the current contract - run migration only for files with number_ prefix:

 if parts.len() != 2 || !parts[1].ends_with(".sql") {
 // not of the format: <VERSION>_<DESCRIPTION>.sql; ignore
 continue;
 }

And may be some one use the other files in migration dir...

About being confused, not at all. I checked this myself :) My tests just failed with a helpful message - the relation "tbl_name" does not exist, and I understand that something is wrong with the migration.

Copy link
Copy Markdown
Collaborator

@indlin if it's already emitting an error for these files, changing the error message doesn't break the contract.

Copy link
Copy Markdown
Collaborator

Superceded by #3089

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@abonander abonander abonander requested changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /