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

Function splitPartitionName

packages/sql/src/schema/partitioning.ts:184–209  ·  view source on GitHub ↗
(name: string)

Source from the content-addressed store, hash-verified

182 * double-quoted identifiers are part of the identifier and do not split.
183 */
184const splitPartitionName = (name: string): { name: string; schema?: string } => {
185 let depth = 0;
186
187 for (let i = 0; i < name.length; i++) {
188 const ch = name[i];
189
190 if (ch === '"') {
191 if (name[i + 1] === '"') {
192 i++;
193 continue;
194 }
195
196 depth = depth === 0 ? 1 : 0;
197 continue;
198 }
199
200 if (ch === '.' && depth === 0) {
201 return {
202 schema: unquoteIdentifier(name.slice(0, i)),
203 name: unquoteIdentifier(name.slice(i + 1)),
204 };
205 }
206 }
207
208 return { name: unquoteIdentifier(name) };
209};
210
211const resolvePartitionKey = (meta: EntityMetadata, key: string, quoteIdentifier: (id: string) => string): string => {
212 const trimmed = key.trim().replaceAll('"', '');

Callers 2

createHashPartitionsFunction · 0.85
createExplicitPartitionsFunction · 0.85

Calls 2

unquoteIdentifierFunction · 0.85
sliceMethod · 0.80

Tested by

no test coverage detected