MCPcopy Create free account
hub / github.com/mikro-orm/mikro-orm / onConflict

Method onConflict

packages/sql/src/query/QueryBuilder.ts:1916–1932  ·  view source on GitHub ↗
(
    fields: F | F[] | RawQueryFragment = [] as F[],
  )

Source from the content-addressed store, hash-verified

1914 }
1915
1916 onConflict<F extends Field<Entity, RootAlias, Context>>(
1917 fields: F | F[] | RawQueryFragment = [] as F[],
1918 ): InsertQueryBuilder<Entity, RootAlias, Context> {
1919 const meta = this.mainAlias.meta as EntityMetadata<Entity>;
1920 this.ensureNotFinalized();
1921 this.#state.onConflict ??= [];
1922 this.#state.onConflict.push({
1923 fields: isRaw(fields)
1924 ? fields
1925 : Utils.asArray(fields as string).flatMap(f => {
1926 const key = f.toString() as EntityKey<Entity>;
1927 /* v8 ignore next */
1928 return meta.properties[key]?.fieldNames ?? [key];
1929 }),
1930 });
1931 return this as unknown as InsertQueryBuilder<Entity, RootAlias, Context>;
1932 }
1933
1934 ignore(): this {
1935 if (!this.#state.onConflict) {

Calls 5

ensureNotFinalizedMethod · 0.95
isRawFunction · 0.90
pushMethod · 0.80
asArrayMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected