diff --git a/bin/templates/configs_/nullable.json b/bin/templates/configs_/nullable.json index 1e5062a..3f0a502 100644 --- a/bin/templates/configs_/nullable.json +++ b/bin/templates/configs_/nullable.json @@ -1,4 +1,4 @@ { - "ExtID": true, - "CreatedAt": false + "ext_id": true, + "created_at": false } diff --git a/internal/create_files/create_files.go b/internal/create_files/create_files.go index d235140..77105fc 100644 --- a/internal/create_files/create_files.go +++ b/internal/create_files/create_files.go @@ -390,9 +390,15 @@ func FindCrudFunctionsURL() string { func FindTextDefaultValue(Column1 *types.Column) string { var Otvet string + ColumnName := Column1.Name + + //ищем в файле настроек nullable.json + is_nullable_config, has_is_nullable_config := types.MapNullableFileds[ColumnName] + + // sValue := "" Type_go := Column1.TypeGo - if Column1.TableKey != "" { + if Column1.TableKey != "" && Column1.IsNullable == true && (is_nullable_config == true || has_is_nullable_config == false) { sValue = "null" } else { diff --git a/internal/create_files/db_crud_tables/db_crud_tables.go b/internal/create_files/db_crud_tables/db_crud_tables.go index 95ec0b3..b5830ee 100644 --- a/internal/create_files/db_crud_tables/db_crud_tables.go +++ b/internal/create_files/db_crud_tables/db_crud_tables.go @@ -344,6 +344,7 @@ func AddTextOmit(TextDB string, Table1 *types.Table) string { TextOmit := "" NullableCount := 0 for _, Column1 := range Table1.MapColumns { + ColumnName := Column1.Name ColumnNameGo := Column1.NameGo TypeGo := Column1.TypeGo @@ -352,7 +353,7 @@ func AddTextOmit(TextDB string, Table1 *types.Table) string { } //ищем в файле настроек nullable.json - is_nullable_config, has_is_nullable_config := types.MapNullableFileds[ColumnNameGo] + is_nullable_config, has_is_nullable_config := types.MapNullableFileds[ColumnName] if has_is_nullable_config == true && is_nullable_config == false { continue }