databaseType property

String get databaseType

Get the pgsql type that represents this TypeDefinition in the database.

Implementation

String get databaseType {
  // TODO: add all supported types here
  var enumSerialization = enumDefinition?.serialized;
  if (enumSerialization != null && isEnumType) {
    switch (enumSerialization) {
      case EnumSerialization.byName:
        return 'text';
      case EnumSerialization.byIndex:
        return 'bigint';
    }
  }
  if (className == 'int') return 'bigint';
  if (className == 'double') return 'double precision';
  if (className == 'bool') return 'boolean';
  if (className == 'String') return 'text';
  if (className == 'DateTime') return 'timestamp without time zone';
  if (className == 'ByteData') return 'bytea';
  if (className == 'Duration') return 'bigint';
  if (className == 'UuidValue') return 'uuid';
  if (className == 'Uri') return 'text';
  if (className == 'BigInt') return 'text';
  if (className == 'Vector') return 'vector';
  if (className == 'HalfVector') return 'halfvec';
  if (className == 'SparseVector') return 'sparsevec';
  if (className == 'Bit') return 'bit';

  return 'json';
}