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

Parse function bodies and sql strings #34

Open
psteinroe opened this issue Sep 15, 2023 · 0 comments
Open

Parse function bodies and sql strings #34

psteinroe opened this issue Sep 15, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@psteinroe
Copy link
Collaborator

psteinroe commented Sep 15, 2023

Postgres parses sql strings such as execute 'select 1'; and function bodies, e.g.

CREATE FUNCTION dup(in int, out f1 int, out f2 text)
    AS $$ SELECT $1, CAST($1 AS text) || ' is text' $$
    LANGUAGE SQL;

as string constants. To improve dx, especially for function bodies, we should pass the string back into the SourceParser.

A few things to consider here:

  • refactor SourceFileParser to SourceParser, and pub fn parse_source_file(&mut self, text: &str) to pub fn parse_source(&mut self, text &str, at_offset: Option<i32>), similar to how the statement parser is designed (done)
  • we have to find a way to make a distinction between a sql string, and a normal string. I would propose to just parse any string constant, and if does not return an error use replace it with the sub-tree.
@psteinroe psteinroe added the bug Something isn't working label Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant