Member Junction
    Preparing search index...

    Interface for a single conversion rule.

    Rules are applied to statements that match their AppliesTo list. They can pre-process (before sqlglot), post-process (after sqlglot), or fully bypass sqlglot by setting BypassSqlglot = true.

    interface IConversionRule {
        AppliesTo: StatementType[];
        BypassJustification?: string;
        BypassSqlglot?: boolean;
        Name: string;
        Priority: number;
        SourceDialect: string;
        TargetDialect: string;
        PostProcess?(
            sql: string,
            originalSQL: string,
            context: ConversionContext,
        ): string;
        PreProcess?(sql: string, context: ConversionContext): string;
    }

    Implemented by

    Index

    Properties

    AppliesTo: StatementType[]

    Statement types this rule applies to

    BypassJustification?: string

    If BypassSqlglot is true, this field documents WHY sqlglot is bypassed. Intended audience: future maintainers deciding whether the bypass is still needed (e.g., after a sqlglot upgrade). Should describe:

    • What sqlglot fails to handle for this statement type
    • The specific T-SQL → PG transformation we need that sqlglot doesn't produce
    • A link to an upstream sqlglot issue if applicable

    Required when BypassSqlglot is true. Helps with the architecture goal of "SQLGlot handles >90% of statements" by making the bypass surface auditable.

    BypassSqlglot?: boolean

    If true, this rule handles conversion entirely — skip sqlglot. The PostProcess method receives the original SQL as both parameters.

    Name: string

    Human-readable name for logging/debugging

    Priority: number

    Priority — lower numbers run first (default: 100)

    SourceDialect: string

    Source SQL dialect this rule converts from (e.g., 'tsql')

    TargetDialect: string

    Target SQL dialect this rule converts to (e.g., 'postgres')

    Methods

    • Transform SQL AFTER sqlglot transpilation.

      Parameters

      • sql: string

        The sqlglot-transpiled SQL (or original if BypassSqlglot)

      • originalSQL: string

        The original T-SQL statement

      • context: ConversionContext

        Shared conversion context

      Returns string

      The final converted SQL