-
Notifications
You must be signed in to change notification settings - Fork 9
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
Added hint when using function as procedure and vice versa #322
Conversation
🦋 Changeset detectedLatest commit: aee377b The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
packages/language-support/src/syntaxValidation/syntaxValidation.ts
Outdated
Show resolved
Hide resolved
packages/language-support/src/syntaxValidation/syntaxValidation.ts
Outdated
Show resolved
Hide resolved
packages/language-support/src/syntaxValidation/syntaxValidation.ts
Outdated
Show resolved
Hide resolved
packages/language-support/src/tests/syntaxValidation/functionsValidation.test.ts
Show resolved
Hide resolved
@@ -59,6 +59,42 @@ meaning that it expects at least 3 arguments of types NODE, STRING, ANY | |||
]); | |||
}); | |||
|
|||
test('Syntax validation error on procedure used as function returns helpful message', () => { | |||
const query = `RETURN apoc.create.uuids(50)`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conversely, we should add a test to check
RETURN APOC.create.uuids(50)
would just say the function is not in the database, but not that the procedure is (because procedures are case sensitive)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented this now, but then got to thinking.. probably any time someone writes strings that match procedure names except for the wrong case, they actually mean the procedure name, so maybe the better solution is to suggest the procedure name with correct case? (so case-insensitive check + case-correct suggest)
Edit: The proposed version here is a little messier than I thought, and I suppose we could (very unlikely) get 2 procedures that are only different in case, which would give ambiguity here, so think ill leave as is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested out in the codemirror playground - working for me nicely 👍
Will yield errors like:
CALL abs(-50) YIELD *
-> Procedure abs is not present in the database. Did you mean to call the function abs? Only procedures can be called inside a CALL clause.and
RETURN apoc.create.uuids(50)
-> Function apoc.create.uuids is not present in the database. Did you mean to call the procedure apoc.create.uuids? Procedures must be called inside a CALL clause.Instead of the regular "Procedure/Function is not present in the database"-messages.