Refactor value preprocessing out of RDBMS to store
This commit is contained in:
@@ -302,7 +302,7 @@ func (s Store) {{ export "query" $.Types.Plural }} (
|
||||
func (s Store) {{ toggleExport .Export "Lookup" $.Types.Singular "By" .Suffix }}(ctx context.Context{{ template "extraArgsDef" $ }}{{- range .RDBMSColumns }}, {{ cc2underscore .Field }} {{ .Type }}{{- end }}) (*{{ $.Types.GoType }}, error) {
|
||||
return s.execLookup{{ $.Types.Singular }}(ctx{{ template "extraArgsCall" $ }}, squirrel.Eq{
|
||||
{{- range .RDBMSColumns }}
|
||||
s.preprocessColumn({{ printf "%q" .AliasedColumn }}, {{ printf "%q" .LookupFilterPreprocess }}): s.preprocessValue({{ cc2underscore .Field }}, {{ printf "%q" .LookupFilterPreprocess }}),
|
||||
s.preprocessColumn({{ printf "%q" .AliasedColumn }}, {{ printf "%q" .LookupFilterPreprocess }}): store.PreprocessValue({{ cc2underscore .Field }}, {{ printf "%q" .LookupFilterPreprocess }}),
|
||||
{{- end }}
|
||||
|
||||
{{ range $field, $value := .Filter }}
|
||||
@@ -376,8 +376,8 @@ func (s Store) partial{{ export $.Types.Singular "Update" }}(ctx context.Context
|
||||
{{ end }}
|
||||
|
||||
{{ if .Upsert.Enable }}
|
||||
// {{ toggleExport .Delete.Export "Upsert" $.Types.Singular }} updates one or more existing rows in {{ $.RDBMS.Table }}
|
||||
func (s Store) {{ toggleExport .Delete.Export "Upsert" $.Types.Singular }}(ctx context.Context{{ template "extraArgsDef" . }}, rr ... *{{ $.Types.GoType }}) (err error) {
|
||||
// {{ toggleExport .Upsert.Export "Upsert" $.Types.Singular }} updates one or more existing rows in {{ $.RDBMS.Table }}
|
||||
func (s Store) {{ toggleExport .Upsert.Export "Upsert" $.Types.Singular }}(ctx context.Context{{ template "extraArgsDef" . }}, rr ... *{{ $.Types.GoType }}) (err error) {
|
||||
for _, res := range rr {
|
||||
err = s.check{{ export $.Types.Singular }}Constraints(ctx {{ template "extraArgsCall" $ }}, res)
|
||||
if err != nil {
|
||||
@@ -706,7 +706,7 @@ func (s *Store) {{ unexport $.Types.Singular }}Hook(ctx context.Context, key tri
|
||||
{{- define "filterByPrimaryKeys" -}}
|
||||
squirrel.Eq{
|
||||
{{ range . -}}
|
||||
s.preprocessColumn({{ printf "%q" .AliasedColumn }}, {{ printf "%q" .LookupFilterPreprocess }}): s.preprocessValue(res.{{ .Field }}, {{ printf "%q" .LookupFilterPreprocess }}),
|
||||
s.preprocessColumn({{ printf "%q" .AliasedColumn }}, {{ printf "%q" .LookupFilterPreprocess }}): store.PreprocessValue(res.{{ .Field }}, {{ printf "%q" .LookupFilterPreprocess }}),
|
||||
{{- end }}
|
||||
}
|
||||
{{- end -}}
|
||||
@@ -714,7 +714,7 @@ func (s *Store) {{ unexport $.Types.Singular }}Hook(ctx context.Context, key tri
|
||||
{{- define "filterByPrimaryKeysWithArgs" -}}
|
||||
squirrel.Eq{
|
||||
{{ range . -}}
|
||||
s.preprocessColumn({{ printf "%q" .AliasedColumn }}, {{ printf "%q" .LookupFilterPreprocess }}): s.preprocessValue({{ .Arg }}, {{ printf "%q" .LookupFilterPreprocess }}),
|
||||
s.preprocessColumn({{ printf "%q" .AliasedColumn }}, {{ printf "%q" .LookupFilterPreprocess }}): store.PreprocessValue({{ .Arg }}, {{ printf "%q" .LookupFilterPreprocess }}),
|
||||
{{ end }}
|
||||
}
|
||||
{{- end -}}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// PreprocessValue value preprocessor logic to modify input value before using it in condition filters and other logic
|
||||
//
|
||||
// We intentionally panic in case of an error here; misuse can only happen with in case of misconfiguration.
|
||||
func PreprocessValue(val interface{}, p string) interface{} {
|
||||
switch p {
|
||||
case "":
|
||||
return val
|
||||
case "lower":
|
||||
if str, ok := val.(string); ok {
|
||||
return strings.ToLower(str)
|
||||
}
|
||||
panic(fmt.Sprintf("preprocessor %q not compatible with type %T (value: %v)", p, val, val))
|
||||
|
||||
default:
|
||||
panic(fmt.Sprintf("unknown preprocessor %q used for value %v", p, val))
|
||||
}
|
||||
}
|
||||
@@ -223,7 +223,7 @@ func (s Store) QueryApplications(
|
||||
// It returns application even if deleted
|
||||
func (s Store) LookupApplicationByID(ctx context.Context, id uint64) (*types.Application, error) {
|
||||
return s.execLookupApplication(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("app.id", ""): s.preprocessValue(id, ""),
|
||||
s.preprocessColumn("app.id", ""): store.PreprocessValue(id, ""),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ func (s Store) partialApplicationUpdate(ctx context.Context, onlyColumns []strin
|
||||
err = s.execUpdateApplications(
|
||||
ctx,
|
||||
squirrel.Eq{
|
||||
s.preprocessColumn("app.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("app.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
},
|
||||
s.internalApplicationEncoder(res).Skip("id").Only(onlyColumns...))
|
||||
if err != nil {
|
||||
@@ -293,7 +293,7 @@ func (s Store) DeleteApplication(ctx context.Context, rr ...*types.Application)
|
||||
for _, res := range rr {
|
||||
|
||||
err = s.execDeleteApplications(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("app.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("app.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
})
|
||||
if err != nil {
|
||||
return s.config.ErrorHandler(err)
|
||||
@@ -306,7 +306,7 @@ func (s Store) DeleteApplication(ctx context.Context, rr ...*types.Application)
|
||||
// DeleteApplicationByID Deletes row from the applications table
|
||||
func (s Store) DeleteApplicationByID(ctx context.Context, ID uint64) error {
|
||||
return s.execDeleteApplications(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("app.id", ""): s.preprocessValue(ID, ""),
|
||||
s.preprocessColumn("app.id", ""): store.PreprocessValue(ID, ""),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ func (s Store) QueryAttachments(
|
||||
// It returns attachment even if deleted
|
||||
func (s Store) LookupAttachmentByID(ctx context.Context, id uint64) (*types.Attachment, error) {
|
||||
return s.execLookupAttachment(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("att.id", ""): s.preprocessValue(id, ""),
|
||||
s.preprocessColumn("att.id", ""): store.PreprocessValue(id, ""),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ func (s Store) partialAttachmentUpdate(ctx context.Context, onlyColumns []string
|
||||
err = s.execUpdateAttachments(
|
||||
ctx,
|
||||
squirrel.Eq{
|
||||
s.preprocessColumn("att.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("att.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
},
|
||||
s.internalAttachmentEncoder(res).Skip("id").Only(onlyColumns...))
|
||||
if err != nil {
|
||||
@@ -169,7 +169,7 @@ func (s Store) DeleteAttachment(ctx context.Context, rr ...*types.Attachment) (e
|
||||
for _, res := range rr {
|
||||
|
||||
err = s.execDeleteAttachments(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("att.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("att.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
})
|
||||
if err != nil {
|
||||
return s.config.ErrorHandler(err)
|
||||
@@ -182,7 +182,7 @@ func (s Store) DeleteAttachment(ctx context.Context, rr ...*types.Attachment) (e
|
||||
// DeleteAttachmentByID Deletes row from the attachments table
|
||||
func (s Store) DeleteAttachmentByID(ctx context.Context, ID uint64) error {
|
||||
return s.execDeleteAttachments(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("att.id", ""): s.preprocessValue(ID, ""),
|
||||
s.preprocessColumn("att.id", ""): store.PreprocessValue(ID, ""),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ func (s Store) QueryComposeAttachments(
|
||||
// It returns attachment even if deleted
|
||||
func (s Store) LookupComposeAttachmentByID(ctx context.Context, id uint64) (*types.Attachment, error) {
|
||||
return s.execLookupComposeAttachment(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("att.id", ""): s.preprocessValue(id, ""),
|
||||
s.preprocessColumn("att.id", ""): store.PreprocessValue(id, ""),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ func (s Store) partialComposeAttachmentUpdate(ctx context.Context, onlyColumns [
|
||||
err = s.execUpdateComposeAttachments(
|
||||
ctx,
|
||||
squirrel.Eq{
|
||||
s.preprocessColumn("att.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("att.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
},
|
||||
s.internalComposeAttachmentEncoder(res).Skip("id").Only(onlyColumns...))
|
||||
if err != nil {
|
||||
@@ -169,7 +169,7 @@ func (s Store) DeleteComposeAttachment(ctx context.Context, rr ...*types.Attachm
|
||||
for _, res := range rr {
|
||||
|
||||
err = s.execDeleteComposeAttachments(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("att.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("att.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
})
|
||||
if err != nil {
|
||||
return s.config.ErrorHandler(err)
|
||||
@@ -182,7 +182,7 @@ func (s Store) DeleteComposeAttachment(ctx context.Context, rr ...*types.Attachm
|
||||
// DeleteComposeAttachmentByID Deletes row from the compose_attachment table
|
||||
func (s Store) DeleteComposeAttachmentByID(ctx context.Context, ID uint64) error {
|
||||
return s.execDeleteComposeAttachments(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("att.id", ""): s.preprocessValue(ID, ""),
|
||||
s.preprocessColumn("att.id", ""): store.PreprocessValue(ID, ""),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -223,15 +223,15 @@ func (s Store) QueryComposeCharts(
|
||||
// It returns compose chart even if deleted
|
||||
func (s Store) LookupComposeChartByID(ctx context.Context, id uint64) (*types.Chart, error) {
|
||||
return s.execLookupComposeChart(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("cch.id", ""): s.preprocessValue(id, ""),
|
||||
s.preprocessColumn("cch.id", ""): store.PreprocessValue(id, ""),
|
||||
})
|
||||
}
|
||||
|
||||
// LookupComposeChartByNamespaceIDHandle searches for compose chart by handle (case-insensitive)
|
||||
func (s Store) LookupComposeChartByNamespaceIDHandle(ctx context.Context, namespace_id uint64, handle string) (*types.Chart, error) {
|
||||
return s.execLookupComposeChart(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("cch.rel_namespace", ""): s.preprocessValue(namespace_id, ""),
|
||||
s.preprocessColumn("cch.handle", "lower"): s.preprocessValue(handle, "lower"),
|
||||
s.preprocessColumn("cch.rel_namespace", ""): store.PreprocessValue(namespace_id, ""),
|
||||
s.preprocessColumn("cch.handle", "lower"): store.PreprocessValue(handle, "lower"),
|
||||
|
||||
"cch.deleted_at": nil,
|
||||
})
|
||||
@@ -270,7 +270,7 @@ func (s Store) partialComposeChartUpdate(ctx context.Context, onlyColumns []stri
|
||||
err = s.execUpdateComposeCharts(
|
||||
ctx,
|
||||
squirrel.Eq{
|
||||
s.preprocessColumn("cch.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("cch.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
},
|
||||
s.internalComposeChartEncoder(res).Skip("id").Only(onlyColumns...))
|
||||
if err != nil {
|
||||
@@ -303,7 +303,7 @@ func (s Store) DeleteComposeChart(ctx context.Context, rr ...*types.Chart) (err
|
||||
for _, res := range rr {
|
||||
|
||||
err = s.execDeleteComposeCharts(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("cch.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("cch.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
})
|
||||
if err != nil {
|
||||
return s.config.ErrorHandler(err)
|
||||
@@ -316,7 +316,7 @@ func (s Store) DeleteComposeChart(ctx context.Context, rr ...*types.Chart) (err
|
||||
// DeleteComposeChartByID Deletes row from the compose_chart table
|
||||
func (s Store) DeleteComposeChartByID(ctx context.Context, ID uint64) error {
|
||||
return s.execDeleteComposeCharts(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("cch.id", ""): s.preprocessValue(ID, ""),
|
||||
s.preprocessColumn("cch.id", ""): store.PreprocessValue(ID, ""),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -86,8 +86,8 @@ func (s Store) QueryComposeModuleFields(
|
||||
// LookupComposeModuleFieldByModuleIDName searches for compose module field by name (case-insensitive)
|
||||
func (s Store) LookupComposeModuleFieldByModuleIDName(ctx context.Context, module_id uint64, name string) (*types.ModuleField, error) {
|
||||
return s.execLookupComposeModuleField(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("cmf.rel_module", ""): s.preprocessValue(module_id, ""),
|
||||
s.preprocessColumn("cmf.name", "lower"): s.preprocessValue(name, "lower"),
|
||||
s.preprocessColumn("cmf.rel_module", ""): store.PreprocessValue(module_id, ""),
|
||||
s.preprocessColumn("cmf.name", "lower"): store.PreprocessValue(name, "lower"),
|
||||
|
||||
"cmf.deleted_at": nil,
|
||||
})
|
||||
@@ -126,7 +126,7 @@ func (s Store) partialComposeModuleFieldUpdate(ctx context.Context, onlyColumns
|
||||
err = s.execUpdateComposeModuleFields(
|
||||
ctx,
|
||||
squirrel.Eq{
|
||||
s.preprocessColumn("cmf.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("cmf.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
},
|
||||
s.internalComposeModuleFieldEncoder(res).Skip("id").Only(onlyColumns...))
|
||||
if err != nil {
|
||||
@@ -159,7 +159,7 @@ func (s Store) DeleteComposeModuleField(ctx context.Context, rr ...*types.Module
|
||||
for _, res := range rr {
|
||||
|
||||
err = s.execDeleteComposeModuleFields(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("cmf.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("cmf.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
})
|
||||
if err != nil {
|
||||
return s.config.ErrorHandler(err)
|
||||
@@ -172,7 +172,7 @@ func (s Store) DeleteComposeModuleField(ctx context.Context, rr ...*types.Module
|
||||
// DeleteComposeModuleFieldByID Deletes row from the compose_module_field table
|
||||
func (s Store) DeleteComposeModuleFieldByID(ctx context.Context, ID uint64) error {
|
||||
return s.execDeleteComposeModuleFields(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("cmf.id", ""): s.preprocessValue(ID, ""),
|
||||
s.preprocessColumn("cmf.id", ""): store.PreprocessValue(ID, ""),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -221,8 +221,8 @@ func (s Store) QueryComposeModules(
|
||||
// LookupComposeModuleByNamespaceIDHandle searches for compose module by handle (case-insensitive)
|
||||
func (s Store) LookupComposeModuleByNamespaceIDHandle(ctx context.Context, namespace_id uint64, handle string) (*types.Module, error) {
|
||||
return s.execLookupComposeModule(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("cmd.rel_namespace", ""): s.preprocessValue(namespace_id, ""),
|
||||
s.preprocessColumn("cmd.handle", "lower"): s.preprocessValue(handle, "lower"),
|
||||
s.preprocessColumn("cmd.rel_namespace", ""): store.PreprocessValue(namespace_id, ""),
|
||||
s.preprocessColumn("cmd.handle", "lower"): store.PreprocessValue(handle, "lower"),
|
||||
|
||||
"cmd.deleted_at": nil,
|
||||
})
|
||||
@@ -231,8 +231,8 @@ func (s Store) LookupComposeModuleByNamespaceIDHandle(ctx context.Context, names
|
||||
// LookupComposeModuleByNamespaceIDName searches for compose module by name (case-insensitive)
|
||||
func (s Store) LookupComposeModuleByNamespaceIDName(ctx context.Context, namespace_id uint64, name string) (*types.Module, error) {
|
||||
return s.execLookupComposeModule(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("cmd.rel_namespace", ""): s.preprocessValue(namespace_id, ""),
|
||||
s.preprocessColumn("cmd.name", "lower"): s.preprocessValue(name, "lower"),
|
||||
s.preprocessColumn("cmd.rel_namespace", ""): store.PreprocessValue(namespace_id, ""),
|
||||
s.preprocessColumn("cmd.name", "lower"): store.PreprocessValue(name, "lower"),
|
||||
|
||||
"cmd.deleted_at": nil,
|
||||
})
|
||||
@@ -243,7 +243,7 @@ func (s Store) LookupComposeModuleByNamespaceIDName(ctx context.Context, namespa
|
||||
// It returns compose module even if deleted
|
||||
func (s Store) LookupComposeModuleByID(ctx context.Context, id uint64) (*types.Module, error) {
|
||||
return s.execLookupComposeModule(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("cmd.id", ""): s.preprocessValue(id, ""),
|
||||
s.preprocessColumn("cmd.id", ""): store.PreprocessValue(id, ""),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ func (s Store) partialComposeModuleUpdate(ctx context.Context, onlyColumns []str
|
||||
err = s.execUpdateComposeModules(
|
||||
ctx,
|
||||
squirrel.Eq{
|
||||
s.preprocessColumn("cmd.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("cmd.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
},
|
||||
s.internalComposeModuleEncoder(res).Skip("id").Only(onlyColumns...))
|
||||
if err != nil {
|
||||
@@ -313,7 +313,7 @@ func (s Store) DeleteComposeModule(ctx context.Context, rr ...*types.Module) (er
|
||||
for _, res := range rr {
|
||||
|
||||
err = s.execDeleteComposeModules(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("cmd.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("cmd.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
})
|
||||
if err != nil {
|
||||
return s.config.ErrorHandler(err)
|
||||
@@ -326,7 +326,7 @@ func (s Store) DeleteComposeModule(ctx context.Context, rr ...*types.Module) (er
|
||||
// DeleteComposeModuleByID Deletes row from the compose_module table
|
||||
func (s Store) DeleteComposeModuleByID(ctx context.Context, ID uint64) error {
|
||||
return s.execDeleteComposeModules(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("cmd.id", ""): s.preprocessValue(ID, ""),
|
||||
s.preprocessColumn("cmd.id", ""): store.PreprocessValue(ID, ""),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -221,7 +221,7 @@ func (s Store) QueryComposeNamespaces(
|
||||
// LookupComposeNamespaceBySlug searches for namespace by slug (case-insensitive)
|
||||
func (s Store) LookupComposeNamespaceBySlug(ctx context.Context, slug string) (*types.Namespace, error) {
|
||||
return s.execLookupComposeNamespace(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("cns.slug", "lower"): s.preprocessValue(slug, "lower"),
|
||||
s.preprocessColumn("cns.slug", "lower"): store.PreprocessValue(slug, "lower"),
|
||||
|
||||
"cns.deleted_at": nil,
|
||||
})
|
||||
@@ -232,7 +232,7 @@ func (s Store) LookupComposeNamespaceBySlug(ctx context.Context, slug string) (*
|
||||
// It returns compose namespace even if deleted
|
||||
func (s Store) LookupComposeNamespaceByID(ctx context.Context, id uint64) (*types.Namespace, error) {
|
||||
return s.execLookupComposeNamespace(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("cns.id", ""): s.preprocessValue(id, ""),
|
||||
s.preprocessColumn("cns.id", ""): store.PreprocessValue(id, ""),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ func (s Store) partialComposeNamespaceUpdate(ctx context.Context, onlyColumns []
|
||||
err = s.execUpdateComposeNamespaces(
|
||||
ctx,
|
||||
squirrel.Eq{
|
||||
s.preprocessColumn("cns.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("cns.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
},
|
||||
s.internalComposeNamespaceEncoder(res).Skip("id").Only(onlyColumns...))
|
||||
if err != nil {
|
||||
@@ -302,7 +302,7 @@ func (s Store) DeleteComposeNamespace(ctx context.Context, rr ...*types.Namespac
|
||||
for _, res := range rr {
|
||||
|
||||
err = s.execDeleteComposeNamespaces(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("cns.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("cns.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
})
|
||||
if err != nil {
|
||||
return s.config.ErrorHandler(err)
|
||||
@@ -315,7 +315,7 @@ func (s Store) DeleteComposeNamespace(ctx context.Context, rr ...*types.Namespac
|
||||
// DeleteComposeNamespaceByID Deletes row from the compose_namespace table
|
||||
func (s Store) DeleteComposeNamespaceByID(ctx context.Context, ID uint64) error {
|
||||
return s.execDeleteComposeNamespaces(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("cns.id", ""): s.preprocessValue(ID, ""),
|
||||
s.preprocessColumn("cns.id", ""): store.PreprocessValue(ID, ""),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -221,8 +221,8 @@ func (s Store) QueryComposePages(
|
||||
// LookupComposePageByNamespaceIDHandle searches for page by handle (case-insensitive)
|
||||
func (s Store) LookupComposePageByNamespaceIDHandle(ctx context.Context, namespace_id uint64, handle string) (*types.Page, error) {
|
||||
return s.execLookupComposePage(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("cpg.rel_namespace", ""): s.preprocessValue(namespace_id, ""),
|
||||
s.preprocessColumn("cpg.handle", "lower"): s.preprocessValue(handle, "lower"),
|
||||
s.preprocessColumn("cpg.rel_namespace", ""): store.PreprocessValue(namespace_id, ""),
|
||||
s.preprocessColumn("cpg.handle", "lower"): store.PreprocessValue(handle, "lower"),
|
||||
|
||||
"cpg.deleted_at": nil,
|
||||
})
|
||||
@@ -231,8 +231,8 @@ func (s Store) LookupComposePageByNamespaceIDHandle(ctx context.Context, namespa
|
||||
// LookupComposePageByNamespaceIDModuleID searches for page by moduleID
|
||||
func (s Store) LookupComposePageByNamespaceIDModuleID(ctx context.Context, namespace_id uint64, module_id uint64) (*types.Page, error) {
|
||||
return s.execLookupComposePage(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("cpg.rel_namespace", ""): s.preprocessValue(namespace_id, ""),
|
||||
s.preprocessColumn("cpg.rel_module", ""): s.preprocessValue(module_id, ""),
|
||||
s.preprocessColumn("cpg.rel_namespace", ""): store.PreprocessValue(namespace_id, ""),
|
||||
s.preprocessColumn("cpg.rel_module", ""): store.PreprocessValue(module_id, ""),
|
||||
|
||||
"cpg.deleted_at": nil,
|
||||
})
|
||||
@@ -243,7 +243,7 @@ func (s Store) LookupComposePageByNamespaceIDModuleID(ctx context.Context, names
|
||||
// It returns compose page even if deleted
|
||||
func (s Store) LookupComposePageByID(ctx context.Context, id uint64) (*types.Page, error) {
|
||||
return s.execLookupComposePage(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("cpg.id", ""): s.preprocessValue(id, ""),
|
||||
s.preprocessColumn("cpg.id", ""): store.PreprocessValue(id, ""),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ func (s Store) partialComposePageUpdate(ctx context.Context, onlyColumns []strin
|
||||
err = s.execUpdateComposePages(
|
||||
ctx,
|
||||
squirrel.Eq{
|
||||
s.preprocessColumn("cpg.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("cpg.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
},
|
||||
s.internalComposePageEncoder(res).Skip("id").Only(onlyColumns...))
|
||||
if err != nil {
|
||||
@@ -313,7 +313,7 @@ func (s Store) DeleteComposePage(ctx context.Context, rr ...*types.Page) (err er
|
||||
for _, res := range rr {
|
||||
|
||||
err = s.execDeleteComposePages(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("cpg.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("cpg.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
})
|
||||
if err != nil {
|
||||
return s.config.ErrorHandler(err)
|
||||
@@ -326,7 +326,7 @@ func (s Store) DeleteComposePage(ctx context.Context, rr ...*types.Page) (err er
|
||||
// DeleteComposePageByID Deletes row from the compose_page table
|
||||
func (s Store) DeleteComposePageByID(ctx context.Context, ID uint64) error {
|
||||
return s.execDeleteComposePages(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("cpg.id", ""): s.preprocessValue(ID, ""),
|
||||
s.preprocessColumn("cpg.id", ""): store.PreprocessValue(ID, ""),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ func (s Store) partialComposeRecordValueUpdate(ctx context.Context, _mod *types.
|
||||
err = s.execUpdateComposeRecordValues(
|
||||
ctx,
|
||||
squirrel.Eq{
|
||||
s.preprocessColumn("crv.record_id", ""): s.preprocessValue(res.RecordID, ""), s.preprocessColumn("crv.name", ""): s.preprocessValue(res.Name, ""), s.preprocessColumn("crv.place", ""): s.preprocessValue(res.Place, ""),
|
||||
s.preprocessColumn("crv.record_id", ""): store.PreprocessValue(res.RecordID, ""), s.preprocessColumn("crv.name", ""): store.PreprocessValue(res.Name, ""), s.preprocessColumn("crv.place", ""): store.PreprocessValue(res.Place, ""),
|
||||
},
|
||||
s.internalComposeRecordValueEncoder(res).Skip("record_id", "name", "place").Only(onlyColumns...))
|
||||
if err != nil {
|
||||
@@ -149,7 +149,7 @@ func (s Store) deleteComposeRecordValue(ctx context.Context, _mod *types.Module,
|
||||
for _, res := range rr {
|
||||
|
||||
err = s.execDeleteComposeRecordValues(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("crv.record_id", ""): s.preprocessValue(res.RecordID, ""), s.preprocessColumn("crv.name", ""): s.preprocessValue(res.Name, ""), s.preprocessColumn("crv.place", ""): s.preprocessValue(res.Place, ""),
|
||||
s.preprocessColumn("crv.record_id", ""): store.PreprocessValue(res.RecordID, ""), s.preprocessColumn("crv.name", ""): store.PreprocessValue(res.Name, ""), s.preprocessColumn("crv.place", ""): store.PreprocessValue(res.Place, ""),
|
||||
})
|
||||
if err != nil {
|
||||
return s.config.ErrorHandler(err)
|
||||
@@ -162,9 +162,9 @@ func (s Store) deleteComposeRecordValue(ctx context.Context, _mod *types.Module,
|
||||
// deleteComposeRecordValueByRecordIDNamePlace Deletes row from the compose_record_value table
|
||||
func (s Store) deleteComposeRecordValueByRecordIDNamePlace(ctx context.Context, _mod *types.Module, recordID uint64, name string, place uint) error {
|
||||
return s.execDeleteComposeRecordValues(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("crv.record_id", ""): s.preprocessValue(recordID, ""),
|
||||
s.preprocessColumn("crv.name", ""): s.preprocessValue(name, ""),
|
||||
s.preprocessColumn("crv.place", ""): s.preprocessValue(place, ""),
|
||||
s.preprocessColumn("crv.record_id", ""): store.PreprocessValue(recordID, ""),
|
||||
s.preprocessColumn("crv.name", ""): store.PreprocessValue(name, ""),
|
||||
s.preprocessColumn("crv.place", ""): store.PreprocessValue(place, ""),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -225,7 +225,7 @@ func (s Store) QueryComposeRecords(
|
||||
// It returns compose record even if deleted
|
||||
func (s Store) lookupComposeRecordByID(ctx context.Context, _mod *types.Module, id uint64) (*types.Record, error) {
|
||||
return s.execLookupComposeRecord(ctx, _mod, squirrel.Eq{
|
||||
s.preprocessColumn("crd.id", ""): s.preprocessValue(id, ""),
|
||||
s.preprocessColumn("crd.id", ""): store.PreprocessValue(id, ""),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ func (s Store) partialComposeRecordUpdate(ctx context.Context, _mod *types.Modul
|
||||
err = s.execUpdateComposeRecords(
|
||||
ctx,
|
||||
squirrel.Eq{
|
||||
s.preprocessColumn("crd.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("crd.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
},
|
||||
s.internalComposeRecordEncoder(res).Skip("id").Only(onlyColumns...))
|
||||
if err != nil {
|
||||
@@ -295,7 +295,7 @@ func (s Store) deleteComposeRecord(ctx context.Context, _mod *types.Module, rr .
|
||||
for _, res := range rr {
|
||||
|
||||
err = s.execDeleteComposeRecords(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("crd.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("crd.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
})
|
||||
if err != nil {
|
||||
return s.config.ErrorHandler(err)
|
||||
@@ -308,7 +308,7 @@ func (s Store) deleteComposeRecord(ctx context.Context, _mod *types.Module, rr .
|
||||
// deleteComposeRecordByID Deletes row from the compose_record table
|
||||
func (s Store) deleteComposeRecordByID(ctx context.Context, _mod *types.Module, ID uint64) error {
|
||||
return s.execDeleteComposeRecords(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("crd.id", ""): s.preprocessValue(ID, ""),
|
||||
s.preprocessColumn("crd.id", ""): store.PreprocessValue(ID, ""),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ func (s Store) QueryCredentials(
|
||||
// It returns credentials even if deleted
|
||||
func (s Store) LookupCredentialsByID(ctx context.Context, id uint64) (*types.Credentials, error) {
|
||||
return s.execLookupCredentials(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("crd.id", ""): s.preprocessValue(id, ""),
|
||||
s.preprocessColumn("crd.id", ""): store.PreprocessValue(id, ""),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ func (s Store) partialCredentialsUpdate(ctx context.Context, onlyColumns []strin
|
||||
err = s.execUpdateCredentials(
|
||||
ctx,
|
||||
squirrel.Eq{
|
||||
s.preprocessColumn("crd.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("crd.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
},
|
||||
s.internalCredentialsEncoder(res).Skip("id").Only(onlyColumns...))
|
||||
if err != nil {
|
||||
@@ -158,7 +158,7 @@ func (s Store) DeleteCredentials(ctx context.Context, rr ...*types.Credentials)
|
||||
for _, res := range rr {
|
||||
|
||||
err = s.execDeleteCredentials(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("crd.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("crd.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
})
|
||||
if err != nil {
|
||||
return s.config.ErrorHandler(err)
|
||||
@@ -171,7 +171,7 @@ func (s Store) DeleteCredentials(ctx context.Context, rr ...*types.Credentials)
|
||||
// DeleteCredentialsByID Deletes row from the credentials table
|
||||
func (s Store) DeleteCredentialsByID(ctx context.Context, ID uint64) error {
|
||||
return s.execDeleteCredentials(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("crd.id", ""): s.preprocessValue(ID, ""),
|
||||
s.preprocessColumn("crd.id", ""): store.PreprocessValue(ID, ""),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ func (s Store) QueryMessagingAttachments(
|
||||
// It returns attachment even if deleted
|
||||
func (s Store) LookupMessagingAttachmentByID(ctx context.Context, id uint64) (*types.Attachment, error) {
|
||||
return s.execLookupMessagingAttachment(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("att.id", ""): s.preprocessValue(id, ""),
|
||||
s.preprocessColumn("att.id", ""): store.PreprocessValue(id, ""),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ func (s Store) partialMessagingAttachmentUpdate(ctx context.Context, onlyColumns
|
||||
err = s.execUpdateMessagingAttachments(
|
||||
ctx,
|
||||
squirrel.Eq{
|
||||
s.preprocessColumn("att.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("att.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
},
|
||||
s.internalMessagingAttachmentEncoder(res).Skip("id").Only(onlyColumns...))
|
||||
if err != nil {
|
||||
@@ -169,7 +169,7 @@ func (s Store) DeleteMessagingAttachment(ctx context.Context, rr ...*types.Attac
|
||||
for _, res := range rr {
|
||||
|
||||
err = s.execDeleteMessagingAttachments(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("att.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("att.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
})
|
||||
if err != nil {
|
||||
return s.config.ErrorHandler(err)
|
||||
@@ -182,7 +182,7 @@ func (s Store) DeleteMessagingAttachment(ctx context.Context, rr ...*types.Attac
|
||||
// DeleteMessagingAttachmentByID Deletes row from the messaging_attachment table
|
||||
func (s Store) DeleteMessagingAttachmentByID(ctx context.Context, ID uint64) error {
|
||||
return s.execDeleteMessagingAttachments(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("att.id", ""): s.preprocessValue(ID, ""),
|
||||
s.preprocessColumn("att.id", ""): store.PreprocessValue(ID, ""),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ func (s Store) partialMessagingChannelMemberUpdate(ctx context.Context, onlyColu
|
||||
err = s.execUpdateMessagingChannelMembers(
|
||||
ctx,
|
||||
squirrel.Eq{
|
||||
s.preprocessColumn("mcm.rel_channel", ""): s.preprocessValue(res.ChannelID, ""), s.preprocessColumn("mcm.rel_user", ""): s.preprocessValue(res.UserID, ""),
|
||||
s.preprocessColumn("mcm.rel_channel", ""): store.PreprocessValue(res.ChannelID, ""), s.preprocessColumn("mcm.rel_user", ""): store.PreprocessValue(res.UserID, ""),
|
||||
},
|
||||
s.internalMessagingChannelMemberEncoder(res).Skip("rel_channel", "rel_user").Only(onlyColumns...))
|
||||
if err != nil {
|
||||
@@ -149,7 +149,7 @@ func (s Store) DeleteMessagingChannelMember(ctx context.Context, rr ...*types.Ch
|
||||
for _, res := range rr {
|
||||
|
||||
err = s.execDeleteMessagingChannelMembers(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("mcm.rel_channel", ""): s.preprocessValue(res.ChannelID, ""), s.preprocessColumn("mcm.rel_user", ""): s.preprocessValue(res.UserID, ""),
|
||||
s.preprocessColumn("mcm.rel_channel", ""): store.PreprocessValue(res.ChannelID, ""), s.preprocessColumn("mcm.rel_user", ""): store.PreprocessValue(res.UserID, ""),
|
||||
})
|
||||
if err != nil {
|
||||
return s.config.ErrorHandler(err)
|
||||
@@ -162,8 +162,8 @@ func (s Store) DeleteMessagingChannelMember(ctx context.Context, rr ...*types.Ch
|
||||
// DeleteMessagingChannelMemberByChannelIDUserID Deletes row from the messaging_channel_member table
|
||||
func (s Store) DeleteMessagingChannelMemberByChannelIDUserID(ctx context.Context, channelID uint64, userID uint64) error {
|
||||
return s.execDeleteMessagingChannelMembers(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("mcm.rel_channel", ""): s.preprocessValue(channelID, ""),
|
||||
s.preprocessColumn("mcm.rel_user", ""): s.preprocessValue(userID, ""),
|
||||
s.preprocessColumn("mcm.rel_channel", ""): store.PreprocessValue(channelID, ""),
|
||||
s.preprocessColumn("mcm.rel_user", ""): store.PreprocessValue(userID, ""),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -223,7 +223,7 @@ func (s Store) QueryMessagingChannels(
|
||||
// It returns attachment even if deleted
|
||||
func (s Store) LookupMessagingChannelByID(ctx context.Context, id uint64) (*types.Channel, error) {
|
||||
return s.execLookupMessagingChannel(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("mch.id", ""): s.preprocessValue(id, ""),
|
||||
s.preprocessColumn("mch.id", ""): store.PreprocessValue(id, ""),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ func (s Store) partialMessagingChannelUpdate(ctx context.Context, onlyColumns []
|
||||
err = s.execUpdateMessagingChannels(
|
||||
ctx,
|
||||
squirrel.Eq{
|
||||
s.preprocessColumn("mch.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("mch.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
},
|
||||
s.internalMessagingChannelEncoder(res).Skip("id").Only(onlyColumns...))
|
||||
if err != nil {
|
||||
@@ -293,7 +293,7 @@ func (s Store) DeleteMessagingChannel(ctx context.Context, rr ...*types.Channel)
|
||||
for _, res := range rr {
|
||||
|
||||
err = s.execDeleteMessagingChannels(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("mch.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("mch.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
})
|
||||
if err != nil {
|
||||
return s.config.ErrorHandler(err)
|
||||
@@ -306,7 +306,7 @@ func (s Store) DeleteMessagingChannel(ctx context.Context, rr ...*types.Channel)
|
||||
// DeleteMessagingChannelByID Deletes row from the messaging_channel table
|
||||
func (s Store) DeleteMessagingChannelByID(ctx context.Context, ID uint64) error {
|
||||
return s.execDeleteMessagingChannels(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("mch.id", ""): s.preprocessValue(ID, ""),
|
||||
s.preprocessColumn("mch.id", ""): store.PreprocessValue(ID, ""),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ func (s Store) QueryMessagingFlags(
|
||||
// LookupMessagingFlagByID searches for flags by ID
|
||||
func (s Store) LookupMessagingFlagByID(ctx context.Context, id uint64) (*types.MessageFlag, error) {
|
||||
return s.execLookupMessagingFlag(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("mmf.id", ""): s.preprocessValue(id, ""),
|
||||
s.preprocessColumn("mmf.id", ""): store.PreprocessValue(id, ""),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ func (s Store) partialMessagingFlagUpdate(ctx context.Context, onlyColumns []str
|
||||
err = s.execUpdateMessagingFlags(
|
||||
ctx,
|
||||
squirrel.Eq{
|
||||
s.preprocessColumn("mmf.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("mmf.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
},
|
||||
s.internalMessagingFlagEncoder(res).Skip("id").Only(onlyColumns...))
|
||||
if err != nil {
|
||||
@@ -156,7 +156,7 @@ func (s Store) DeleteMessagingFlag(ctx context.Context, rr ...*types.MessageFlag
|
||||
for _, res := range rr {
|
||||
|
||||
err = s.execDeleteMessagingFlags(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("mmf.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("mmf.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
})
|
||||
if err != nil {
|
||||
return s.config.ErrorHandler(err)
|
||||
@@ -169,7 +169,7 @@ func (s Store) DeleteMessagingFlag(ctx context.Context, rr ...*types.MessageFlag
|
||||
// DeleteMessagingFlagByID Deletes row from the messaging_message_flag table
|
||||
func (s Store) DeleteMessagingFlagByID(ctx context.Context, ID uint64) error {
|
||||
return s.execDeleteMessagingFlags(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("mmf.id", ""): s.preprocessValue(ID, ""),
|
||||
s.preprocessColumn("mmf.id", ""): store.PreprocessValue(ID, ""),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ func (s Store) QueryMessagingMentions(
|
||||
// It returns attachment even if deleted
|
||||
func (s Store) LookupMessagingMentionByID(ctx context.Context, id uint64) (*types.Mention, error) {
|
||||
return s.execLookupMessagingMention(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("msg.id", ""): s.preprocessValue(id, ""),
|
||||
s.preprocessColumn("msg.id", ""): store.PreprocessValue(id, ""),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ func (s Store) partialMessagingMentionUpdate(ctx context.Context, onlyColumns []
|
||||
err = s.execUpdateMessagingMentions(
|
||||
ctx,
|
||||
squirrel.Eq{
|
||||
s.preprocessColumn("msg.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("msg.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
},
|
||||
s.internalMessagingMentionEncoder(res).Skip("id").Only(onlyColumns...))
|
||||
if err != nil {
|
||||
@@ -158,7 +158,7 @@ func (s Store) DeleteMessagingMention(ctx context.Context, rr ...*types.Mention)
|
||||
for _, res := range rr {
|
||||
|
||||
err = s.execDeleteMessagingMentions(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("msg.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("msg.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
})
|
||||
if err != nil {
|
||||
return s.config.ErrorHandler(err)
|
||||
@@ -171,7 +171,7 @@ func (s Store) DeleteMessagingMention(ctx context.Context, rr ...*types.Mention)
|
||||
// DeleteMessagingMentionByID Deletes row from the messaging_mention table
|
||||
func (s Store) DeleteMessagingMentionByID(ctx context.Context, ID uint64) error {
|
||||
return s.execDeleteMessagingMentions(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("msg.id", ""): s.preprocessValue(ID, ""),
|
||||
s.preprocessColumn("msg.id", ""): store.PreprocessValue(ID, ""),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ func (s Store) QueryMessagingMessageAttachments(
|
||||
// LookupMessagingMessageAttachmentByMessageID searches for message attachment by message ID
|
||||
func (s Store) LookupMessagingMessageAttachmentByMessageID(ctx context.Context, message_id uint64) (*types.MessageAttachment, error) {
|
||||
return s.execLookupMessagingMessageAttachment(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("mma.rel_message", ""): s.preprocessValue(message_id, ""),
|
||||
s.preprocessColumn("mma.rel_message", ""): store.PreprocessValue(message_id, ""),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ func (s Store) partialMessagingMessageAttachmentUpdate(ctx context.Context, only
|
||||
err = s.execUpdateMessagingMessageAttachments(
|
||||
ctx,
|
||||
squirrel.Eq{
|
||||
s.preprocessColumn("mma.rel_message", ""): s.preprocessValue(res.MessageID, ""),
|
||||
s.preprocessColumn("mma.rel_message", ""): store.PreprocessValue(res.MessageID, ""),
|
||||
},
|
||||
s.internalMessagingMessageAttachmentEncoder(res).Skip("rel_message").Only(onlyColumns...))
|
||||
if err != nil {
|
||||
@@ -134,7 +134,7 @@ func (s Store) DeleteMessagingMessageAttachment(ctx context.Context, rr ...*type
|
||||
for _, res := range rr {
|
||||
|
||||
err = s.execDeleteMessagingMessageAttachments(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("mma.rel_message", ""): s.preprocessValue(res.MessageID, ""),
|
||||
s.preprocessColumn("mma.rel_message", ""): store.PreprocessValue(res.MessageID, ""),
|
||||
})
|
||||
if err != nil {
|
||||
return s.config.ErrorHandler(err)
|
||||
@@ -147,7 +147,7 @@ func (s Store) DeleteMessagingMessageAttachment(ctx context.Context, rr ...*type
|
||||
// DeleteMessagingMessageAttachmentByMessageID Deletes row from the messaging_message_attachment table
|
||||
func (s Store) DeleteMessagingMessageAttachmentByMessageID(ctx context.Context, messageID uint64) error {
|
||||
return s.execDeleteMessagingMessageAttachments(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("mma.rel_message", ""): s.preprocessValue(messageID, ""),
|
||||
s.preprocessColumn("mma.rel_message", ""): store.PreprocessValue(messageID, ""),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ func (s Store) QueryMessagingMessages(
|
||||
// It returns message even if deleted
|
||||
func (s Store) LookupMessagingMessageByID(ctx context.Context, id uint64) (*types.Message, error) {
|
||||
return s.execLookupMessagingMessage(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("msg.id", ""): s.preprocessValue(id, ""),
|
||||
s.preprocessColumn("msg.id", ""): store.PreprocessValue(id, ""),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ func (s Store) partialMessagingMessageUpdate(ctx context.Context, onlyColumns []
|
||||
err = s.execUpdateMessagingMessages(
|
||||
ctx,
|
||||
squirrel.Eq{
|
||||
s.preprocessColumn("msg.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("msg.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
},
|
||||
s.internalMessagingMessageEncoder(res).Skip("id").Only(onlyColumns...))
|
||||
if err != nil {
|
||||
@@ -158,7 +158,7 @@ func (s Store) DeleteMessagingMessage(ctx context.Context, rr ...*types.Message)
|
||||
for _, res := range rr {
|
||||
|
||||
err = s.execDeleteMessagingMessages(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("msg.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("msg.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
})
|
||||
if err != nil {
|
||||
return s.config.ErrorHandler(err)
|
||||
@@ -171,7 +171,7 @@ func (s Store) DeleteMessagingMessage(ctx context.Context, rr ...*types.Message)
|
||||
// DeleteMessagingMessageByID Deletes row from the messaging_message table
|
||||
func (s Store) DeleteMessagingMessageByID(ctx context.Context, ID uint64) error {
|
||||
return s.execDeleteMessagingMessages(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("msg.id", ""): s.preprocessValue(ID, ""),
|
||||
s.preprocessColumn("msg.id", ""): store.PreprocessValue(ID, ""),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ func (s Store) partialMessagingUnreadUpdate(ctx context.Context, onlyColumns []s
|
||||
err = s.execUpdateMessagingUnreads(
|
||||
ctx,
|
||||
squirrel.Eq{
|
||||
s.preprocessColumn("mur.rel_channel", ""): s.preprocessValue(res.ChannelID, ""), s.preprocessColumn("mur.rel_reply_to", ""): s.preprocessValue(res.ReplyTo, ""), s.preprocessColumn("mur.rel_user", ""): s.preprocessValue(res.UserID, ""),
|
||||
s.preprocessColumn("mur.rel_channel", ""): store.PreprocessValue(res.ChannelID, ""), s.preprocessColumn("mur.rel_reply_to", ""): store.PreprocessValue(res.ReplyTo, ""), s.preprocessColumn("mur.rel_user", ""): store.PreprocessValue(res.UserID, ""),
|
||||
},
|
||||
s.internalMessagingUnreadEncoder(res).Skip("rel_channel", "rel_reply_to", "rel_user").Only(onlyColumns...))
|
||||
if err != nil {
|
||||
@@ -127,7 +127,7 @@ func (s Store) DeleteMessagingUnread(ctx context.Context, rr ...*types.Unread) (
|
||||
for _, res := range rr {
|
||||
|
||||
err = s.execDeleteMessagingUnreads(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("mur.rel_channel", ""): s.preprocessValue(res.ChannelID, ""), s.preprocessColumn("mur.rel_reply_to", ""): s.preprocessValue(res.ReplyTo, ""), s.preprocessColumn("mur.rel_user", ""): s.preprocessValue(res.UserID, ""),
|
||||
s.preprocessColumn("mur.rel_channel", ""): store.PreprocessValue(res.ChannelID, ""), s.preprocessColumn("mur.rel_reply_to", ""): store.PreprocessValue(res.ReplyTo, ""), s.preprocessColumn("mur.rel_user", ""): store.PreprocessValue(res.UserID, ""),
|
||||
})
|
||||
if err != nil {
|
||||
return s.config.ErrorHandler(err)
|
||||
@@ -140,9 +140,9 @@ func (s Store) DeleteMessagingUnread(ctx context.Context, rr ...*types.Unread) (
|
||||
// DeleteMessagingUnreadByChannelIDReplyToUserID Deletes row from the messaging_unread table
|
||||
func (s Store) DeleteMessagingUnreadByChannelIDReplyToUserID(ctx context.Context, channelID uint64, replyTo uint64, userID uint64) error {
|
||||
return s.execDeleteMessagingUnreads(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("mur.rel_channel", ""): s.preprocessValue(channelID, ""),
|
||||
s.preprocessColumn("mur.rel_reply_to", ""): s.preprocessValue(replyTo, ""),
|
||||
s.preprocessColumn("mur.rel_user", ""): s.preprocessValue(userID, ""),
|
||||
s.preprocessColumn("mur.rel_channel", ""): store.PreprocessValue(channelID, ""),
|
||||
s.preprocessColumn("mur.rel_reply_to", ""): store.PreprocessValue(replyTo, ""),
|
||||
s.preprocessColumn("mur.rel_user", ""): store.PreprocessValue(userID, ""),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ func (s Store) partialRbacRuleUpdate(ctx context.Context, onlyColumns []string,
|
||||
err = s.execUpdateRbacRules(
|
||||
ctx,
|
||||
squirrel.Eq{
|
||||
s.preprocessColumn("rls.rel_role", ""): s.preprocessValue(res.RoleID, ""), s.preprocessColumn("rls.resource", ""): s.preprocessValue(res.Resource, ""), s.preprocessColumn("rls.operation", ""): s.preprocessValue(res.Operation, ""),
|
||||
s.preprocessColumn("rls.rel_role", ""): store.PreprocessValue(res.RoleID, ""), s.preprocessColumn("rls.resource", ""): store.PreprocessValue(res.Resource, ""), s.preprocessColumn("rls.operation", ""): store.PreprocessValue(res.Operation, ""),
|
||||
},
|
||||
s.internalRbacRuleEncoder(res).Skip("rel_role", "resource", "operation").Only(onlyColumns...))
|
||||
if err != nil {
|
||||
@@ -146,7 +146,7 @@ func (s Store) DeleteRbacRule(ctx context.Context, rr ...*rbac.Rule) (err error)
|
||||
for _, res := range rr {
|
||||
|
||||
err = s.execDeleteRbacRules(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("rls.rel_role", ""): s.preprocessValue(res.RoleID, ""), s.preprocessColumn("rls.resource", ""): s.preprocessValue(res.Resource, ""), s.preprocessColumn("rls.operation", ""): s.preprocessValue(res.Operation, ""),
|
||||
s.preprocessColumn("rls.rel_role", ""): store.PreprocessValue(res.RoleID, ""), s.preprocessColumn("rls.resource", ""): store.PreprocessValue(res.Resource, ""), s.preprocessColumn("rls.operation", ""): store.PreprocessValue(res.Operation, ""),
|
||||
})
|
||||
if err != nil {
|
||||
return s.config.ErrorHandler(err)
|
||||
@@ -159,9 +159,9 @@ func (s Store) DeleteRbacRule(ctx context.Context, rr ...*rbac.Rule) (err error)
|
||||
// DeleteRbacRuleByRoleIDResourceOperation Deletes row from the rbac_rules table
|
||||
func (s Store) DeleteRbacRuleByRoleIDResourceOperation(ctx context.Context, roleID uint64, resource string, operation string) error {
|
||||
return s.execDeleteRbacRules(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("rls.rel_role", ""): s.preprocessValue(roleID, ""),
|
||||
s.preprocessColumn("rls.resource", ""): s.preprocessValue(resource, ""),
|
||||
s.preprocessColumn("rls.operation", ""): s.preprocessValue(operation, ""),
|
||||
s.preprocessColumn("rls.rel_role", ""): store.PreprocessValue(roleID, ""),
|
||||
s.preprocessColumn("rls.resource", ""): store.PreprocessValue(resource, ""),
|
||||
s.preprocessColumn("rls.operation", ""): store.PreprocessValue(operation, ""),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
+1
-26
@@ -289,7 +289,7 @@ func (s Store) Config() *Config {
|
||||
// No preprocessor ("") is intentionally checked after checking registered list of preprocessors
|
||||
func (s Store) preprocessColumn(col string, p string) string {
|
||||
if fn, has := s.config.ColumnPreprocessors[p]; has {
|
||||
return fn(col, p)
|
||||
return fn(col)
|
||||
}
|
||||
|
||||
switch p {
|
||||
@@ -302,31 +302,6 @@ func (s Store) preprocessColumn(col string, p string) string {
|
||||
}
|
||||
}
|
||||
|
||||
// value preprocessor logic to modify input value before using it in condition filters
|
||||
//
|
||||
// It checks registered ValuePreprocessors from config
|
||||
// and then the standard set
|
||||
//
|
||||
// No preprocessor ("") is intentionally checked after checking registered list of preprocessors
|
||||
func (s Store) preprocessValue(val interface{}, p string) interface{} {
|
||||
if fn, has := s.config.ValuePreprocessors[p]; has {
|
||||
return fn(val, p)
|
||||
}
|
||||
|
||||
switch p {
|
||||
case "":
|
||||
return val
|
||||
case "lower":
|
||||
if str, ok := val.(string); ok {
|
||||
return strings.ToLower(str)
|
||||
}
|
||||
panic(fmt.Sprintf("preprocessor %q not compatible with type %T (value: %v)", p, val, val))
|
||||
|
||||
default:
|
||||
panic(fmt.Sprintf("unknown preprocessor %q used for value %v", p, val))
|
||||
}
|
||||
}
|
||||
|
||||
// SqlFunctionHandler calls configured sql function handler if set
|
||||
// otherwise returns passed arguments directly
|
||||
func (s Store) SqlFunctionHandler(f ql.Function) (ql.ASTNode, error) {
|
||||
|
||||
@@ -24,8 +24,7 @@ import (
|
||||
|
||||
type (
|
||||
txRetryOnErrHandler func(int, error) bool
|
||||
columnPreprocFn func(string, string) string
|
||||
valuePreprocFn func(interface{}, string) interface{}
|
||||
columnPreprocFn func(string) string
|
||||
errorHandler func(error) error
|
||||
triggerKey string
|
||||
|
||||
@@ -85,7 +84,6 @@ type (
|
||||
TxRetryErrHandler txRetryOnErrHandler
|
||||
|
||||
ColumnPreprocessors map[string]columnPreprocFn
|
||||
ValuePreprocessors map[string]valuePreprocFn
|
||||
|
||||
ErrorHandler errorHandler
|
||||
|
||||
|
||||
@@ -223,7 +223,7 @@ func (s Store) QueryReminders(
|
||||
// It returns reminder even if deleted or suspended
|
||||
func (s Store) LookupReminderByID(ctx context.Context, id uint64) (*types.Reminder, error) {
|
||||
return s.execLookupReminder(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("rmd.id", ""): s.preprocessValue(id, ""),
|
||||
s.preprocessColumn("rmd.id", ""): store.PreprocessValue(id, ""),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ func (s Store) partialReminderUpdate(ctx context.Context, onlyColumns []string,
|
||||
err = s.execUpdateReminders(
|
||||
ctx,
|
||||
squirrel.Eq{
|
||||
s.preprocessColumn("rmd.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("rmd.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
},
|
||||
s.internalReminderEncoder(res).Skip("id").Only(onlyColumns...))
|
||||
if err != nil {
|
||||
@@ -293,7 +293,7 @@ func (s Store) DeleteReminder(ctx context.Context, rr ...*types.Reminder) (err e
|
||||
for _, res := range rr {
|
||||
|
||||
err = s.execDeleteReminders(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("rmd.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("rmd.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
})
|
||||
if err != nil {
|
||||
return s.config.ErrorHandler(err)
|
||||
@@ -306,7 +306,7 @@ func (s Store) DeleteReminder(ctx context.Context, rr ...*types.Reminder) (err e
|
||||
// DeleteReminderByID Deletes row from the reminders table
|
||||
func (s Store) DeleteReminderByID(ctx context.Context, ID uint64) error {
|
||||
return s.execDeleteReminders(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("rmd.id", ""): s.preprocessValue(ID, ""),
|
||||
s.preprocessColumn("rmd.id", ""): store.PreprocessValue(ID, ""),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ func (s Store) partialRoleMemberUpdate(ctx context.Context, onlyColumns []string
|
||||
err = s.execUpdateRoleMembers(
|
||||
ctx,
|
||||
squirrel.Eq{
|
||||
s.preprocessColumn("rm.rel_user", ""): s.preprocessValue(res.UserID, ""), s.preprocessColumn("rm.rel_role", ""): s.preprocessValue(res.RoleID, ""),
|
||||
s.preprocessColumn("rm.rel_user", ""): store.PreprocessValue(res.UserID, ""), s.preprocessColumn("rm.rel_role", ""): store.PreprocessValue(res.RoleID, ""),
|
||||
},
|
||||
s.internalRoleMemberEncoder(res).Skip("rel_user", "rel_role").Only(onlyColumns...))
|
||||
if err != nil {
|
||||
@@ -146,7 +146,7 @@ func (s Store) DeleteRoleMember(ctx context.Context, rr ...*types.RoleMember) (e
|
||||
for _, res := range rr {
|
||||
|
||||
err = s.execDeleteRoleMembers(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("rm.rel_user", ""): s.preprocessValue(res.UserID, ""), s.preprocessColumn("rm.rel_role", ""): s.preprocessValue(res.RoleID, ""),
|
||||
s.preprocessColumn("rm.rel_user", ""): store.PreprocessValue(res.UserID, ""), s.preprocessColumn("rm.rel_role", ""): store.PreprocessValue(res.RoleID, ""),
|
||||
})
|
||||
if err != nil {
|
||||
return s.config.ErrorHandler(err)
|
||||
@@ -159,8 +159,8 @@ func (s Store) DeleteRoleMember(ctx context.Context, rr ...*types.RoleMember) (e
|
||||
// DeleteRoleMemberByUserIDRoleID Deletes row from the role_members table
|
||||
func (s Store) DeleteRoleMemberByUserIDRoleID(ctx context.Context, userID uint64, roleID uint64) error {
|
||||
return s.execDeleteRoleMembers(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("rm.rel_user", ""): s.preprocessValue(userID, ""),
|
||||
s.preprocessColumn("rm.rel_role", ""): s.preprocessValue(roleID, ""),
|
||||
s.preprocessColumn("rm.rel_user", ""): store.PreprocessValue(userID, ""),
|
||||
s.preprocessColumn("rm.rel_role", ""): store.PreprocessValue(roleID, ""),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -223,7 +223,7 @@ func (s Store) QueryRoles(
|
||||
// It returns role even if deleted or suspended
|
||||
func (s Store) LookupRoleByID(ctx context.Context, id uint64) (*types.Role, error) {
|
||||
return s.execLookupRole(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("rl.id", ""): s.preprocessValue(id, ""),
|
||||
s.preprocessColumn("rl.id", ""): store.PreprocessValue(id, ""),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ func (s Store) LookupRoleByID(ctx context.Context, id uint64) (*types.Role, erro
|
||||
// It returns only valid roles (not deleted, not archived)
|
||||
func (s Store) LookupRoleByHandle(ctx context.Context, handle string) (*types.Role, error) {
|
||||
return s.execLookupRole(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("rl.handle", "lower"): s.preprocessValue(handle, "lower"),
|
||||
s.preprocessColumn("rl.handle", "lower"): store.PreprocessValue(handle, "lower"),
|
||||
|
||||
"rl.archived_at": nil,
|
||||
"rl.deleted_at": nil,
|
||||
@@ -244,7 +244,7 @@ func (s Store) LookupRoleByHandle(ctx context.Context, handle string) (*types.Ro
|
||||
// It returns only valid roles (not deleted, not archived)
|
||||
func (s Store) LookupRoleByName(ctx context.Context, name string) (*types.Role, error) {
|
||||
return s.execLookupRole(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("rl.name", ""): s.preprocessValue(name, ""),
|
||||
s.preprocessColumn("rl.name", ""): store.PreprocessValue(name, ""),
|
||||
|
||||
"rl.archived_at": nil,
|
||||
"rl.deleted_at": nil,
|
||||
@@ -284,7 +284,7 @@ func (s Store) partialRoleUpdate(ctx context.Context, onlyColumns []string, rr .
|
||||
err = s.execUpdateRoles(
|
||||
ctx,
|
||||
squirrel.Eq{
|
||||
s.preprocessColumn("rl.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("rl.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
},
|
||||
s.internalRoleEncoder(res).Skip("id").Only(onlyColumns...))
|
||||
if err != nil {
|
||||
@@ -317,7 +317,7 @@ func (s Store) DeleteRole(ctx context.Context, rr ...*types.Role) (err error) {
|
||||
for _, res := range rr {
|
||||
|
||||
err = s.execDeleteRoles(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("rl.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("rl.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
})
|
||||
if err != nil {
|
||||
return s.config.ErrorHandler(err)
|
||||
@@ -330,7 +330,7 @@ func (s Store) DeleteRole(ctx context.Context, rr ...*types.Role) (err error) {
|
||||
// DeleteRoleByID Deletes row from the roles table
|
||||
func (s Store) DeleteRoleByID(ctx context.Context, ID uint64) error {
|
||||
return s.execDeleteRoles(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("rl.id", ""): s.preprocessValue(ID, ""),
|
||||
s.preprocessColumn("rl.id", ""): store.PreprocessValue(ID, ""),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -97,8 +97,8 @@ func (s Store) QuerySettings(
|
||||
// LookupSettingByNameOwnedBy searches for settings by name and owner
|
||||
func (s Store) LookupSettingByNameOwnedBy(ctx context.Context, name string, owned_by uint64) (*types.SettingValue, error) {
|
||||
return s.execLookupSetting(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("st.name", ""): s.preprocessValue(name, ""),
|
||||
s.preprocessColumn("st.rel_owner", ""): s.preprocessValue(owned_by, ""),
|
||||
s.preprocessColumn("st.name", ""): store.PreprocessValue(name, ""),
|
||||
s.preprocessColumn("st.rel_owner", ""): store.PreprocessValue(owned_by, ""),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ func (s Store) partialSettingUpdate(ctx context.Context, onlyColumns []string, r
|
||||
err = s.execUpdateSettings(
|
||||
ctx,
|
||||
squirrel.Eq{
|
||||
s.preprocessColumn("st.name", ""): s.preprocessValue(res.Name, ""), s.preprocessColumn("st.rel_owner", ""): s.preprocessValue(res.OwnedBy, ""),
|
||||
s.preprocessColumn("st.name", ""): store.PreprocessValue(res.Name, ""), s.preprocessColumn("st.rel_owner", ""): store.PreprocessValue(res.OwnedBy, ""),
|
||||
},
|
||||
s.internalSettingEncoder(res).Skip("name", "rel_owner").Only(onlyColumns...))
|
||||
if err != nil {
|
||||
@@ -168,7 +168,7 @@ func (s Store) DeleteSetting(ctx context.Context, rr ...*types.SettingValue) (er
|
||||
for _, res := range rr {
|
||||
|
||||
err = s.execDeleteSettings(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("st.name", ""): s.preprocessValue(res.Name, ""), s.preprocessColumn("st.rel_owner", ""): s.preprocessValue(res.OwnedBy, ""),
|
||||
s.preprocessColumn("st.name", ""): store.PreprocessValue(res.Name, ""), s.preprocessColumn("st.rel_owner", ""): store.PreprocessValue(res.OwnedBy, ""),
|
||||
})
|
||||
if err != nil {
|
||||
return s.config.ErrorHandler(err)
|
||||
@@ -181,8 +181,8 @@ func (s Store) DeleteSetting(ctx context.Context, rr ...*types.SettingValue) (er
|
||||
// DeleteSettingByNameOwnedBy Deletes row from the settings table
|
||||
func (s Store) DeleteSettingByNameOwnedBy(ctx context.Context, name string, ownedBy uint64) error {
|
||||
return s.execDeleteSettings(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("st.name", ""): s.preprocessValue(name, ""),
|
||||
s.preprocessColumn("st.rel_owner", ""): s.preprocessValue(ownedBy, ""),
|
||||
s.preprocessColumn("st.name", ""): store.PreprocessValue(name, ""),
|
||||
s.preprocessColumn("st.rel_owner", ""): store.PreprocessValue(ownedBy, ""),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -223,7 +223,7 @@ func (s Store) QueryUsers(
|
||||
// It returns user even if deleted or suspended
|
||||
func (s Store) LookupUserByID(ctx context.Context, id uint64) (*types.User, error) {
|
||||
return s.execLookupUser(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("usr.id", ""): s.preprocessValue(id, ""),
|
||||
s.preprocessColumn("usr.id", ""): store.PreprocessValue(id, ""),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ func (s Store) LookupUserByID(ctx context.Context, id uint64) (*types.User, erro
|
||||
// It returns only valid users (not deleted, not suspended)
|
||||
func (s Store) LookupUserByEmail(ctx context.Context, email string) (*types.User, error) {
|
||||
return s.execLookupUser(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("usr.email", "lower"): s.preprocessValue(email, "lower"),
|
||||
s.preprocessColumn("usr.email", "lower"): store.PreprocessValue(email, "lower"),
|
||||
|
||||
"usr.deleted_at": nil,
|
||||
"usr.suspended_at": nil,
|
||||
@@ -244,7 +244,7 @@ func (s Store) LookupUserByEmail(ctx context.Context, email string) (*types.User
|
||||
// It returns only valid users (not deleted, not suspended)
|
||||
func (s Store) LookupUserByHandle(ctx context.Context, handle string) (*types.User, error) {
|
||||
return s.execLookupUser(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("usr.handle", "lower"): s.preprocessValue(handle, "lower"),
|
||||
s.preprocessColumn("usr.handle", "lower"): store.PreprocessValue(handle, "lower"),
|
||||
|
||||
"usr.deleted_at": nil,
|
||||
"usr.suspended_at": nil,
|
||||
@@ -256,7 +256,7 @@ func (s Store) LookupUserByHandle(ctx context.Context, handle string) (*types.Us
|
||||
// It returns only valid users (not deleted, not suspended)
|
||||
func (s Store) LookupUserByUsername(ctx context.Context, username string) (*types.User, error) {
|
||||
return s.execLookupUser(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("usr.username", "lower"): s.preprocessValue(username, "lower"),
|
||||
s.preprocessColumn("usr.username", "lower"): store.PreprocessValue(username, "lower"),
|
||||
|
||||
"usr.deleted_at": nil,
|
||||
"usr.suspended_at": nil,
|
||||
@@ -296,7 +296,7 @@ func (s Store) partialUserUpdate(ctx context.Context, onlyColumns []string, rr .
|
||||
err = s.execUpdateUsers(
|
||||
ctx,
|
||||
squirrel.Eq{
|
||||
s.preprocessColumn("usr.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("usr.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
},
|
||||
s.internalUserEncoder(res).Skip("id").Only(onlyColumns...))
|
||||
if err != nil {
|
||||
@@ -329,7 +329,7 @@ func (s Store) DeleteUser(ctx context.Context, rr ...*types.User) (err error) {
|
||||
for _, res := range rr {
|
||||
|
||||
err = s.execDeleteUsers(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("usr.id", ""): s.preprocessValue(res.ID, ""),
|
||||
s.preprocessColumn("usr.id", ""): store.PreprocessValue(res.ID, ""),
|
||||
})
|
||||
if err != nil {
|
||||
return s.config.ErrorHandler(err)
|
||||
@@ -342,7 +342,7 @@ func (s Store) DeleteUser(ctx context.Context, rr ...*types.User) (err error) {
|
||||
// DeleteUserByID Deletes row from the users table
|
||||
func (s Store) DeleteUserByID(ctx context.Context, ID uint64) error {
|
||||
return s.execDeleteUsers(ctx, squirrel.Eq{
|
||||
s.preprocessColumn("usr.id", ""): s.preprocessValue(ID, ""),
|
||||
s.preprocessColumn("usr.id", ""): store.PreprocessValue(ID, ""),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user