Loading ...
Sorry, an error occurred while loading the content.

Is this a bug?

Expand Messages
  • hleogr
    Before filing this as an open issue I would like to check whether this is a bug or not. If I create a db variable with taffy() a run several queries with regex
    Message 1 of 1 , Sep 17, 2012
    • 0 Attachment
      Before filing this as an open issue I would like to check whether this is a bug or not.
      If I create a db variable with taffy() a run several queries with regex method with the db the result is always the first query. Below is a little example what I mean. To run the code you need to place the taffy.js in the same folder as the sample html file below.

      <!DOCTYPE html SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
      <script type="text/javascript" src="taffy.js"/>
      <script type="text/javascript">
      function testMe() {
      var arr = JSON.parse(document.getElementById("input") .textContent);
      var test = {
      query1: new RegExp("tt", "gi"),
      query2: new RegExp("bb", "gi")
      };
      var out = document.getElementById("output");
      var db = TAFFY(arr);
      for (var q in test) {
      var r1 = db({
      "a" : {
      regex:test[q]
      }
      }) .get();
      var r2 = TAFFY(arr)({
      "a" : {
      regex:test[q]
      }
      }) .get();
      var result = "Query result length for RegExp " + test[q] + ": " + r1.length + " Should be: " + r2.length;
      out.appendChild(document.createTextNode(result));
      out.appendChild(document.createElement("br"));
      }
      }</script>
      </head>
      <body>

      <div id="input"> [ {"a":"xxxx"},{"a":"ttt"} ] </div>
      <button onclick="testMe()">Test</button>
      <div id="output"/>
      </body>
      </html>
    Your message has been successfully submitted and would be delivered to recipients shortly.