CouchDB
  1. CouchDB
  2. COUCHDB-1306

Allow Booleans to be unquoted in Rewrite rules

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.1, 1.2
    • Fix Version/s: None
    • Component/s: None
    • Labels:
    • Skill Level:
      Regular Contributors Level (Easy to Medium)

      Description

      COUCHDB-1074 breaks the JSON format of Rewrite rules requiring that Boolean values always be quoted. This requires additional knowledge for a user to even understand why their JSON doesn't work with CouchDB.

        Activity

        Hide
        Benoit Chesneau added a comment -

        I don't like the term "breaks". "don't work like I expect it should" is more accurate here. Strings are perfectly valid in json.

        The reasoning to use strings here is to handle miscellaneous strings coming from the query argument.

        While using json in query params of the rewrites members is perfectly feasible, it's different when you have to handle strings coming from the query:

        • a params may be a string sometimes or an array in a view, or maybe just a string in a view too :

        eg:
        ?key=%5B1%2C2%5D

        When you aren't rewriting a view. Should it be considered like [1,2] or "[1,2]" or ["1", "2"] ?

        First implementations was considering that everything in the query was json values. It was apparently a problem for some.

        While I have some ideas to solve that, at some point using a format member to define the format of a variable was the simplest and working way to solve that. That what does most of the rewriters even with regexps anyway. (there is btw another implementation I posted on the ml that was badly waiting for reviews ....).

        I have some idea about the rewriter DSL anyway. Just need to connect the bits before posting it.

        Show
        Benoit Chesneau added a comment - I don't like the term "breaks". "don't work like I expect it should" is more accurate here. Strings are perfectly valid in json. The reasoning to use strings here is to handle miscellaneous strings coming from the query argument. While using json in query params of the rewrites members is perfectly feasible, it's different when you have to handle strings coming from the query: a params may be a string sometimes or an array in a view, or maybe just a string in a view too : eg: ?key=%5B1%2C2%5D When you aren't rewriting a view. Should it be considered like [1,2] or " [1,2] " or ["1", "2"] ? First implementations was considering that everything in the query was json values. It was apparently a problem for some. While I have some ideas to solve that, at some point using a format member to define the format of a variable was the simplest and working way to solve that. That what does most of the rewriters even with regexps anyway. (there is btw another implementation I posted on the ml that was badly waiting for reviews ....). I have some idea about the rewriter DSL anyway. Just need to connect the bits before posting it.
        Hide
        Benjamin Young added a comment -

        The "breaks" part came from past, working CouchApps failing due to the COUCHDB-1074 patch. I understand reasoning behind the patch, but breaking past (and perfectly reasonable JSON) rewrite rules that include something like "descending: true" should be considered a bug, and ideally fixed.

        If true booleans can no longer be supported in the rewriter, it would be great to at least throw something in the logs about why its failing. Otherwise, hours go quickly down the drain for something as simple as a pair of quotation marks...

        It wouldn't be so bad if it weren't so frustrating to hunt down.

        Show
        Benjamin Young added a comment - The "breaks" part came from past, working CouchApps failing due to the COUCHDB-1074 patch. I understand reasoning behind the patch, but breaking past (and perfectly reasonable JSON) rewrite rules that include something like "descending: true" should be considered a bug, and ideally fixed. If true booleans can no longer be supported in the rewriter, it would be great to at least throw something in the logs about why its failing. Otherwise, hours go quickly down the drain for something as simple as a pair of quotation marks... It wouldn't be so bad if it weren't so frustrating to hunt down.

          People

          • Assignee:
            Benoit Chesneau
            Reporter:
            Benjamin Young
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:

              Development