mikro-orm/mikro-orm

View on GitHub
packages/core/src/types/EnumType.ts

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import { Type } from './Type';
import type { Platform } from '../platforms';
import type { EntityProperty } from '../typings';

export class EnumType extends Type<string | null | undefined> {

  override getColumnType(prop: EntityProperty, platform: Platform) {
    if (prop.nativeEnumName) {
      return prop.nativeEnumName;
    }

    return prop.columnTypes?.[0] ?? platform.getEnumTypeDeclarationSQL(prop);
  }

  override compareAsType(): string {
    return 'string';
  }

  override ensureComparable(): boolean {
    return false;
  }

}