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

Function validateSqlOptions

packages/sql/src/AbstractSqlDriver.ts:145–166  ·  view source on GitHub ↗
(options: { collation?: any; indexHint?: any; using?: any })

Source from the content-addressed store, hash-verified

143 }
144
145 private validateSqlOptions(options: { collation?: any; indexHint?: any; using?: any }): void {
146 if (options.using && !options.indexHint) {
147 const names = Utils.asArray(options.using);
148 const hint = this.platform.formatIndexHint(names);
149
150 if (hint) {
151 options.indexHint = hint;
152 }
153 }
154
155 if (options.collation != null && typeof options.collation !== 'string') {
156 throw new Error(
157 'Collation option for SQL drivers must be a string (collation name). Use a CollationOptions object only with MongoDB.',
158 );
159 }
160
161 if (options.indexHint != null && typeof options.indexHint !== 'string') {
162 throw new Error(
163 "indexHint for SQL drivers must be a string (e.g. 'force index(my_index)'). Use an object only with MongoDB.",
164 );
165 }
166 }
167
168 override createEntityManager(useContext?: boolean): this[typeof EntityManagerType] {
169 const EntityManagerClass = this.config.get('entityManager', SqlEntityManager);

Callers

nothing calls this directly

Calls 2

asArrayMethod · 0.80
formatIndexHintMethod · 0.45

Tested by

no test coverage detected