Automatically cast Enums in assignment to database fields and vice versa - OpenEdge Development - Products Enhancements - Progress Community

 OpenEdge Development

Automatically cast Enums in assignment to database fields and vice versa

Database field cannot be ENUM types, so to store an ENUM, it must be one of STRING, INTEGER or INT64.

  1. When assigning an ENUM instance to a database field or a temp-table field automatically cast to the expected type.
  2. When assigning a STRING, INTEGER or INT64 database field or temp-table field to a variable of an ENUM type, automatically cast to an ENUM.

This is not needed for variable and property assignments, as they should ideally be defined as the ENUM type, but the simplest change (i.e. always cast or only cast when using buffers) is good enough.

In other word, instead of code like this:

ASSIGN Order.orderStatus = INT(OrderStatusEnum:Shipped)

....

ASSIGN oMyEnum = OrderStatusEnum:GetEnum(Order.orderStatus)

Allow the code to be like this:

ASSIGN Order.orderStatus = OrderStatusEnum:Shipped

....

ASSIGN oMyEnum = Order.orderStatus
Comments
  • "This is not needed for variable and property assignments, as they should ideally be defined as the ENUM type" => despite not being 100% needed, this would be nice that whatever the left side, if its type is known at compile time, the cast be done automagically, be it (temp) table field or variable.