aheber / tree-sitter-sfapex

Tree-sitter implementation for Salesforce's Apex, SOQL, and SOSL
MIT License
69 stars 14 forks source link

`convertTimezone` function seems to be missing in SOQL #18

Closed sam-superframe closed 12 months ago

sam-superframe commented 1 year ago

I was testing out examples from the docs and it seems the SOQL lifted from here generates an ERROR node.

https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_convert_time_zone.htm

SELECT HOUR_IN_DAY(convertTimezone(CreatedDate)), SUM(Amount)
FROM Opportunity
GROUP BY HOUR_IN_DAY(convertTimezone(CreatedDate))

From what I can tell, it looks like it's just that convertTimezone is missing as a possible function.

image
aheber commented 1 year ago

Thanks! When I wrote it I limited it to certain function names, I'm rethinking that decision. You're right I didn't have that one listed, I'm going to change it a bit so it treats function names as a labeled identifier instead of a limited set of string matches.

This will have a bit of a cascade effect, and including some queries. FYI @finxxi once I get this released, when you increment the git hash for NVIM you'll have some query changes to do in that package.

I'll get final details later but I think going to change the "function_name" node type into "identifier" with a "field" name of "function_name."

sam-superframe commented 1 year ago

I think that's a reasonable change. I'm not sure it's the parser's responsibility to ensure that a given function exists or not.

aheber commented 12 months ago

Sorry, @xixiaofinland I was tagging the wrong user yesterday. This and the associated PR will cause the need for query updates.

xixiaofinland commented 12 months ago

got it sir :) @aheber