Fix derive_dialect! proc macro for use from external crates#2219
Open
alexander-beedie wants to merge 1 commit intoapache:mainfrom
Open
Fix derive_dialect! proc macro for use from external crates#2219alexander-beedie wants to merge 1 commit intoapache:mainfrom
derive_dialect! proc macro for use from external crates#2219alexander-beedie wants to merge 1 commit intoapache:mainfrom
Conversation
77e405f to
f8cb6b0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Unfortunately I made a classic proc-macro blunder in #2174, forgetting that
$CARGO_MANIFEST_DIRpoints to the crate being compiled, which is not thesqlparsercrate. So all the tests worked (as the crate being compiled and thesqlparsercrate are the same), but actual use from an external crate fails (without exotic workarounds) 😅This PR fixes and industrialises the source lookup; now it does the following (documented/explained in the code too):
$CARGO_MANIFEST_DIR/src/dialect/mod.rs: works when macro invoked from within thesqlparsercrate (e.g. tests).<sqlparser_derive dir>/../src/dialect/mod.rs: works whensqlparser_derivelives in a workspace alongside the main crate (standardderive/layout).sqlparser_derivecrate in the Cargo registry: works when an external crate usesderive_dialect!via registry dependency.Confirmed this addresses the issue, and dialects can now be properly derived in/from external crates 👍
Also: minor tweak to use slightly more idiomatic
map_err!insidederive_dialect.