Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
Daniel 2025-12-29 09:19:24 +08:00
parent f5167ae895
commit 3c00f5a3d1
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 13 additions and 2 deletions

View file

@ -1203,10 +1203,15 @@ func (tx *Transaction) doInsert0(operation *Operation, tree *parse.Tree) (ret *T
remains = append(remains, remain)
}
}
if "" == insertedNode.ID {
if !ast.IsNodeIDPattern(insertedNode.ID) {
insertedNode.ID = ast.NewNodeID()
insertedNode.SetIALAttr("id", insertedNode.ID)
}
if ast.NodeAttributeView == insertedNode.Type {
if !ast.IsNodeIDPattern(insertedNode.AttributeViewID) {
insertedNode.AttributeViewID = ast.NewNodeID()
}
}
var node *ast.Node
nextID := operation.NextID
@ -1783,8 +1788,9 @@ func createdUpdated(node *ast.Node) {
created := util.TimeFromID(node.ID)
updated := node.IALAttr("updated")
if "" == updated {
if !util.IsTimeStr(updated) {
updated = created
node.SetIALAttr("updated", updated)
}
if updated < created {
updated = created

View file

@ -26,6 +26,11 @@ import (
"github.com/88250/go-humanize"
)
func IsTimeStr(str string) bool {
_, err := time.Parse("20060102150405", str)
return nil == err
}
func GetTodayStart() (ret time.Time) {
ret = time.Now()
ret = time.Date(ret.Year(), ret.Month(), ret.Day(), 0, 0, 0, 0, time.Local)