[SERVER-2095] console returning an error for lines terminated in equals (=) Created: 15/Nov/10  Updated: 12/Jul/16  Resolved: 06/Dec/10

Status: Closed
Project: Core Server
Component/s: JavaScript
Affects Version/s: 1.6.3, 1.6.4
Fix Version/s: 1.7.4

Type: Bug Priority: Major - P3
Reporter: Justin Dearing Assignee: Tony Hannan
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 7


Operating System: ALL
Participants:

 Description   

If I put the following jacascript in the console:
var SomeEvent = db.events.findOne(

{ Name: 'Some stupid event' }

);
SomeEvent.Summary =
"Some Text.\r\n\r\n" +
"Some more text.";
db.events.save(SomeEvent);
db.events.findOne(

{ Name: 'Some stupid event' }

);
I get the following:
> var SomeEvent = db.events.findOne(

{ Name: 'Some stupid event' }

);
> SomeEvent.Summary =

Expected behavior of the shell would be to hold the line ending in equals in a buffer and append the next line to it before executing.



 Comments   
Comment by auto [ 06/Dec/10 ]

Author:

{'login': 'TonyGen', 'name': 'Tony Hannan', 'email': 'tony@10gen.com'}

Message: SERVER-2095: Small enhancement to previous commit
/mongodb/mongo/commit/b7eaac286e4798c3f38250d2fe1b4baf84e221c3

Comment by Tony Hannan [ 06/Dec/10 ]

Shell now requests another line when user enters a line with a dangling operator. Eg. 'x = 1 +' will request more input.

Comment by auto [ 06/Dec/10 ]

Author:

{'login': 'TonyGen', 'name': 'Tony Hannan', 'email': 'tony@10gen.com'}

Message: SERVER-2095: Shell requests another line when user enters a line with a dangling operator. Eg. 'x = 1 +' will request more input
/mongodb/mongo/commit/1f02e078caf8adf86c651130977454cbddcb5be9

Comment by Kristina Chodorow (Inactive) [ 30/Nov/10 ]

Rhino precedent:

js> x=
> 3
3

Comment by Justin Dearing [ 30/Nov/10 ]

Mongo will buffer if you have unmatched ", ', (, {, or [ characters so why not the same for an equals sign. So it seems a reasonable expectation to do the same with a line terminated by a binary operator.

As far as behavior matching, I'm actually looking more towards the RDBMs console client behavior. postgres and mysql don't assume batching or transactions by default and buffer until the semicolon. Javascript consoles can't match that behavior perfectly since semicolons are (semi)optional in javascript, but I think its the right model for a javascript console for a RDBMS.

If you still want JavaScript console precedent let me know and I'll look for it.

Comment by Tony Hannan [ 30/Nov/10 ]

Why do you expect this buffering behavior? Do other javascript command-line interfaces do this? Can you give some pointers?

Generated at Thu Feb 08 02:58:57 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.