From 377e07cbd9b969542c97e26eed05d8acbb7f0f02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toma=C5=BE=20Jerman?= Date: Mon, 29 Aug 2022 13:29:18 +0200 Subject: [PATCH] Move dal attribute types to constants for reusability --- pkg/dal/attribute_types.go | 42 ++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/pkg/dal/attribute_types.go b/pkg/dal/attribute_types.go index 53ea352a7..bfb7d4aba 100644 --- a/pkg/dal/attribute_types.go +++ b/pkg/dal/attribute_types.go @@ -128,6 +128,22 @@ type ( } ) +const ( + AttributeTypeID AttributeType = "corteza::dal:attribute-type:id" + AttributeTypeRef = "corteza::dal:attribute-type:ref" + AttributeTypeTimestamp = "corteza::dal:attribute-type:timestamp" + AttributeTypeTime = "corteza::dal:attribute-type:time" + AttributeTypeDate = "corteza::dal:attribute-type:date" + AttributeTypeNumber = "corteza::dal:attribute-type:number" + AttributeTypeText = "corteza::dal:attribute-type:text" + AttributeTypeBoolean = "corteza::dal:attribute-type:boolean" + AttributeTypeEnum = "corteza::dal:attribute-type:enum" + AttributeTypeGeometry = "corteza::dal:attribute-type:geometry" + AttributeTypeJSON = "corteza::dal:attribute-type:json" + AttributeTypeBlob = "corteza::dal:attribute-type:blob" + AttributeTypeUUID = "corteza::dal:attribute-type:uuid" +) + func (t TypeID) IsNullable() bool { return t.Nullable } func (t TypeRef) IsNullable() bool { return t.Nullable } func (t TypeTimestamp) IsNullable() bool { return t.Nullable } @@ -142,16 +158,16 @@ func (t TypeJSON) IsNullable() bool { return t.Nullable } func (t TypeBlob) IsNullable() bool { return t.Nullable } func (t TypeUUID) IsNullable() bool { return t.Nullable } -func (t TypeID) Type() AttributeType { return "corteza::dal:attribute-type:id" } -func (t TypeRef) Type() AttributeType { return "corteza::dal:attribute-type:ref" } -func (t TypeTimestamp) Type() AttributeType { return "corteza::dal:attribute-type:timestamp" } -func (t TypeTime) Type() AttributeType { return "corteza::dal:attribute-type:time" } -func (t TypeDate) Type() AttributeType { return "corteza::dal:attribute-type:date" } -func (t TypeNumber) Type() AttributeType { return "corteza::dal:attribute-type:number" } -func (t TypeText) Type() AttributeType { return "corteza::dal:attribute-type:text" } -func (t TypeBoolean) Type() AttributeType { return "corteza::dal:attribute-type:boolean" } -func (t TypeEnum) Type() AttributeType { return "corteza::dal:attribute-type:enum" } -func (t TypeGeometry) Type() AttributeType { return "corteza::dal:attribute-type:geometry" } -func (t TypeJSON) Type() AttributeType { return "corteza::dal:attribute-type:json" } -func (t TypeBlob) Type() AttributeType { return "corteza::dal:attribute-type:blob" } -func (t TypeUUID) Type() AttributeType { return "corteza::dal:attribute-type:uuid" } +func (t TypeID) Type() AttributeType { return AttributeTypeID } +func (t TypeRef) Type() AttributeType { return AttributeTypeRef } +func (t TypeTimestamp) Type() AttributeType { return AttributeTypeTimestamp } +func (t TypeTime) Type() AttributeType { return AttributeTypeTime } +func (t TypeDate) Type() AttributeType { return AttributeTypeDate } +func (t TypeNumber) Type() AttributeType { return AttributeTypeNumber } +func (t TypeText) Type() AttributeType { return AttributeTypeText } +func (t TypeBoolean) Type() AttributeType { return AttributeTypeBoolean } +func (t TypeEnum) Type() AttributeType { return AttributeTypeEnum } +func (t TypeGeometry) Type() AttributeType { return AttributeTypeGeometry } +func (t TypeJSON) Type() AttributeType { return AttributeTypeJSON } +func (t TypeBlob) Type() AttributeType { return AttributeTypeBlob } +func (t TypeUUID) Type() AttributeType { return AttributeTypeUUID }