Class PostgreSQLDialect

An implementation of the SQLDialect specific to PostgreSQL.

Todo

joins

Todo

sub-selects

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 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

    • allConstraints: Constraint[]
    • startingLevel: number = 1

    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

  • 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 "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