Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Data Type Mapping Table

Comprehensive mapping between MDL data types, Mendix internal types, and backend representations.

Primitive Types

MDL TypeDescriptionRange/Limits
StringVariable-length text (default length 200)1 to unlimited characters
String(n)Variable-length text with explicit length1 to unlimited characters
Integer32-bit signed integer-2,147,483,648 to 2,147,483,647
Long64-bit signed integer-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
DecimalHigh-precision decimal numberUp to 20 digits total
BooleanTrue/false valuetrue or false (must have DEFAULT)
DateTimeDate and time with timezone awarenessUTC timestamp
DateDate only (no time component)Internally stored as DateTime
AutoNumberAuto-incrementing integerTypically combined with NOT NULL UNIQUE
BinaryBinary data (files, images)Configurable max size
HashedStringSecurely hashed string (passwords)One-way hash, cannot be retrieved

Complex Types

MDL TypeDescriptionExample
Enumeration(Module.EnumName)Reference to an enumeration typeStatus: Enumeration(Sales.OrderStatus)

MDL to Backend Type Mapping

MDL TypeBSON $TypeGo Type (SDK)
StringDomainModels$StringAttributeType*StringAttributeType
String(n)DomainModels$StringAttributeType + Length*StringAttributeType{Length: n}
IntegerDomainModels$IntegerAttributeType*IntegerAttributeType
LongDomainModels$LongAttributeType*LongAttributeType
DecimalDomainModels$DecimalAttributeType*DecimalAttributeType
BooleanDomainModels$BooleanAttributeType*BooleanAttributeType
DateTimeDomainModels$DateTimeAttributeType*DateTimeAttributeType
DateDomainModels$DateTimeAttributeType*DateTimeAttributeType
AutoNumberDomainModels$AutoNumberAttributeType*AutoNumberAttributeType
BinaryDomainModels$BinaryAttributeType*BinaryAttributeType
EnumerationDomainModels$EnumerationAttributeType*EnumerationAttributeType
HashedStringDomainModels$HashedStringAttributeType*HashedStringAttributeType

Default Value Mapping

MDL DefaultBSON StructureGo Structure
DEFAULT 'text'Value: {$Type: "DomainModels$StoredValue", DefaultValue: "text"}Value: &AttributeValue{DefaultValue: "text"}
DEFAULT 123Value: {$Type: "DomainModels$StoredValue", DefaultValue: "123"}Value: &AttributeValue{DefaultValue: "123"}
DEFAULT TRUEValue: {$Type: "DomainModels$StoredValue", DefaultValue: "true"}Value: &AttributeValue{DefaultValue: "true"}
(calculated)Value: {$Type: "DomainModels$CalculatedValue", Microflow: <id>}Value: &AttributeValue{Type: "CalculatedValue", MicroflowID: id}

Default Value Syntax by Type

TypeDefault SyntaxExamples
StringDEFAULT 'value'DEFAULT '', DEFAULT 'Unknown'
IntegerDEFAULT nDEFAULT 0, DEFAULT -1
LongDEFAULT nDEFAULT 0
DecimalDEFAULT n.nDEFAULT 0, DEFAULT 0.00, DEFAULT 99.99
BooleanDEFAULT TRUE/FALSEDEFAULT TRUE, DEFAULT FALSE
AutoNumberDEFAULT nDEFAULT 1 (starting value)
EnumerationDEFAULT Module.Enum.ValueDEFAULT Shop.Status.Active, DEFAULT 'Pending'

Constraints

ConstraintSyntaxDescription
Not NullNOT NULLValue is required
Not Null with ErrorNOT NULL ERROR 'message'Required with custom error
UniqueUNIQUEValue must be unique
Unique with ErrorUNIQUE ERROR 'message'Unique with custom error

Constraints must appear in this order:

  1. NOT NULL [ERROR '...']
  2. UNIQUE [ERROR '...']
  3. DEFAULT <value>

Type Compatibility

MDL does not perform implicit type conversions. Types must match exactly.

Compatible type changes:

  • String(100) to String(200) – Increasing length
  • Integer to Long – Widening numeric type

Incompatible type changes:

  • String to Integer
  • Boolean to String
  • Any type to AutoNumber (if not empty)

Complete Example

/** Example entity demonstrating all data types */
@Position(100, 100)
CREATE PERSISTENT ENTITY Demo.AllTypes (
  /** Auto-generated ID */
  Id: AutoNumber NOT NULL UNIQUE DEFAULT 1,

  /** Short text field */
  Code: String(10) NOT NULL UNIQUE,

  /** Standard text field */
  Name: String(200) NOT NULL,

  /** Long text field */
  Description: String(unlimited),

  /** Integer counter */
  Counter: Integer DEFAULT 0,

  /** Large number */
  BigNumber: Long,

  /** Money amount */
  Amount: Decimal DEFAULT 0.00,

  /** Flag field */
  IsActive: Boolean DEFAULT TRUE,

  /** Timestamp */
  CreatedAt: DateTime,

  /** Date only */
  BirthDate: Date,

  /** File attachment */
  Attachment: Binary,

  /** Status from enumeration */
  Status: Enumeration(Demo.Status) DEFAULT 'Active'
)
INDEX (Code)
INDEX (Name, CreatedAt DESC);