Fix invalid unique handle check for page layouts
This commit is contained in:
committed by
Jože Fortun
parent
614f9c7cde
commit
c82592f6de
@@ -184,6 +184,12 @@ pageLayout: {
|
||||
description: """
|
||||
searches for page layour by handle (case-insensitive)
|
||||
"""
|
||||
}, {
|
||||
fields: ["namespace_id", "page_id", "handle"]
|
||||
nullConstraint: ["deleted_at"]
|
||||
description: """
|
||||
searches for page layour by handle (case-insensitive)
|
||||
"""
|
||||
}, {
|
||||
fields: ["id"]
|
||||
description: """
|
||||
|
||||
@@ -418,7 +418,7 @@ func (svc pageLayout) lookup(ctx context.Context, namespaceID uint64, lookup fun
|
||||
|
||||
func (svc pageLayout) uniqueCheck(ctx context.Context, p *types.PageLayout) (err error) {
|
||||
if p.Handle != "" {
|
||||
if e, _ := store.LookupComposePageLayoutByNamespaceIDHandle(ctx, svc.store, p.NamespaceID, p.Handle); e != nil && e.ID != p.ID {
|
||||
if e, _ := store.LookupComposePageLayoutByNamespaceIDPageIDHandle(ctx, svc.store, p.NamespaceID, p.PageID, p.Handle); e != nil && e.ID != p.ID {
|
||||
return PageLayoutErrHandleNotUnique()
|
||||
}
|
||||
}
|
||||
|
||||
Generated
+43
@@ -10172,6 +10172,49 @@ func (s *Store) LookupComposePageLayoutByNamespaceIDHandle(ctx context.Context,
|
||||
return aux.decode()
|
||||
}
|
||||
|
||||
// LookupComposePageLayoutByNamespaceIDPageIDHandle searches for page layour by handle (case-insensitive)
|
||||
//
|
||||
// This function is auto-generated
|
||||
func (s *Store) LookupComposePageLayoutByNamespaceIDPageIDHandle(ctx context.Context, namespaceID uint64, pageID uint64, handle string) (_ *composeType.PageLayout, err error) {
|
||||
var (
|
||||
rows *sql.Rows
|
||||
aux = new(auxComposePageLayout)
|
||||
lookup = composePageLayoutSelectQuery(s.Dialect.GOQU()).Where(
|
||||
goqu.I("rel_namespace").Eq(namespaceID),
|
||||
goqu.I("page_id").Eq(pageID),
|
||||
s.Functions.LOWER(goqu.I("handle")).Eq(strings.ToLower(handle)),
|
||||
stateNilComparison(s.Dialect, "deleted_at", filter.StateExcluded),
|
||||
).Limit(1)
|
||||
)
|
||||
|
||||
rows, err = s.Query(ctx, lookup)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
defer func() {
|
||||
closeError := rows.Close()
|
||||
if err == nil {
|
||||
// return error from close
|
||||
err = closeError
|
||||
}
|
||||
}()
|
||||
|
||||
if err = rows.Err(); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if !rows.Next() {
|
||||
return nil, store.ErrNotFound.Stack(1)
|
||||
}
|
||||
|
||||
if err = aux.scan(rows); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
return aux.decode()
|
||||
}
|
||||
|
||||
// LookupComposePageLayoutByID searches for compose page layour by ID
|
||||
//
|
||||
// It returns compose page layour even if deleted
|
||||
|
||||
Generated
+8
@@ -339,6 +339,7 @@ type (
|
||||
DeleteComposePageLayoutByID(ctx context.Context, id uint64) error
|
||||
TruncateComposePageLayouts(ctx context.Context) error
|
||||
LookupComposePageLayoutByNamespaceIDHandle(ctx context.Context, namespaceID uint64, handle string) (*composeType.PageLayout, error)
|
||||
LookupComposePageLayoutByNamespaceIDPageIDHandle(ctx context.Context, namespaceID uint64, pageID uint64, handle string) (*composeType.PageLayout, error)
|
||||
LookupComposePageLayoutByID(ctx context.Context, id uint64) (*composeType.PageLayout, error)
|
||||
ReorderComposePageLayouts(ctx context.Context, namespace_id uint64, page_id uint64, page_layout_ids []uint64) error
|
||||
}
|
||||
@@ -1904,6 +1905,13 @@ func LookupComposePageLayoutByNamespaceIDHandle(ctx context.Context, s ComposePa
|
||||
return s.LookupComposePageLayoutByNamespaceIDHandle(ctx, namespaceID, handle)
|
||||
}
|
||||
|
||||
// LookupComposePageLayoutByNamespaceIDPageIDHandle searches for page layour by handle (case-insensitive)
|
||||
//
|
||||
// This function is auto-generated
|
||||
func LookupComposePageLayoutByNamespaceIDPageIDHandle(ctx context.Context, s ComposePageLayouts, namespaceID uint64, pageID uint64, handle string) (*composeType.PageLayout, error) {
|
||||
return s.LookupComposePageLayoutByNamespaceIDPageIDHandle(ctx, namespaceID, pageID, handle)
|
||||
}
|
||||
|
||||
// LookupComposePageLayoutByID searches for compose page layour by ID
|
||||
//
|
||||
// It returns compose page layour even if deleted
|
||||
|
||||
Reference in New Issue
Block a user