---
source: crates/squawk_parser/tests/tests.rs
input_file: crates/squawk_parser/tests/data/ok/prepare.sql
---
SOURCE_FILE
  COMMENT "-- insert"
  WHITESPACE "\n"
  PREPARE
    PREPARE_KW "PREPARE"
    WHITESPACE " "
    NAME
      IDENT "fooplan"
    WHITESPACE " "
    PARAM_LIST
      L_PAREN "("
      PARAM
        PATH_TYPE
          PATH
            PATH_SEGMENT
              NAME_REF
                INT_KW "int"
      COMMA ","
      WHITESPACE " "
      PARAM
        PATH_TYPE
          PATH
            PATH_SEGMENT
              NAME_REF
                TEXT_KW "text"
      COMMA ","
      WHITESPACE " "
      PARAM
        PATH_TYPE
          PATH
            PATH_SEGMENT
              NAME_REF
                IDENT "bool"
      COMMA ","
      WHITESPACE " "
      PARAM
        PATH_TYPE
          PATH
            PATH_SEGMENT
              NAME_REF
                NUMERIC_KW "numeric"
      R_PAREN ")"
    WHITESPACE " "
    AS_KW "AS"
    WHITESPACE "\n    "
    INSERT
      INSERT_KW "INSERT"
      WHITESPACE " "
      INTO_KW "INTO"
      WHITESPACE " "
      PATH
        PATH_SEGMENT
          NAME_REF
            IDENT "foo"
      WHITESPACE " "
      VALUES
        VALUES_KW "VALUES"
        ROW_LIST
          ROW
            L_PAREN "("
            LITERAL
              POSITIONAL_PARAM "$1"
            COMMA ","
            WHITESPACE " "
            LITERAL
              POSITIONAL_PARAM "$2"
            COMMA ","
            WHITESPACE " "
            LITERAL
              POSITIONAL_PARAM "$3"
            COMMA ","
            WHITESPACE " "
            LITERAL
              POSITIONAL_PARAM "$4"
            R_PAREN ")"
  SEMICOLON ";"
  WHITESPACE "\n\n\n\n"
  COMMENT "-- select"
  WHITESPACE "\n"
  PREPARE
    PREPARE_KW "PREPARE"
    WHITESPACE " "
    NAME
      IDENT "usrrptplan"
    WHITESPACE " "
    PARAM_LIST
      L_PAREN "("
      PARAM
        PATH_TYPE
          PATH
            PATH_SEGMENT
              NAME_REF
                INT_KW "int"
      R_PAREN ")"
    WHITESPACE " "
    AS_KW "AS"
    WHITESPACE "\n    "
    SELECT
      SELECT_CLAUSE
        SELECT_KW "SELECT"
        WHITESPACE " "
        TARGET_LIST
          TARGET
            STAR "*"
      WHITESPACE " "
      FROM_CLAUSE
        FROM_KW "FROM"
        WHITESPACE " "
        FROM_ITEM
          NAME_REF
            IDENT "users"
          WHITESPACE " "
          ALIAS
            NAME
              IDENT "u"
        COMMA ","
        WHITESPACE " "
        FROM_ITEM
          NAME_REF
            IDENT "logs"
          WHITESPACE " "
          ALIAS
            NAME
              IDENT "l"
      WHITESPACE " "
      WHERE_CLAUSE
        WHERE_KW "WHERE"
        WHITESPACE " "
        BIN_EXPR
          BIN_EXPR
            BIN_EXPR
              FIELD_EXPR
                NAME_REF
                  IDENT "u"
                DOT "."
                NAME_REF
                  IDENT "usrid"
              EQ "="
              LITERAL
                POSITIONAL_PARAM "$1"
            WHITESPACE " "
            AND_KW "AND"
            WHITESPACE " "
            BIN_EXPR
              FIELD_EXPR
                NAME_REF
                  IDENT "u"
                DOT "."
                NAME_REF
                  IDENT "usrid"
              EQ "="
              FIELD_EXPR
                NAME_REF
                  IDENT "l"
                DOT "."
                NAME_REF
                  IDENT "usrid"
          WHITESPACE "\n    "
          AND_KW "AND"
          WHITESPACE " "
          BIN_EXPR
            FIELD_EXPR
              NAME_REF
                IDENT "l"
              DOT "."
              NAME_REF
                IDENT "date"
            WHITESPACE " "
            EQ "="
            WHITESPACE " "
            LITERAL
              POSITIONAL_PARAM "$2"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  PREPARE
    PREPARE_KW "PREPARE"
    WHITESPACE " "
    NAME
      IDENT "foo"
    WHITESPACE " "
    AS_KW "AS"
    WHITESPACE "\n    "
    SELECT
      WITH_CLAUSE
        WITH_KW "with"
        WHITESPACE " "
        WITH_TABLE
          NAME
            IDENT "t"
          WHITESPACE " "
          AS_KW "as"
          WHITESPACE " "
          L_PAREN "("
          SELECT
            SELECT_CLAUSE
              SELECT_KW "select"
              WHITESPACE " "
              TARGET_LIST
                TARGET
                  LITERAL
                    INT_NUMBER "1"
          R_PAREN ")"
      WHITESPACE "\n    "
      SELECT_CLAUSE
        SELECT_KW "select"
        WHITESPACE " "
        TARGET_LIST
          TARGET
            STAR "*"
      WHITESPACE " "
      FROM_CLAUSE
        FROM_KW "from"
        WHITESPACE " "
        FROM_ITEM
          NAME_REF
            IDENT "t"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  COMMENT "-- update"
  WHITESPACE "\n"
  PREPARE
    PREPARE_KW "prepare"
    WHITESPACE " "
    NAME
      IDENT "foo"
    WHITESPACE " "
    AS_KW "as"
    WHITESPACE "\n  "
    UPDATE
      UPDATE_KW "update"
      WHITESPACE " "
      RELATION_NAME
        PATH
          PATH_SEGMENT
            NAME_REF
              IDENT "foo"
      WHITESPACE " "
      SET_CLAUSE
        SET_KW "set"
        WHITESPACE " "
        SET_COLUMN_LIST
          SET_SINGLE_COLUMN
            COLUMN
              NAME_REF
                IDENT "x"
            WHITESPACE " "
            EQ "="
            WHITESPACE " "
            SET_EXPR
              LITERAL
                INT_NUMBER "1"
      WHITESPACE " "
      WHERE_CLAUSE
        WHERE_KW "where"
        WHITESPACE " "
        BIN_EXPR
          NAME_REF
            IDENT "x"
          WHITESPACE " "
          R_ANGLE ">"
          WHITESPACE " "
          LITERAL
            INT_NUMBER "10"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  COMMENT "-- delete"
  WHITESPACE "\n"
  PREPARE
    PREPARE_KW "prepare"
    WHITESPACE " "
    NAME
      IDENT "foo"
    WHITESPACE " "
    AS_KW "as"
    WHITESPACE "\n  "
    DELETE
      DELETE_KW "delete"
      WHITESPACE " "
      FROM_KW "from"
      WHITESPACE " "
      RELATION_NAME
        PATH
          PATH_SEGMENT
            NAME_REF
              IDENT "foo"
      WHITESPACE " "
      WHERE_CLAUSE
        WHERE_KW "where"
        WHITESPACE " "
        BIN_EXPR
          NAME_REF
            IDENT "x"
          WHITESPACE " "
          EQ "="
          WHITESPACE " "
          LITERAL
            INT_NUMBER "1"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  COMMENT "-- merge"
  WHITESPACE "\n"
  PREPARE
    PREPARE_KW "prepare"
    WHITESPACE " "
    NAME
      IDENT "foo"
    WHITESPACE " "
    AS_KW "as"
    WHITESPACE "\n  "
    MERGE
      MERGE_KW "merge"
      WHITESPACE " "
      INTO_KW "into"
      WHITESPACE " "
      RELATION_NAME
        PATH
          PATH_SEGMENT
            NAME_REF
              IDENT "t1"
      WHITESPACE "\n  "
      USING_ON_CLAUSE
        USING_KW "using"
        WHITESPACE " "
        FROM_ITEM
          NAME_REF
            IDENT "t2"
        WHITESPACE " "
        ON_CLAUSE
          ON_KW "on"
          WHITESPACE " "
          BIN_EXPR
            FIELD_EXPR
              NAME_REF
                IDENT "t2"
              DOT "."
              NAME_REF
                IDENT "id"
            WHITESPACE " "
            EQ "="
            WHITESPACE " "
            FIELD_EXPR
              NAME_REF
                IDENT "t1"
              DOT "."
              NAME_REF
                IDENT "id"
      WHITESPACE "\n  "
      MERGE_WHEN_MATCHED
        WHEN_KW "when"
        WHITESPACE " "
        MATCHED_KW "matched"
        WHITESPACE " "
        THEN_KW "then"
        WHITESPACE " "
        MERGE_DO_NOTHING
          DO_KW "do"
          WHITESPACE " "
          NOTHING_KW "nothing"
      WHITESPACE "\n  "
      MERGE_WHEN_NOT_MATCHED_SOURCE
        WHEN_KW "when"
        WHITESPACE " "
        NOT_KW "not"
        WHITESPACE " "
        MATCHED_KW "matched"
        WHITESPACE " "
        BY_KW "by"
        WHITESPACE " "
        SOURCE_KW "source"
        WHITESPACE " "
        THEN_KW "then"
        WHITESPACE " "
        MERGE_DO_NOTHING
          DO_KW "do"
          WHITESPACE " "
          NOTHING_KW "nothing"
      WHITESPACE "\n  "
      MERGE_WHEN_NOT_MATCHED_TARGET
        WHEN_KW "when"
        WHITESPACE " "
        NOT_KW "not"
        WHITESPACE " "
        MATCHED_KW "matched"
        WHITESPACE " "
        THEN_KW "then"
        WHITESPACE " "
        MERGE_DO_NOTHING
          DO_KW "do"
          WHITESPACE " "
          NOTHING_KW "nothing"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  COMMENT "-- values"
  WHITESPACE "\n"
  PREPARE
    PREPARE_KW "prepare"
    WHITESPACE " "
    NAME
      IDENT "foo"
    WHITESPACE " "
    AS_KW "as"
    WHITESPACE "\n  "
    VALUES
      VALUES_KW "values"
      WHITESPACE " "
      ROW_LIST
        ROW
          L_PAREN "("
          LITERAL
            INT_NUMBER "1"
          COMMA ","
          WHITESPACE " "
          LITERAL
            STRING "'one'"
          R_PAREN ")"
        COMMA ","
        WHITESPACE " "
        ROW
          L_PAREN "("
          LITERAL
            INT_NUMBER "2"
          COMMA ","
          WHITESPACE " "
          LITERAL
            STRING "'two'"
          R_PAREN ")"
  SEMICOLON ";"
  WHITESPACE "\n\n"
