Member Junction
    Preparing search index...

    Database-agnostic connection interface for CodeGen operations.

    This interface abstracts the underlying database driver (mssql.ConnectionPool, pg.Pool, etc.) so that the orchestration code in SQLCodeGenBase, ManageMetadataBase, and related classes can work with any supported database platform.

    Simple query (no parameters):

    const result = await conn.query("SELECT ID, Name FROM MyTable WHERE Status = Active");
    const rows = result.recordset;

    Parameterized query (safe from SQL injection):

    const result = await conn.queryWithParams(
    "SELECT ID FROM MyTable WHERE Name = @Name AND SchemaName = @Schema",
    { Name: Users, Schema: dbo }
    );

    Stored procedure / function call:

    const result = await conn.executeStoredProcedure(
    "[dbo].[spCreateEntity]",
    { Name: NewEntity, SchemaName: dbo }
    );

    Transaction:

    const tx = await conn.beginTransaction();
    try {
    await tx.query("INSERT INTO ...");
    await tx.query("UPDATE ...");
    await tx.commit();
    } catch (e) {
    await tx.rollback();
    throw e;
    }
    • SQLServerCodeGenConnection wraps mssql.ConnectionPool (in CodeGenLib)
    • PostgreSQLCodeGenConnection wraps pg.Pool (in PostgreSQLDataProvider)
    interface CodeGenConnection {
        Dialect: SQLDialect;
        beginTransaction(): Promise<CodeGenTransaction>;
        executeStoredProcedure(
            name: string,
            params: Record<string, unknown>,
        ): Promise<CodeGenQueryResult>;
        query(sql: string): Promise<CodeGenQueryResult>;
        queryWithParams(
            sql: string,
            params: Record<string, unknown>,
        ): Promise<CodeGenQueryResult>;
    }

    Implemented by

    Index

    Properties

    Dialect: SQLDialect

    The SQL dialect for this connection's platform. Exposes identifier quoting, timestamp expressions, etc. — used by callers (e.g. validator-function emission in EntitySubClassGeneratorBase) that need to author dialect-aware SQL but don't have access to a CodeGenDatabaseProvider instance.

    Methods

    • Executes a stored procedure (SQL Server) or function call (PostgreSQL).

      Parameters

      • name: string

        The fully qualified routine name (e.g., "[dbo].[spCreateEntity]").

      • params: Record<string, unknown>

        Named parameters for the routine.

      Returns Promise<CodeGenQueryResult>

      The query result with a recordset array.

    • Executes a SQL query with named parameters. Parameters are passed as key-value pairs and the implementation is responsible for binding them safely (e.g.,

      Parameters

      • sql: string

        The SQL statement with parameter placeholders.

      • params: Record<string, unknown>

        Named parameters as key-value pairs.

      Returns Promise<CodeGenQueryResult>

      The query result with a recordset array.

      for SQL Server, $1/$2 for PostgreSQL).

      For SQL Server, the parameter names in the SQL should use @-prefix notation matching the keys in the params object. For PostgreSQL, the implementation translates @-prefixed names to $N notation.