ADSQLParser

public class ADSQLParser

Parses a SQL statement into an Action Data SQL Document Object Model (DOM). This parser currently supports a subset of SQL commands as defined by SQLite. for example:

let sql = """
CREATE TABLE IF NOT EXISTS parts
(
    part_id           INTEGER   PRIMARY KEY,
    stock             INTEGER   DEFAULT 0   NOT NULL,
    description       TEXT      CHECK( description != '' )    -- empty strings not allowed
);
"""

let instructions = try ADSQLParser.parse(sql)
print(instructions)
  • Attempts to parse the given string into an Action Data SQL DOM. This parser currently supports a subset of SQL commands as defined by SQLite. For exmaple:

    let sql = "SELECT * FROM parts WHERE part_id = 10"
    
    let instructions = try ADSQLParser.parse(sql)
    print(instructions)
    

    Remark

    This function will throw a ADSQLParseError if it encounters an issue while parsing the input string.

    Declaration

    Swift

    public static func parse(_ sql: String) throws -> [ADSQLInstruction]

    Parameters

    sql

    The SQL instruction to parse.

    Return Value

    A list of ADSQLInstruction instances representing the DOM for the given SQL instruction.