Skip to content

feat: dollar-quoted strings support#772

Merged
alamb merged 8 commits into
apache:mainfrom
vasilev-alex:dollar-quoted-strings
Dec 29, 2022
Merged

feat: dollar-quoted strings support#772
alamb merged 8 commits into
apache:mainfrom
vasilev-alex:dollar-quoted-strings

Conversation

@vasilev-alex

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

Copy link
Copy Markdown
Contributor

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

coveralls commented Dec 27, 2022

Copy link
Copy Markdown

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

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

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

alamb commented Dec 28, 2022

Copy link
Copy Markdown
Contributor

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
@vasilev-alex vasilev-alex requested a review from alamb December 28, 2022 20:50

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

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

Comment thread tests/sqlparser_postgres.rs Outdated
Comment thread src/tokenizer.rs Outdated
@vasilev-alex vasilev-alex requested a review from alamb December 29, 2022 10:12

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

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

Comment thread src/tokenizer.rs
if prev == Some('$') {
if ch == '$' {
chars.next();
is_terminated = true;

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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 apache: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