Polyglot SQL API Documentation - v0.8.1
    Preparing search index...

    Function transpile

    • Transpile SQL from one dialect to another.

      Parameters

      • sql: string

        The SQL string to transpile

      • read: Dialect

        Source dialect to parse the SQL with

      • write: Dialect

        Target dialect to generate SQL for

      • Optionaloptions: TranspileOptions

      Returns TranspileResult

      The transpiled SQL statements

      The published npm package includes all supported dialects. Use getDialects to inspect the dialects available in the loaded WASM module.

      const result = transpile(
      "SELECT IFNULL(a, b)",
      Dialect.MySQL,
      Dialect.PostgreSQL,
      );
      // result.sql[0] = "SELECT COALESCE(a, b)"