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

Method quote

packages/sql/src/query/NativeQueryBuilder.ts:697–726  ·  view source on GitHub ↗
(id: string | RawQueryFragment | NativeQueryBuilder)

Source from the content-addressed store, hash-verified

695 }
696
697 protected quote(id: string | RawQueryFragment | NativeQueryBuilder): string {
698 if (isRaw(id)) {
699 return this.platform.formatQuery(id.sql, id.params);
700 }
701
702 if (id instanceof NativeQueryBuilder) {
703 const { sql, params } = id.compile();
704 return this.platform.formatQuery(sql, params);
705 }
706
707 if (id.endsWith('.*')) {
708 const schema = this.platform.quoteIdentifier(id.substring(0, id.indexOf('.')));
709 return schema + '.*';
710 }
711
712 if (id.toLowerCase().includes(' as ')) {
713 const parts = id.split(/ as /i);
714 const a = this.platform.quoteIdentifier(parts[0]);
715 const b = this.platform.quoteIdentifier(parts[1]);
716
717 const asKeyword = this.platform.usesAsKeyword() ? ' as ' : ' ';
718 return `${a}${asKeyword}${b}`;
719 }
720
721 if (id === '*') {
722 return id;
723 }
724
725 return this.platform.quoteIdentifier(id);
726 }
727}

Callers 15

fromMethod · 0.95
compileMethod · 0.95
addLockClauseMethod · 0.95
addOnConflictClauseMethod · 0.95
insertSelectMethod · 0.95
compileSelectMethod · 0.95
getFieldsMethod · 0.95
addOutputClauseMethod · 0.95
processInsertDataMethod · 0.95
compileUpdateMethod · 0.95
compileCtesMethod · 0.95
getRenameColumnSQLFunction · 0.45

Calls 5

isRawFunction · 0.90
formatQueryMethod · 0.80
usesAsKeywordMethod · 0.80
compileMethod · 0.45
quoteIdentifierMethod · 0.45

Tested by

no test coverage detected