-
Notifications
You must be signed in to change notification settings - Fork 566
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
Create test pattern for Spans #1563
Comments
@lustefaniak , given your comments on
I wonder if you have any suggestions here (or maybe a code pointer for the downstream tests that we could possible start looking at?) |
Hi! Just a small note since I started playing around with this. I assume it's because it's not implemented yet but anyway to keep track: it seems currently that Function args don't have a span, and also the Function span only covers the function name, not its arguments and parentheses. So for /edit to add: I guess it's because Very tangential, it would be useful if there was a helper function to convert line-column-based locations to byte offsets. (My use case is implementing a fixer without rebuilding the SQL from the AST, just applying fixes locally to individual nodes in the source text to keep unaffected parts unchanged in the original format.) |
Hi @alamb, what I did downstream couldn't be ported immediately as it is a much higher level testing, which I think might not work well in the low-level library. I work on the result of the AST analysis, storing locations into higher-level concepts like columns and dependency chains. Categorising locations into specific categories:
I assert that the captured "location" is precisely a specific string.
On the one hand, it is a very high level without looking into details of all the AST nodes; on the other hand, I found working with line/char super hard to grasp and error-prone and led to not the level of testing I wanted. Ultimately, I wanted the best experience for our users, and snipped-based testing worked pretty well. |
@graup Yes you are right. There is a lot of missing cases like these. For FunctionArgumentList, adding the parenthesis as AttachedToken would be straight forward and should be done. I never quite figured out what the best to do it for enum tuple variants like Subquery is though.
Yeah this is definitely the Span for Value missing. Getting that in is pretty high priority imo. |
Thanks for the reply @Nyrox . It seems if we just implement AttachedToken for FunctionArgumentList's parentheses, the missing spans for Value wouldn't matter much for my case, as the union'ed Function span including the right parenthesis would also include anything between the function name and the right parenthesis. I looked into the code a bit and understand your struggle, somehow |
Part of #1548
Usecase
Spanned
to retrieve source locations on AST nodes #1435We would like to add span information through out the rest of the AST structures (see docs in #1549) and list on #1548
In order to support this feature reasonably, we need to be able to test the feature and avoid regressions
Proposal
I think we need some sort of span test.
I recommend
tests/sqlparser_spans.rs
Then add a test that
I think we'll have to use judgement on how fine grained the location information
can / should be.
The text was updated successfully, but these errors were encountered: