{"version":3,"file":"dialect.mjs","sources":["../../src/dialects/dialect.ts"],"sourcesContent":["import type { Knex } from 'knex';\n\nimport type { Database } from '..';\nimport type { ForeignKey, Index, Schema } from '../schema';\n\nexport interface SchemaInspector {\n  getSchema(): Promise<Schema>;\n  getIndexes(tableName: string): Promise<Index[]>;\n  getForeignKeys(tableName: string): Promise<ForeignKey[]>;\n  getTables(): Promise<string[]>;\n}\n\nexport default class Dialect {\n  db: Database;\n\n  schemaInspector: SchemaInspector = {} as SchemaInspector;\n\n  client: string;\n\n  constructor(db: Database, client: string) {\n    this.db = db;\n    this.client = client;\n  }\n\n  // eslint-disable-next-line @typescript-eslint/no-unused-vars\n  configure(conn?: any) {}\n\n  // eslint-disable-next-line @typescript-eslint/no-unused-vars\n  async initialize(_nativeConnection?: unknown) {\n    // noop\n  }\n\n  getTables() {\n    throw new Error('getTables not implemented for this dialect');\n  }\n\n  getSqlType(type: unknown) {\n    return type;\n  }\n\n  canAlterConstraints() {\n    return true;\n  }\n\n  usesForeignKeys() {\n    return false;\n  }\n\n  useReturning() {\n    return false;\n  }\n\n  supportsUnsigned() {\n    return false;\n  }\n\n  supportsOperator(operator?: string): boolean;\n  supportsOperator(): boolean {\n    return true;\n  }\n\n  async startSchemaUpdate() {\n    // noop\n  }\n\n  async endSchemaUpdate() {\n    // noop\n  }\n\n  transformErrors(error: Error | { message: string }) {\n    if (error instanceof Error) {\n      throw error;\n    }\n\n    throw new Error(error.message);\n  }\n\n  canAddIncrements() {\n    return true;\n  }\n\n  /**\n   * Whether indexes and constraints can be renamed in place (used by the rename\n   * migration helpers to keep index/constraint names in sync with a renamed\n   * column or table). When false, schema sync drops and recreates them by name.\n   */\n  canRenameSchemaObjects() {\n    return false;\n  }\n\n  /**\n   * Renames the index or constraint `from` on `table` to `to`, if it exists and\n   * `to` is free. Runs on the given transaction. Returns whether a rename happened.\n   */\n  async renameSchemaObject(\n    // eslint-disable-next-line @typescript-eslint/no-unused-vars\n    trx: Knex,\n    // eslint-disable-next-line @typescript-eslint/no-unused-vars\n    params: { table: string; from: string; to: string }\n  ): Promise<boolean> {\n    return false;\n  }\n\n  /**\n   * Drops the index (and, where foreign keys are named, the foreign-key\n   * constraint) called `name` on `table`, if it exists. Used by the rename\n   * migration helpers on dialects that cannot rename schema objects in place,\n   * so a renamed table/column does not keep an index under its old name\n   * (schema sync never drops it and would collide when re-creating it). Runs on\n   * the given transaction. Returns whether anything was dropped.\n   */\n  async dropSchemaObject(\n    // eslint-disable-next-line @typescript-eslint/no-unused-vars\n    trx: Knex,\n    // eslint-disable-next-line @typescript-eslint/no-unused-vars\n    params: { table: string; name: string }\n  ): Promise<boolean> {\n    return false;\n  }\n\n  /**\n   * Max rows per batch for bulk inserts.\n   * Some databases limit multi-row insert size; override in dialect when a lower limit is required.\n   */\n  getBatchInsertSize(): number {\n    return 1000;\n  }\n\n  /**\n   * Get column type conversion SQL for complex type changes\n   * Override in specific dialects to handle database-specific conversions\n   * @param currentType - The current database data type\n   * @param targetType - The target Strapi type\n   * @returns Conversion SQL details or null if no special handling needed\n   */\n  getColumnTypeConversionSQL(\n    // eslint-disable-next-line @typescript-eslint/no-unused-vars\n    currentType: string,\n    // eslint-disable-next-line @typescript-eslint/no-unused-vars\n    targetType: string\n  ): { sql: string; typeClause: string; warning?: string } | null {\n    return null;\n  }\n}\n"],"names":["Dialect","configure","conn","initialize","_nativeConnection","getTables","Error","getSqlType","type","canAlterConstraints","usesForeignKeys","useReturning","supportsUnsigned","supportsOperator","startSchemaUpdate","endSchemaUpdate","transformErrors","error","message","canAddIncrements","canRenameSchemaObjects","renameSchemaObject","trx","params","dropSchemaObject","getBatchInsertSize","getColumnTypeConversionSQL","currentType","targetType","db","client","schemaInspector"],"mappings":"AAYe,MAAMA,OAAAA,CAAAA;;IAanBC,SAAAA,CAAUC,IAAU,EAAE,CAAC;;IAGvB,MAAMC,UAAAA,CAAWC,iBAA2B,EAAE;;AAE9C,IAAA;IAEAC,SAAAA,GAAY;AACV,QAAA,MAA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