fix: readers and linting issues
Some checks failed
CI / Test (1.24) (push) Failing after -24m50s
CI / Test (1.25) (push) Failing after -24m42s
CI / Build (push) Successful in -25m49s
CI / Lint (push) Successful in -25m36s

This commit is contained in:
2025-12-19 22:28:24 +02:00
parent d9225a7310
commit aad5db5175
16 changed files with 1237 additions and 80 deletions

View File

@@ -693,7 +693,7 @@ func (r *Reader) deriveTableName(structName string) string {
// parseColumn parses a struct field into a Column model
// Returns the column and any inline reference information (e.g., "mainaccount(id_mainaccount)")
func (r *Reader) parseColumn(fieldName string, fieldType ast.Expr, tag string, sequence uint) (*models.Column, string) {
func (r *Reader) parseColumn(fieldName string, fieldType ast.Expr, tag string, sequence uint) (col *models.Column, ref string) {
// Extract gorm tag
gormTag := r.extractGormTag(tag)
if gormTag == "" {
@@ -756,20 +756,14 @@ func (r *Reader) parseColumn(fieldName string, fieldType ast.Expr, tag string, s
// - explicit "not null" tag means NOT NULL
// - absence of "not null" tag with sql_types means nullable
// - primitive types (string, int64, bool) default to NOT NULL unless explicitly nullable
// Primary keys are always NOT NULL
column.NotNull = false
if _, hasNotNull := parts["not null"]; hasNotNull {
column.NotNull = true
} else {
// If no explicit "not null" tag, check the Go type
if r.isNullableGoType(fieldType) {
// sql_types.SqlString, etc. are nullable by default
column.NotNull = false
} else {
// Primitive types default to NOT NULL
column.NotNull = false // Default to nullable unless explicitly set
}
// sql_types.SqlString, etc. are nullable by default
column.NotNull = !r.isNullableGoType(fieldType)
}
// Primary keys are always NOT NULL
if column.IsPrimaryKey {
column.NotNull = true
}