3
0

Fix ID and Ref type casting for MySQL databases

The CAST function takes in UNSIGNED instead of BIGINT.
This commit is contained in:
Tomaž Jerman
2022-09-15 12:05:56 +02:00
parent da24de8b09
commit bd68b76137
+13 -4
View File
@@ -2,15 +2,17 @@ package mysql
import (
"fmt"
"github.com/cortezaproject/corteza-server/pkg/dal"
"strconv"
"strings"
"github.com/cortezaproject/corteza-server/store/adapters/rdbms/ddl"
"github.com/cortezaproject/corteza-server/store/adapters/rdbms/drivers"
"github.com/cortezaproject/corteza-server/store/adapters/rdbms/ql"
"github.com/cortezaproject/corteza-server/pkg/dal"
"github.com/cortezaproject/corteza-server/store/adapters/rdbms/drivers"
"github.com/doug-martin/goqu/v9"
"github.com/doug-martin/goqu/v9/dialect/mysql"
"github.com/doug-martin/goqu/v9/exp"
"strconv"
"strings"
)
type (
@@ -95,6 +97,13 @@ func (mysqlDialect) AttributeCast(attr *dal.Attribute, val exp.LiteralExpression
c = exp.NewCastExpression(ce, "SIGNED")
case *dal.TypeID, *dal.TypeRef:
ce := exp.NewCaseExpression().
When(val.RegexpLike(drivers.CheckID), val).
Else(drivers.LiteralNULL)
c = exp.NewCastExpression(ce, "UNSIGNED")
default:
return drivers.AttributeCast(attr, val)