Class SQLDialectAbstract

Abstract class defining a particular dialect of SQL that is used to render query builders to strings of SQL of that dialect for execution by Connection instances.

Hierarchy

Constructors

Accessors

Methods

  • Get the method with the given name from this class, bound to this class.

    Returns

    function

    Parameters

    • methodName: string

    Returns ((...args: any[]) => any)

      • (...args: any[]): any
      • Get the method with the given name from this class, bound to this class.

        Returns

        function

        Parameters

        • Rest ...args: any[]

        Returns any

  • Call the make() method on the global container.

    Type Parameters

    • T

    Parameters

    • target: any
    • Rest ...parameters: any[]

    Returns T

  • Given a table schema-builder, render a series of queries as a transaction that apply the given schema to database.

    Todo

    handle constraints better - ConstraintBuilder

    Parameters

    Returns string

  • Given an array of Constraint objects, render them as WHERE-clause SQL in this dialect.

    This function should escape the values before they are included in the query string.

    Example

    dialect.renderConstraints([
    {
    field: 'id',
    operator: '<',
    operand: 44,
    preop: 'AND',
    },
    {
    field: 'id',
    operator: '>',
    operand: 30,
    preop: 'AND',
    },
    ]) // => 'id < 44 AND id > 30'

    Parameters

    Returns string

  • Wrap the given query string as a "SELECT ..." query that returns the number of rows matched by the original query string.

    The resultant query should return the extollo_render_count field with the number of rows that the original query would return.

    Parameters

    • query: string

    Returns string

  • Render the given query builder as a query that can be used to test if at least 1 row exists for the given builder.

    The resultant query should return at least 1 row if that condition is met, and should return NO rows otherwise.

    This function should escape the values before they are included in the query string.

    Example

    The PostgreSQL dialect achieves this by removing the user-specified fields, select-ing TRUE, and applying LIMIT 1 to the query. This returns a single row if the constraints have results, and nothing otherwise.

    Parameters

    Returns string

  • Given a rendered "SELECT ..." query string, wrap it such that the query will only return the rows ranging from the start to end indices.

    Parameters

    • query: string
    • start: number
    • end: number

    Returns string

  • Render the table-column definitions for the table defined by the given schema-builder.

    Example

    dialect.renderTableColumns(builder)
    // => ['col1 varchar(100) NULL', 'col2 serial NOT NULL']

    Parameters

    Returns string[]

  • Given a series of fully-formed queries, render them as a single transaction.

    Example

    const queries = [
    'SELECT * FROM a',
    'UPDATE b SET col = 123',
    ]

    dialect.renderTransaction(queries)
    // => 'BEGIN; SELECT * FROM a; UPDATE b SET col = 123; COMMIT;'

    Parameters

    • queries: string[]

    Returns string

  • Render the given query builder as an "UPDATE ..." query string, setting the column values from the given data object.

    This function should escape the values before they are included in the query string.

    Parameters

    Returns string

  • Render the "SET ... [field = value ...]" portion of the update query.

    This function should escape the values before they are included in the query string.

    Example

    dialect.renderUpdateSet({field1: 'value', field2: 45})
    // => "SET field1 = 'value', field2 = 45"

    Parameters

    Returns string