Skip to content

Commit 69e7447

Browse files
committed
Revert "If a primitive column is nullable, handle correctly"
This reverts commit 87b89ef.
1 parent ffff8f1 commit 69e7447

File tree

3 files changed

+13
-38
lines changed

3 files changed

+13
-38
lines changed

examples/src/main/resources/ondeck/postgresql/query/checking_account.sql

Whitespace-only changes.

examples/src/main/resources/ondeck/postgresql/schema/0004_checking_account.sql

Whitespace-only changes.

internal/core/gen.go

Lines changed: 13 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,7 @@ func jdbcSet(t ktType, idx int, name string) string {
104104
if t.IsUUID() {
105105
return fmt.Sprintf("stmt.setObject(%d, %s)", idx, name)
106106
}
107-
if t.IsNull && t.PrimitiveType != "" {
108-
return fmt.Sprintf("if (%[3]s != null) stmt.set%[1]s(%[2]d, %[3]s) else stmt.setNull(%[2]d, Types.%[4]s)", t.Name, idx, name, t.PrimitiveType)
109-
} else {
110-
return fmt.Sprintf("stmt.set%s(%d, %s)", t.Name, idx, name)
111-
}
107+
return fmt.Sprintf("stmt.set%s(%d, %s)", t.Name, idx, name)
112108
}
113109

114110
type Params struct {
@@ -336,13 +332,12 @@ func BuildDataClasses(conf Config, req *plugin.GenerateRequest) []Struct {
336332
}
337333

338334
type ktType struct {
339-
Name string
340-
IsEnum bool
341-
IsArray bool
342-
IsNull bool
343-
PrimitiveType string
344-
DataType string
345-
Engine string
335+
Name string
336+
IsEnum bool
337+
IsArray bool
338+
IsNull bool
339+
DataType string
340+
Engine string
346341
}
347342

348343
func (t ktType) String() string {
@@ -391,13 +386,12 @@ func (t ktType) IsBigDecimal() bool {
391386
func makeType(req *plugin.GenerateRequest, col *plugin.Column) ktType {
392387
typ, isEnum := ktInnerType(req, col)
393388
return ktType{
394-
Name: typ,
395-
IsEnum: isEnum,
396-
IsArray: col.IsArray,
397-
IsNull: !col.NotNull,
398-
PrimitiveType: ktPrimitiveType(typ),
399-
DataType: sdk.DataType(col.Type),
400-
Engine: req.Settings.Engine,
389+
Name: typ,
390+
IsEnum: isEnum,
391+
IsArray: col.IsArray,
392+
IsNull: !col.NotNull,
393+
DataType: sdk.DataType(col.Type),
394+
Engine: req.Settings.Engine,
401395
}
402396
}
403397

@@ -413,25 +407,6 @@ func ktInnerType(req *plugin.GenerateRequest, col *plugin.Column) (string, bool)
413407
}
414408
}
415409

416-
func ktPrimitiveType(t string) string {
417-
switch t {
418-
case "Int":
419-
return "INTEGER"
420-
case "Double":
421-
return "DOUBLE"
422-
case "Long":
423-
return "BIGINT"
424-
case "Short":
425-
return "SMALLINT"
426-
case "Float":
427-
return "REAL"
428-
case "Boolean":
429-
return "BOOLEAN"
430-
default:
431-
return ""
432-
}
433-
}
434-
435410
type goColumn struct {
436411
id int
437412
*plugin.Column

0 commit comments

Comments
 (0)