Skip to content

Commit 7bf383a

Browse files
committed
Merge remote-tracking branch 'origin' into dateDatatypeTests
2 parents e9bf64c + bf6e164 commit 7bf383a

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

oracle/common.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ import (
5555
"gorm.io/gorm/schema"
5656
)
5757

58+
// Extra data types for the data type that are not declared in the
59+
// default DataType list
60+
const (
61+
JSON schema.DataType = "json"
62+
Timestamp schema.DataType = "timestamp"
63+
TimestampWithTimeZone schema.DataType = "timestamp with time zone"
64+
)
65+
5866
// Helper function to get Oracle array type for a field
5967
func getOracleArrayType(field *schema.Field, values []any) string {
6068
switch field.DataType {
@@ -64,6 +72,10 @@ func getOracleArrayType(field *schema.Field, values []any) string {
6472
return "TABLE OF NUMBER"
6573
case schema.Float:
6674
return "TABLE OF NUMBER"
75+
case JSON:
76+
// PL/SQL does not yet allow declaring collections of JSON (TABLE OF JSON) directly.
77+
// Workaround for JSON type
78+
fallthrough
6779
case schema.String:
6880
if field.Size > 0 && field.Size <= 4000 {
6981
return fmt.Sprintf("TABLE OF VARCHAR2(%d)", field.Size)
@@ -113,13 +125,6 @@ func findFieldByDBName(schema *schema.Schema, dbName string) *schema.Field {
113125
return nil
114126
}
115127

116-
// Extra data types to determine the destination type for OUT parameters
117-
// when using a serializer
118-
const (
119-
Timestamp schema.DataType = "timestamp"
120-
TimestampWithTimeZone schema.DataType = "timestamp with time zone"
121-
)
122-
123128
// Create typed destination for OUT parameters
124129
func createTypedDestination(f *schema.Field) interface{} {
125130
if f == nil {

0 commit comments

Comments
 (0)