Skip to content

Commit 4ac63e5

Browse files
committed
fix: add Date as distinct type from DateTime throughout the pipeline
Date attributes are stored as DomainModels$DateTimeAttributeType with LocalizeDate=false in BSON. Added DateAttributeType (domain model) and DateType (microflows) structs. Parser now distinguishes Date (LocalizeDate=false) from DateTime (LocalizeDate=true). Updated all type switches in executor, formatters, writers, and catalog. Also fixed Long type mapping in cmd_dbconnection.go (DataTypes$LongType). Fixes #26
1 parent b46bf51 commit 4ac63e5

19 files changed

Lines changed: 83 additions & 19 deletions

mdl/catalog/builder_microflows.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,8 @@ func getDataTypeName(dt microflows.DataType) string {
318318
return "String"
319319
case *microflows.DateTimeType:
320320
return "DateTime"
321+
case *microflows.DateType:
322+
return "Date"
321323
case *microflows.ObjectType:
322324
return "Object:" + t.EntityQualifiedName
323325
case *microflows.ListType:

mdl/executor/cmd_constants.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ func formatConstantType(dt model.ConstantDataType) string {
178178
return "Boolean"
179179
case "DateTime":
180180
return "DateTime"
181+
case "Date":
182+
return "Date"
181183
case "Binary":
182184
return "Binary"
183185
case "Enumeration":
@@ -218,6 +220,8 @@ func formatConstantTypeForMDL(dt model.ConstantDataType) string {
218220
return "Boolean"
219221
case "DateTime":
220222
return "DateTime"
223+
case "Date":
224+
return "Date"
221225
case "Binary":
222226
return "Binary"
223227
case "Enumeration":
@@ -397,6 +401,8 @@ func astDataTypeToConstantDataType(dt ast.DataType) model.ConstantDataType {
397401
return model.ConstantDataType{Kind: "Boolean"}
398402
case ast.TypeDateTime:
399403
return model.ConstantDataType{Kind: "DateTime"}
404+
case ast.TypeDate:
405+
return model.ConstantDataType{Kind: "Date"}
400406
case ast.TypeBinary:
401407
return model.ConstantDataType{Kind: "Binary"}
402408
case ast.TypeEnumeration:

mdl/executor/cmd_dbconnection.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,12 +326,12 @@ func astDataTypeToDBType(dt ast.DataType) string {
326326
case ast.TypeInteger:
327327
return "DataTypes$IntegerType"
328328
case ast.TypeLong:
329-
return "DataTypes$IntegerType"
329+
return "DataTypes$LongType"
330330
case ast.TypeDecimal:
331331
return "DataTypes$DecimalType"
332332
case ast.TypeBoolean:
333333
return "DataTypes$BooleanType"
334-
case ast.TypeDateTime:
334+
case ast.TypeDateTime, ast.TypeDate:
335335
return "DataTypes$DateTimeType"
336336
default:
337337
return "DataTypes$StringType"

mdl/executor/cmd_diff_local.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,11 @@ func (e *Executor) attributeBsonToMDL(raw map[string]any) string {
374374
case strings.Contains(attrType, "BooleanAttributeType"):
375375
typeStr = "Boolean"
376376
case strings.Contains(attrType, "DateTimeAttributeType"):
377-
typeStr = "DateTime"
377+
if localize, ok := raw["LocalizeDate"].(bool); ok && localize {
378+
typeStr = "DateTime"
379+
} else {
380+
typeStr = "Date"
381+
}
378382
case strings.Contains(attrType, "AutoNumberAttributeType"):
379383
typeStr = "AutoNumber"
380384
case strings.Contains(attrType, "BinaryAttributeType"):
@@ -404,7 +408,11 @@ func (e *Executor) attributeBsonToMDL(raw map[string]any) string {
404408
case strings.Contains(typeType, "BooleanAttributeType"):
405409
typeStr = "Boolean"
406410
case strings.Contains(typeType, "DateTimeAttributeType"):
407-
typeStr = "DateTime"
411+
if localize, ok := typeObj["LocalizeDate"].(bool); ok && localize {
412+
typeStr = "DateTime"
413+
} else {
414+
typeStr = "Date"
415+
}
408416
case strings.Contains(typeType, "AutoNumberAttributeType"):
409417
typeStr = "AutoNumber"
410418
case strings.Contains(typeType, "BinaryAttributeType"):

mdl/executor/cmd_diff_mdl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ func (e *Executor) dataTypeToString(dt ast.DataType) string {
638638
case ast.TypeDateTime:
639639
return "DateTime"
640640
case ast.TypeDate:
641-
return "DateTime"
641+
return "Date"
642642
case ast.TypeAutoNumber:
643643
return "AutoNumber"
644644
case ast.TypeBinary:

mdl/executor/cmd_microflows_helpers.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ func convertASTToMicroflowDataType(dt ast.DataType, entityResolver func(ast.Qual
2727
return &microflows.DecimalType{}
2828
case ast.TypeString:
2929
return &microflows.StringType{}
30-
case ast.TypeDateTime, ast.TypeDate:
30+
case ast.TypeDateTime:
3131
return &microflows.DateTimeType{}
32+
case ast.TypeDate:
33+
return &microflows.DateType{}
3234
case ast.TypeBinary:
3335
return &microflows.BinaryType{}
3436
case ast.TypeVoid:

mdl/executor/cmd_microflows_show.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,8 @@ func (e *Executor) formatMicroflowDataType(dt microflows.DataType, entityNames m
525525
return "String"
526526
case *microflows.DateTimeType:
527527
return "DateTime"
528+
case *microflows.DateType:
529+
return "Date"
528530
case *microflows.BinaryType:
529531
return "Binary"
530532
case *microflows.VoidType:

mdl/executor/cmd_pages_builder_input_filters.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func (pb *pageBuilder) getFilterWidgetIDForAttribute(attrPath string) string {
2424
case *domainmodel.IntegerAttributeType, *domainmodel.LongAttributeType,
2525
*domainmodel.DecimalAttributeType, *domainmodel.AutoNumberAttributeType:
2626
return pages.WidgetIDDataGridNumberFilter
27-
case *domainmodel.DateTimeAttributeType:
27+
case *domainmodel.DateTimeAttributeType, *domainmodel.DateAttributeType:
2828
return pages.WidgetIDDataGridDateFilter
2929
case *domainmodel.BooleanAttributeType, *domainmodel.EnumerationAttributeType:
3030
return pages.WidgetIDDataGridDropdownFilter

mdl/executor/cmd_pages_builder_v3.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ func mdlTypeToBsonType(mdlType string) string {
967967
return "DataTypes$LongType"
968968
case "decimal":
969969
return "DataTypes$DecimalType"
970-
case "datetime":
970+
case "datetime", "date":
971971
return "DataTypes$DateTimeType"
972972
default:
973973
// Could be an entity type - use ObjectType

mdl/executor/cmd_structure.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,8 @@ func formatDataTypeDisplay(dt microflows.DataType) string {
990990
return "String"
991991
case *microflows.DateTimeType:
992992
return "DateTime"
993+
case *microflows.DateType:
994+
return "Date"
993995
case *microflows.ObjectType:
994996
return shortName(t.EntityQualifiedName)
995997
case *microflows.ListType:

0 commit comments

Comments
 (0)