mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
fix(lists): handle NULL clientID for non-arr lists on Postgres (#1904)
fix(lists): handle NULL clientID for Postgres
This commit is contained in:
parent
79f8a98e73
commit
7bb3487e5e
1 changed files with 8 additions and 4 deletions
|
@ -68,12 +68,14 @@ func (r *ListRepo) List(ctx context.Context) ([]*domain.List, error) {
|
||||||
|
|
||||||
var url, apiKey, lastRefreshStatus, lastRefreshData sql.Null[string]
|
var url, apiKey, lastRefreshStatus, lastRefreshData sql.Null[string]
|
||||||
var lastRefreshTime sql.Null[time.Time]
|
var lastRefreshTime sql.Null[time.Time]
|
||||||
|
var clientID sql.Null[int]
|
||||||
|
|
||||||
err = rows.Scan(&list.ID, &list.Name, &list.Enabled, &list.Type, &list.ClientID, &url, pq.Array(&list.Headers), &list.APIKey, &list.MatchRelease, pq.Array(&list.TagsInclude), pq.Array(&list.TagsExclude), &list.IncludeUnmonitored, &list.IncludeAlternateTitles, &lastRefreshTime, &lastRefreshStatus, &lastRefreshData, &list.CreatedAt, &list.UpdatedAt)
|
err = rows.Scan(&list.ID, &list.Name, &list.Enabled, &list.Type, &clientID, &url, pq.Array(&list.Headers), &list.APIKey, &list.MatchRelease, pq.Array(&list.TagsInclude), pq.Array(&list.TagsExclude), &list.IncludeUnmonitored, &list.IncludeAlternateTitles, &lastRefreshTime, &lastRefreshStatus, &lastRefreshData, &list.CreatedAt, &list.UpdatedAt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list.ClientID = clientID.V
|
||||||
list.URL = url.V
|
list.URL = url.V
|
||||||
list.APIKey = apiKey.V
|
list.APIKey = apiKey.V
|
||||||
list.LastRefreshTime = lastRefreshTime.V
|
list.LastRefreshTime = lastRefreshTime.V
|
||||||
|
@ -128,12 +130,14 @@ func (r *ListRepo) FindByID(ctx context.Context, listID int64) (*domain.List, er
|
||||||
var list domain.List
|
var list domain.List
|
||||||
|
|
||||||
var url, apiKey sql.Null[string]
|
var url, apiKey sql.Null[string]
|
||||||
|
var clientID sql.Null[int]
|
||||||
|
|
||||||
err = row.Scan(&list.ID, &list.Name, &list.Enabled, &list.Type, &list.ClientID, &url, pq.Array(&list.Headers), &list.APIKey, &list.MatchRelease, pq.Array(&list.TagsInclude), pq.Array(&list.TagsExclude), &list.IncludeUnmonitored, &list.IncludeAlternateTitles, &list.LastRefreshTime, &list.LastRefreshStatus, &list.LastRefreshData, &list.CreatedAt, &list.UpdatedAt)
|
err = row.Scan(&list.ID, &list.Name, &list.Enabled, &list.Type, &clientID, &url, pq.Array(&list.Headers), &list.APIKey, &list.MatchRelease, pq.Array(&list.TagsInclude), pq.Array(&list.TagsExclude), &list.IncludeUnmonitored, &list.IncludeAlternateTitles, &list.LastRefreshTime, &list.LastRefreshStatus, &list.LastRefreshData, &list.CreatedAt, &list.UpdatedAt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list.ClientID = clientID.V
|
||||||
list.URL = url.V
|
list.URL = url.V
|
||||||
list.APIKey = apiKey.V
|
list.APIKey = apiKey.V
|
||||||
|
|
||||||
|
@ -167,7 +171,7 @@ func (r *ListRepo) Store(ctx context.Context, list *domain.List) error {
|
||||||
list.Name,
|
list.Name,
|
||||||
list.Enabled,
|
list.Enabled,
|
||||||
list.Type,
|
list.Type,
|
||||||
list.ClientID,
|
toNullInt32(int32(list.ClientID)),
|
||||||
list.URL,
|
list.URL,
|
||||||
pq.Array(list.Headers),
|
pq.Array(list.Headers),
|
||||||
list.APIKey,
|
list.APIKey,
|
||||||
|
@ -210,7 +214,7 @@ func (r *ListRepo) Update(ctx context.Context, list *domain.List) error {
|
||||||
Set("name", list.Name).
|
Set("name", list.Name).
|
||||||
Set("enabled", list.Enabled).
|
Set("enabled", list.Enabled).
|
||||||
Set("type", list.Type).
|
Set("type", list.Type).
|
||||||
Set("client_id", list.ClientID).
|
Set("client_id", toNullInt32(int32(list.ClientID))).
|
||||||
Set("url", list.URL).
|
Set("url", list.URL).
|
||||||
Set("headers", pq.Array(list.Headers)).
|
Set("headers", pq.Array(list.Headers)).
|
||||||
Set("api_key", list.APIKey).
|
Set("api_key", list.APIKey).
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue