Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-398

Having leading comments in Javascript can break db.eval()

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor - P4
    • Resolution: Fixed
    • None
    • 1.1.4
    • JavaScript
    • None

    Description

      This works:

      > db.eval(/dieinafire/function()

      {return [true];})
      [true]

      As does this:

      > db.eval("function(){return [true];}

      ")
      [true]

      Starting with a string with a comment does not:

      > db.eval("/dieinafire/function()

      {return [true];}

      ")
      null

      mstearn in #mongodb said:

      < mstearn> yup, function literal vs sting with function

      So I guess this is a known behavior. However, it's completely non-
      obvious when you run into it via a client library.

      Is there a way to db.eval() javascript code that starts with a comment
      via pymongo?

      Obviously for now I've just removed the comment, but I wasted an
      afternoon trying to figure out why in the world some perfectly valid
      Javascript wasn't executing.

      Thanks,
      schmichael

      Attachments

        Activity

          People

            eliot Eliot Horowitz (Inactive)
            eliot Eliot Horowitz (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: