-
-
Notifications
You must be signed in to change notification settings - Fork 492
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
Check to make sure migration name is valid #879
Conversation
Hi @AngelOnFira welcome back! |
// Make sure the migration name doesn't contain any characters that | ||
// are invalid module names in Rust. | ||
if migration_name.contains('-') { | ||
return Err(Box::new(MigrationCommandError::InvalidName( | ||
"Invalid character used in migration name".to_string(), | ||
))); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @AngelOnFira, sorry for the delay. I think the error message can be more specific? E.g. hyphen -
cannot be used in migration name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Such as...
// Make sure the migration name doesn't contain any characters that | |
// are invalid module names in Rust. | |
if migration_name.contains('-') { | |
return Err(Box::new(MigrationCommandError::InvalidName( | |
"Invalid character used in migration name".to_string(), | |
))); | |
} | |
// Make sure the migration name doesn't contain any characters that | |
// are invalid module names in Rust. | |
if migration_name.contains('-') { | |
return Err(Box::new(MigrationCommandError::InvalidName( | |
"Hyphen `-` cannot be used in migration name".to_string(), | |
))); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more nitpick, could we have a test case for this new behaviour? I want this behaviour to be checked and persisted in years to come :)
Thank you so much for the great contributions!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @AngelOnFira, I'll continue the work on #1155 :)
I created a migration named
initial-tables
, however, I had to change it since it wasn't valid as a Rust module name.I'm sure there are some other characters that should be filtered out, but I didn't look too deep. Also, I created a custom error for this, but I'm not super sure if that's the cleanest place to put it. I can make any changes necessary :)