Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-3033

serializer has bad parameter structure

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: BSON

      https://github.com/mongodb/js-bson/issues/385

      Imho the serializer method heads are bad. The last parameter is isArray but actually all it does is depending if it is true or false it will set the corresponding encoding to ascii or utf8.

      Unable to find source-code formatter for language: const. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
          ? buffer.write(key, index, 'utf8')
          : buffer.write(key, index, 'ascii');
      

      So actually the last parameter is about encoding and not if the input is an array or not. So probably we should rename it to encoding and insert directly if it should be using utf8 or ascii. This should remove a lot of if checks also.

      Also strange is this function call:

      https://github.com/mongodb/js-bson/blob/4c6f2e4f7f39e75274dd12e67d34befb4fd6ea28/lib/parser/serializer.js#L853

      Why is serializeFunctions passed to serializeFunction as parameter isArray?

            Assignee:
            Unassigned Unassigned
            Reporter:
            alexander.golin@mongodb.com Alexander Golin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated: