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

feat: dollar-quoted strings support #772

Merged
merged 8 commits into from Dec 29, 2022

Conversation

vasilev-alex
Copy link
Contributor

@vasilev-alex vasilev-alex commented Dec 27, 2022

Previously, there was the DoubleDollarQuoting token, and it was used only in the context of functions. But technically, dollar-quoting is another way to present strings.
e.g.

SELECT $$Hello, World!$$;
SELECT $tag_name$Hello, World!$tag_name$;

That's why I think it's reasonable to introduce the DollarQuotedString token, which can hold such string values and their optional tag names.

I have not added any tests yet but will do it if otherwise, it looks ok.

Closes #698

@coveralls
Copy link

coveralls commented Dec 27, 2022

Pull Request Test Coverage Report for Build 3799814922

  • 99 of 113 (87.61%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.06%) to 86.032%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/parser.rs 3 4 75.0%
src/ast/value.rs 5 7 71.43%
src/tokenizer.rs 45 56 80.36%
Totals Coverage Status
Change from base Build 3795207804: 0.06%
Covered Lines: 13095
Relevant Lines: 15221

💛 - Coveralls

Copy link
Collaborator

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @vasilev-alex
The basic idea looks good to me. I think with some tests it would be 👍

@alamb
Copy link
Collaborator

alamb commented Dec 28, 2022

Marking as draft to signify it is waiting on tests -- please mark as ready to review when it is

@alamb alamb marked this pull request as draft December 28, 2022 13:27
@vasilev-alex vasilev-alex marked this pull request as ready for review December 28, 2022 20:50
Copy link
Collaborator

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thanks @vasilev-alex -- this is looking close

tests/sqlparser_postgres.rs Outdated Show resolved Hide resolved
src/tokenizer.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Awesome -- thank you @vasilev-alex

if prev == Some('$') {
if ch == '$' {
chars.next();
is_terminated = true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

tag: None,
value: "Foo$Bar".into(),
})),
alias: Ident {
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

@alamb alamb merged commit 072ccc0 into sqlparser-rs:main Dec 29, 2022
@vasilev-alex vasilev-alex deleted the dollar-quoted-strings branch December 29, 2022 13:34
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.

Support Postgresql dollar-quoted string $$constant$$
3 participants