Closed dstpierre closed 1 year ago
To add more context. I think we should detect the error on the database provider side and return the empty slice only for this error, not all error.
For instance, code taken from database/postgresql/base.go
line:120:
if err = pg.DB.QueryRow(qry, auth.AccountID, auth.UserID).Scan(&result.Total); err != nil {
return
}
We'd need to check for the specific error regarding table / relation does not exists and only in that case return the empty slice without error.
Same for mongo
and memory
database package.
@dstpierre may I handle this issue?
Describe the bug The creation of tables occur on the first insertion (call to
CreateDocument
function.For this reason, code that tries to get records from a table that did not had a created document will return an error.
To Reproduce
$ backend server
ListDocument
requestError returned:
Expected behavior
Might be better to return an empty slice instead of an error. The "standard" web CRUD flow is to create the "listing" page before users go to create entity.
Output of staticbackend -v
StaticBackend version v1.4.0-rc2-13-gb392f7a | 2022-08-23.05:33:15 (b392f7a)
Additional context
This should be the same behavior for all 3 database package:
postgresql
,mongo
, andmemory
.