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
Max length for naming #275
base: main
Are you sure you want to change the base?
Conversation
34db282
to
dfd9955
Compare
Co-authored-by: Andrew Farries <andyrb@gmail.com>
Co-authored-by: Andrew Farries <andyrb@gmail.com>
Co-authored-by: Andrew Farries <andyrb@gmail.com>
Signed-off-by: Alexis Rico <sferadev@gmail.com>
Signed-off-by: Alexis Rico <sferadev@gmail.com>
@andrew-farries Updated with main and applied the changes to make CI checks pass |
Signed-off-by: Alexis Rico <sferadev@gmail.com>
} | ||
|
||
func (e InvalidNameLengthError) Error() string { | ||
return fmt.Sprintf("max length of %q is %d", e.Name, e.Max) |
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.
return fmt.Sprintf("max length of %q is %d", e.Name, e.Max) | |
return fmt.Sprintf("length of %q (%d) exceeds maximum length of %d", e.Name, len(e.Name), e.Max) |
func validateName(name string) error { | ||
if len(name) > MaxNameLength { | ||
return InvalidNameLengthError{Name: name, Max: MaxNameLength} | ||
} | ||
return nil | ||
} | ||
|
||
func ValidateName(name string) error { | ||
return validateName(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.
Get rid of validateName
and use the exported ValidateName
everywhere.
|
||
if err := validateName(o.Column); err != nil { | ||
return err | ||
} | ||
|
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.
I don't think it makes sense to check the length of the column name on the operation here as it must already exist in the database. The check can be removed.
if err := validateName(o.Column); err != nil { | ||
return err | ||
} |
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.
I don't think it makes sense to check the length of the column name on the operation here as it must already exist in the database. The check can be removed.
if err := validateName(o.Column); err != nil { | ||
return err | ||
} | ||
|
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.
I don't think it makes sense to check the length of the column name on the operation here as it must already exist in the database. The check can be removed.
if err := validateName(o.Column); err != nil { | ||
return err | ||
} | ||
|
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.
I don't think it makes sense to check the length of the column name on the operation here as it must already exist in the database. The check can be removed.
if err := validateName(o.Column); err != nil { | ||
return err | ||
} |
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.
I don't think it makes sense to check the length of the column name on the operation here as it must already exist in the database. The check can be removed.
if err := validateName(o.Column); err != nil { | ||
return err | ||
} | ||
|
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.
I don't think it makes sense to check the length of the column name on the operation here as it must already exist in the database. The check can be removed.
if err := validateName(o.Column); err != nil { | ||
return err | ||
} |
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.
I don't think it makes sense to check the length of the column name on the operation here as it must already exist in the database. The check can be removed.
if err := migrations.ValidateName(versionSchema); err != nil { | ||
return err | ||
} |
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.
This is too late to check the length of the new version schema - at this point a potentially lengthy migration start operation has already taken place so it's a poor user experience for the migration to fail with a validation check at this stage. I'd remove the check here and if we need it we can add a check earlier in the migration start process as a separate PR.
Bump @0del 👋 This PR is almost ready to go; it just needs some removals. |
TODO list:
fixes: #64