Skip to content

In Schema, allow defining default values for properties #52

@julianhyde

Description

@julianhyde

Allow defining default values for properties. For example, we could define that the default value of primary_key is `false:

  object_type: dimension {
    property: type {
      type: dimension_field_type
    }
    property: sql {
      type: code
    }
    property: label {
      type: string
    }
    property: primary_key {
      type: boolean
      default: "false"
    }
    property: tags {
      type: string_list
    }
  }

Defaults would only be allowed for properties of type string, number and an enum type defined in the schema, such as 'boolean'.

In the schema, defaults are always strings. The schema loader must check that they are valid (valid numbers, valid members of their enum).

If a property has a default, the value of cardinality is ignored. The user does not need to specify the property, and the consumer can assume that it is present. (In future, we may add a newcardinality value implied alongside required and optional.)

In LookmlSchemas.ObjectTypeBuilder, add method withDefaultValue. As for the existing method withCardinality, withDefaultValue applies to the previously added property, and throws if there was no previous property.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions