feat: foreignKeys check

+fix: "unnamed" field bug
This commit is contained in:
2024-12-30 23:44:24 +07:00
parent ece3f3c801
commit 03ccaff375
10 changed files with 123 additions and 21 deletions

View File

@@ -43,7 +43,7 @@ func isGormValueNullable(tags *structtag.Tags) (*bool, error) {
}
}
func CheckFieldNullConsistency(field ast.Field, structName string, structTags string) error {
func CheckFieldNullConsistency(field ast.Field, fieldName string, structName string, structTags string) error {
tags, err := structtag.Parse(structTags)
if err != nil {
return errors.New(fmt.Sprintf("Invalid structure tag: %s", err))
@@ -64,7 +64,7 @@ func CheckFieldNullConsistency(field ast.Field, structName string, structTags st
}
if isFieldNullable != *isColumnNullable {
return errors.New(fmt.Sprintf("Null safety error in \"%s\" model, field \"%s\": column nullable policy doesn't match to tag nullable policy", structName, field.Names[0].Name))
return errors.New(fmt.Sprintf("Null safety error in \"%s\" model, field \"%s\": column nullable policy doesn't match to tag nullable policy", structName, fieldName))
}
return nil
}