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

Function normalizePartitionDefinition

packages/sql/src/schema/partitioning.ts:271–287  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

269
270/** @internal */
271export function normalizePartitionDefinition(value: string): string {
272 const normalized = normalizeWhitespace(value);
273 const match = /^(\w+)\s*(.*)$/.exec(normalized);
274 const rawType = match ? match[1] : normalized;
275 const type = rawType.toLowerCase();
276 const expression = match ? match[2].trim() : '';
277
278 if (!expression) {
279 return type;
280 }
281
282 if (!expression.startsWith('(')) {
283 return `${type} ${normalizePartitionSqlFragment(expression)}`;
284 }
285
286 return `${type} (${normalizePartitionSqlFragment(unwrapAllOuterParentheses(expression))})`;
287}
288
289const PARTITION_BOUND_KEYWORDS = /\b(for values|with|in|from|to|minvalue|maxvalue|null)\b/gi;
290

Callers 4

getPartitionsMethod · 0.85
diffPartitioningFunction · 0.85
toEntityPartitionByFunction · 0.85

Calls 3

normalizeWhitespaceFunction · 0.85

Tested by

no test coverage detected