Skip to content

Preserve double colon casts (and simplify cast representations)#1221

Merged
alamb merged 1 commit intoapache:mainfrom
jmhain:preserve-double-colon-cast
Apr 21, 2024
Merged

Preserve double colon casts (and simplify cast representations)#1221
alamb merged 1 commit intoapache:mainfrom
jmhain:preserve-double-colon-cast

Conversation

@jmhain
Copy link
Copy Markdown
Contributor

@jmhain jmhain commented Apr 14, 2024

It's been a slight annoyance to me that :: casts are converted to CAST()-style casts when rewriting SQL using this crate, so this PR makes it so we preserve the cast syntax used in the AST. We also had three AST nodes for CAST, TRY_CAST, and SAFE_CAST which didn't seem necessary, so I reduced this to just Expr::Cast with a kind field that determines the particular syntax / mode of cast used.

This change seems to be well covered by existing tests, but let me know if you have any suggestions for additional tests I could add here.

@coveralls
Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 8680999989

Details

  • 37 of 45 (82.22%) changed or added relevant lines in 5 files are covered.
  • 5 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.03%) to 88.061%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/parser/mod.rs 9 11 81.82%
src/ast/mod.rs 10 16 62.5%
Files with Coverage Reduction New Missed Lines %
src/parser/mod.rs 5 82.86%
Totals Coverage Status
Change from base Build 8660968190: -0.03%
Covered Lines: 21273
Relevant Lines: 24157

💛 - Coveralls

@iffyio
Copy link
Copy Markdown
Contributor

iffyio commented Apr 17, 2024

LGTM! cc @alamb

@alamb
Copy link
Copy Markdown
Contributor

alamb commented Apr 21, 2024

Thanks @jmhain and @iffyio 🚀

@alamb alamb merged commit d1f67bd into apache:main Apr 21, 2024
@jmhain jmhain deleted the preserve-double-colon-cast branch April 21, 2024 15:32
JichaoS pushed a commit to luabase/sqlparser-rs that referenced this pull request May 7, 2024
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.

4 participants