Skip to content

MikroOrmDialect

Defined in: packages/ddd-mikro-orm/src/errors/mikro-orm.dialect.ts:107

The MikroORM persistence dialect: it reads the violated unique constraint of a UniqueConstraintViolationException through the ORM’s entity metadata, so a repository maps it by entity property and never names a constraint or column.

  • PostgreSQL reports the constraint name; it is matched against the names in the mapping (unique: 'name' on a property, uniques[].name) or, when none is declared, the naming strategy’s indexName.
  • SQLite and libSQL report the table.column list; it is matched against the columns of each constraint.

Any other error, an entity without metadata, or an unknown constraint yields undefined, so the decorator rethrows the original error.

On construction, when a multi-property unique constraint has no name, or two constraints of one entity cover the same columns.

const orm = await MikroORM.init(options);
setPersistenceDialect(new MikroOrmDialect(orm));

new MikroOrmDialect(orm): MikroOrmDialect

Defined in: packages/ddd-mikro-orm/src/errors/mikro-orm.dialect.ts:114

Pick<MikroORM, "getMetadata" | "config">

MikroOrmDialect

uniqueViolation(error, entity): string | undefined

Defined in: packages/ddd-mikro-orm/src/errors/mikro-orm.dialect.ts:125

The key of the unique constraint error violated while writing entity: the entity property it covers, or the declared name of a multi-column constraint. undefined when error is not a unique violation, or names a constraint the dialect does not know.

unknown

object

string | undefined

IPersistenceDialect.uniqueViolation