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

Parser fix, only allow ORDER BY ASC and ORDER BY time ASC #3409

Merged
merged 1 commit into from
Jul 21, 2015

Conversation

gunnaraasen
Copy link
Member

Fixes #3380, which was introduced in #2912, which itself was a fix for #2731.

This PR makes the parser accept ORDER BY ASC and ORDER BY time ASC as the only valid ORDER BY clauses. All other ORDER BY clauses will return an error.

This also adds some parsing logic for ORDER BY clauses and fixes SortField.String() to output correctly so the query can be rewritten correctly in the rewriteSelectStatement step of the query executor.

@otoolep
Copy link
Contributor

otoolep commented Jul 21, 2015

+1

return nil, errors.New("only ORDER BY time ASC supported at this time")
}
return append(fields, &SortField{Ascending: (tok == ASC)}), nil
} else if tok != IDENT && tok != STRING {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should only accept IDENT. ORDER BY "foo" ASC is okay but not ORDER BY 'foo' ASC.

if tok != IDENT && tok != STRING {
return nil, newParseError(tokstr(tok, lit), []string{"identifier"}, pos)
}
field.Name = lit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The // Scan for IDENT... line through field.Name = lit should be changed to...

    // Parse field name
    ident, err := p.parseIdent()
    if err != nil {
        return nil, err
    }
    field.Name = ident

@gunnaraasen
Copy link
Member Author

@dgnorton made the parseIdent change.

@dgnorton
Copy link
Contributor

+1

gunnaraasen added a commit that referenced this pull request Jul 21, 2015
Parser fix, only allow ORDER BY ASC and ORDER BY time ASC
@gunnaraasen gunnaraasen merged commit dcc3735 into master Jul 21, 2015
@gunnaraasen gunnaraasen deleted the ga-fix-3380 branch July 21, 2015 19:17
@gunnaraasen gunnaraasen mentioned this pull request Jul 24, 2015
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

Successfully merging this pull request may close these issues.

[0.9.2-rc1] : ORDER BY asc giving error: "only ORDER BY ASC supported at this time"
3 participants