Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query formatting between BEGIN and END? #195

Open
swillits opened this issue Aug 3, 2015 · 1 comment
Open

Query formatting between BEGIN and END? #195

swillits opened this issue Aug 3, 2015 · 1 comment

Comments

@swillits
Copy link

swillits commented Aug 3, 2015

It seems like no formatting is done for the query between BEGIN and END.

sql = """CREATE FUNCTION a(x VARCHAR(20)) RETURNS VARCHAR(20)
BEGIN
DECLARE y VARCHAR(20);
IF (1 = 1) THEN
SET x = y;
END IF;
RETURN x;
END;
"""
print sqlparse.format(sql, reindent=True,indent_width="4",indent_tabs=True);

When the above is formatted, it simply spits out:

CREATE FUNCTION a(x VARCHAR(20)) RETURNS VARCHAR(20) BEGIN DECLARE y VARCHAR(20); IF (1 = 1) THEN
SET x = y; END IF; RETURN x; END;

While I am expecting something like:

CREATE FUNCTION a(x VARCHAR(20)) RETURNS VARCHAR(20)
    BEGIN
        DECLARE y VARCHAR(20);
        IF (1 = 1) THEN
            SET x = y;
        END IF;
        RETURN x;
    END;
@harveyadcock
Copy link

This is still an issue in the latest release.

ovr pushed a commit to cube-js/sqlparse that referenced this issue Dec 26, 2020
This simplifies codes slightly, removing the need deal with the EOF case explicitly.

The clone kludge in `_ => self.expected("date/time field",
Token::Word(w.clone())))` will become unnecessary once we stop using
a separate match for the keywords, as suggested in
https://github.com/andygrove/sqlparser-rs/pull/193#issuecomment-641607194
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants