generated from oracle/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
When creating more than 1 record, with a model that contains a read-only field and a JSON field with a value that exceeds 4000 characters an error is returned indicating the read-only field needs to be declared.
The best way to reproduce this is using this test:
func TestCreateReadOnlyJson(t *testing.T) {
type record struct {
ID string `gorm:"column:child_id;primaryKey;type:varchar(36)"`
ReadOnlyField string `gorm:"->;-:migration;column:read_only_field;type:varchar(100)"`
JsonTypeField datatypes.JSON `gorm:"column:json_type_field;type:json"`
}
json := datatypes.JSON(fmt.Sprintf(`{"key":"%s"}`, strings.Repeat("x", 4000)))
records := []record{
{
ID: "1",
JsonTypeField: json,
},
{
ID: "2",
},
}
DB.Migrator().DropTable(&record{})
err := DB.AutoMigrate(&record{})
if err != nil {
t.Fatalf("errors happened with migrate: %v", err)
}
err = DB.Model(&records).Create(&records).Error
if err != nil {
t.Fatalf("errors happened when create: %v", err)
}
// verify records are created
var results []record
err = DB.Find(&results).Error
if err != nil {
t.Fatalf("errors happened when querying after create: %v", err)
}
if len(results) != 2 {
t.Fatalf("expected 1 parent, got %d", len(results))
}
}
After executing this test the following error is returned:
PLS-00302: component 'read_only_field' must be declared
Can you help us out on how we can solve this?
Metadata
Metadata
Assignees
Labels
No labels