3
0

Add (temporary) solution to MSSQL true/false representation problem

Passing dialect options lower so the supporting functions can prepare
proper expressions.
Might be better off defining a new nuance for this, or researching
more if I can trick goqu to do it correctly.
This commit is contained in:
Tomaž Jerman
2022-11-30 14:26:45 +01:00
committed by Jože Fortun
parent 41234648a9
commit 7c857ab183
10 changed files with 201 additions and 180 deletions

View File

@@ -7,6 +7,7 @@ import (
{{- range $path, $alias := .imports }}
{{ $alias }} {{ printf "%q" $path }}
{{- end }}
"github.com/cortezaproject/corteza/server/store/adapters/rdbms/drivers"
"github.com/doug-martin/goqu/v9"
)
@@ -34,15 +35,15 @@ type (
// are generated and can choose to ignore or alter them.
//
// This function is auto-generated
func {{ .expIdent }}Filter(f {{ .goFilterType }})(ee []goqu.Expression, _ {{ .goFilterType }}, err error) {
func {{ .expIdent }}Filter(d drivers.Dialect, f {{ .goFilterType }})(ee []goqu.Expression, _ {{ .goFilterType }}, err error) {
{{ range .filter.byNilState }}
if expr := stateNilComparison({{ printf "%q" .storeIdent }}, f.{{ .expIdent }}); expr != nil {
if expr := stateNilComparison(d,{{ printf "%q" .storeIdent }}, f.{{ .expIdent }}); expr != nil {
ee = append(ee, expr)
}
{{ end }}
{{ range .filter.byFalseState }}
if expr := stateFalseComparison({{ printf "%q" .storeIdent }}, f.{{ .expIdent }}); expr != nil {
if expr := stateFalseComparison(d,{{ printf "%q" .storeIdent }}, f.{{ .expIdent }}); expr != nil {
ee = append(ee, expr)
}
{{ end }}

View File

@@ -377,7 +377,7 @@ func (s *Store) Query{{ .expIdentPlural }}(
tExpr, f, err = s.Filters.{{ .expIdent }}(s, f)
} else {
// using generated filter
tExpr, f, err = {{ .expIdent }}Filter(f)
tExpr, f, err = {{ .expIdent }}Filter(s.Dialect, f)
}
if err != nil {
@@ -498,7 +498,7 @@ func (s *Store) Query{{ .expIdentPlural }}(
{{- end }}
{{- end }}
{{- range .nullConstraint }}
stateNilComparison({{ printf "%q" . }}, filter.StateExcluded),
stateNilComparison(s.Dialect, {{ printf "%q" . }}, filter.StateExcluded),
{{- end }}
).Limit(1)
)