Fix DAL model diff computation for record revisions and psql db
* Fixed up type inconsistency. * Added some missing type fit matching.
This commit is contained in:
@@ -19,7 +19,7 @@ record: {
|
||||
attributes: {
|
||||
id: schema.IdField
|
||||
revision: {
|
||||
goType: "uint"
|
||||
goType: "int"
|
||||
dal: { type: "Number", meta: { "rdbms:type": "integer" }, default: 0 }
|
||||
}
|
||||
module_id: {
|
||||
|
||||
+1
-1
@@ -450,7 +450,7 @@ func (r *Record) SetValue(name string, pos uint, value any) (err error) {
|
||||
case "ownedBy", "OwnedBy", "owned_by":
|
||||
return cast2.Uint64(value, &r.OwnedBy)
|
||||
case "revision", "Revision":
|
||||
return cast2.Uint(value, &r.Revision)
|
||||
return cast2.Int(value, &r.Revision)
|
||||
case "updatedAt", "UpdatedAt":
|
||||
return cast2.TimePtr(value, &r.UpdatedAt)
|
||||
case "updatedBy", "UpdatedBy", "updated_by":
|
||||
|
||||
@@ -46,7 +46,7 @@ type (
|
||||
ID uint64 `json:"recordID,string"`
|
||||
ModuleID uint64 `json:"moduleID,string"`
|
||||
|
||||
Revision uint `json:"revision,omitempty"`
|
||||
Revision int `json:"revision,omitempty"`
|
||||
|
||||
module *Module
|
||||
|
||||
|
||||
@@ -3,11 +3,12 @@ package revisions
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/cortezaproject/corteza/server/pkg/cast2"
|
||||
"github.com/cortezaproject/corteza/server/pkg/dal"
|
||||
"github.com/cortezaproject/corteza/server/pkg/filter"
|
||||
"github.com/cortezaproject/corteza/server/pkg/id"
|
||||
"time"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -18,7 +19,7 @@ type (
|
||||
|
||||
ResourceID uint64 `json:"resourceID,string"`
|
||||
|
||||
Revision uint `json:"revision"`
|
||||
Revision int `json:"revision"`
|
||||
Operation Operation `json:"operation"`
|
||||
|
||||
UserID uint64 `json:"userID,string"`
|
||||
@@ -47,7 +48,7 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
func Make(op Operation, revision uint, resourceID, userID uint64) (rev *Revision) {
|
||||
func Make(op Operation, revision int, resourceID, userID uint64) (rev *Revision) {
|
||||
return &Revision{
|
||||
ID: id.Next(),
|
||||
Timestamp: now(),
|
||||
@@ -190,7 +191,7 @@ func (r *Revision) SetValue(name string, _ uint, value any) error {
|
||||
return cast2.Uint64(value, &r.ResourceID)
|
||||
|
||||
case "revision":
|
||||
return cast2.Uint(value, &r.Revision)
|
||||
return cast2.Int(value, &r.Revision)
|
||||
|
||||
case "operation":
|
||||
return cast2.String(value, &r.Operation)
|
||||
|
||||
@@ -229,6 +229,15 @@ func (postgresDialect) ColumnFits(target, assert *ddl.Column) bool {
|
||||
"numeric": {
|
||||
"text": true,
|
||||
"varchar": true,
|
||||
"bigint": true,
|
||||
// @note this isn't entirely correct, but record revision lapsus made us
|
||||
"integer": true,
|
||||
},
|
||||
"integer": {
|
||||
"text": true,
|
||||
"varchar": true,
|
||||
"bigint": true,
|
||||
"numeric": true,
|
||||
},
|
||||
"timestamp": {
|
||||
"text": true,
|
||||
|
||||
Reference in New Issue
Block a user