-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
2
Problem Statement/Rationale
Using use (or any other keyword) in multiline input (either with a file or just inputting a multiline string in Compass shell for example) in shell is not working and behavior is inconsistent based on where the statement is in the code
Steps to Reproduce
Try evaluating the following scripts in mongosh from a file or in Compass by just pasting them:
use test123;
print('hello!');
print('hello'); use test123; print('goodbye');
Expected Results
Both scripts work and evaluate all the lines Based on the discussion with massimiliano.marcon we don't want to support this syntax in scripts. In that case it would probably be more reasonable that both scripts throw an error, suggesting an alternative/fix for the issue (e.g., `use <db>;` is not supported in multiline inputs, please use `use('<db>');` instead or something like that)
Actual Results
First script will switch the database to test123 and stop
Second script will fail with babel parsing error