Fix ID and Ref type casting for MySQL databases
The CAST function takes in UNSIGNED instead of BIGINT.
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user