Skip to content

Cast Operations

Operation: createCast

pgm.createCast( source_type, target_type, opttions )

IMPORTANT

Create a new cast - postgres docs

Arguments

NameTypeDescription
source_typestringThe name of the source data type of the cast
target_typestringThe name of the target data type of the cast
optionsobjectCheck below for available options

Options

OptionTypeDescription
functionNamestringName of function to use to do the cast
argumentTypesarrayArray of types of arguments for the function
inoutbooleanUse standard I/O routines for conversion
asstringIndicate when this may cast may be done implicitly
Tips
  • argumentTypes: Is an array of strings listing the types of arguments for the conversion function. If this is not present, it defaults to just the source_type.

  • inout: Setting this to true indicates that conversion should be used by using the standard text output conversion for source_type and passing the result to the input conversion process for target_type.

  • as: This may be either assignment or implicit. If implicit is used, the cast may be used implicitly in any context; this is not recommended. If assignment is used the cast will only be done implicitly in assignments.

Reverse Operation: dropCast

pgm.dropCast( source_type, target_type )

IMPORTANT

Drop a cast - postgres docs

Arguments

NameTypeDescription
source_typestringThe name of the source data type of the cast
target_typestringThe name of the target data type of the cast
optionsobjectCheck below for available options

Options

OptionTypeDescription
ifExistsbooleanDo not throw an error if the cast does not exist