mirror of
https://github.com/pocketbase/pocketbase.git
synced 2025-03-19 06:07:48 +02:00
Merge branch 'master' into develop
This commit is contained in:
commit
aba6279feb
@ -19,6 +19,8 @@
|
||||
|
||||
- Added checks for `nil` hooks in `forms.RecordUpsert` when used with custom `Dao` ([#2277](https://github.com/pocketbase/pocketbase/issues/2277)).
|
||||
|
||||
- Fixed unique detailed field error not returned on record create failure ([#2287](https://github.com/pocketbase/pocketbase/discussions/2287)).
|
||||
|
||||
|
||||
## v0.14.4
|
||||
|
||||
|
@ -1173,6 +1173,20 @@ func TestRecordCrudCreate(t *testing.T) {
|
||||
"OnModelAfterCreate": 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "unique field error check",
|
||||
Method: http.MethodPost,
|
||||
Url: "/api/collections/demo2/records",
|
||||
Body: strings.NewReader(`{
|
||||
"title":"test2"
|
||||
}`),
|
||||
ExpectedStatus: 400,
|
||||
ExpectedContent: []string{
|
||||
`"data":{`,
|
||||
`"title":{`,
|
||||
`"code":"validation_not_unique"`,
|
||||
},
|
||||
},
|
||||
|
||||
// ID checks
|
||||
// -----------------------------------------------------------
|
||||
@ -1747,6 +1761,24 @@ func TestRecordCrudUpdate(t *testing.T) {
|
||||
`"id":{"code":"validation_in_invalid"`,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "unique field error check",
|
||||
Method: http.MethodPatch,
|
||||
Url: "/api/collections/demo2/records/llvuca81nly1qls",
|
||||
Body: strings.NewReader(`{
|
||||
"title":"test2"
|
||||
}`),
|
||||
ExpectedStatus: 400,
|
||||
ExpectedContent: []string{
|
||||
`"data":{`,
|
||||
`"title":{`,
|
||||
`"code":"validation_not_unique"`,
|
||||
},
|
||||
ExpectedEvents: map[string]int{
|
||||
"OnRecordBeforeUpdateRequest": 1,
|
||||
"OnModelBeforeUpdate": 1,
|
||||
},
|
||||
},
|
||||
|
||||
// check whether if @request.data modifer fields are properly resolved
|
||||
// -----------------------------------------------------------
|
||||
|
@ -707,7 +707,7 @@ func (form *RecordUpsert) DrySubmit(callback func(txDao *daos.Dao) error) error
|
||||
defer tx.Rollback()
|
||||
|
||||
if err := txDao.SaveRecord(form.record); err != nil {
|
||||
return err
|
||||
return form.prepareError(err)
|
||||
}
|
||||
|
||||
// restore record isNew state
|
||||
@ -779,11 +779,7 @@ func (form *RecordUpsert) Submit(interceptors ...InterceptorFunc[*models.Record]
|
||||
|
||||
// persist the record model
|
||||
if err := dao.SaveRecord(form.record); err != nil {
|
||||
preparedErr := form.prepareError(err)
|
||||
if _, ok := preparedErr.(validation.Errors); ok {
|
||||
return preparedErr
|
||||
}
|
||||
return fmt.Errorf("failed to save the record: %w", err)
|
||||
return form.prepareError(err)
|
||||
}
|
||||
|
||||
// delete old files (if any)
|
||||
|
Loading…
x
Reference in New Issue
Block a user