0

This line in my JS file:

RedQueryBuilderFactory.create(config, 
  'SELECT "x0"."title", "x0"."priority" FROM "ticket" "x0" WHERE ("x0"."status" = (?))',
  []
);

works fine witih an empty array as the 3rd parameter. This parameter is supposed to be an array of strings according to the documentation and any sample code I can find. When I pass a string in the array it fails:

RedQueryBuilderFactory.create(config, 
  'SELECT "x0"."title", "x0"."priority" FROM "ticket" "x0" WHERE ("x0"."status" = (?))',
  ['in_process']
);

I get java.lang.ClassCastException in the Safari console. Here's the related part of the config if it's relevant:

var config = {
    meta : {
        tables : [ {
            "name" : "ticket",
            "label" : "Ticket",
            "columns" : [ {
                "name" : "title",
                "label" : "Title",
                "type" : "STRING",
                "size" : 255
            }, {
                "name" : "priority",
                "label" : "Priority",
                "type" : "REF"
            }  ],
            fks : []
        } ],

        types : [ {
            "name" : "REF",
            "editor" : "SELECT",
            "operators" : [ {
                "name" : "IN",
                "label" : "any of",
                "cardinality" : "MULTI"
            }]
        }  ]
    }
};
Matt S
  • 14,976
  • 6
  • 57
  • 76

1 Answers1

1

Looks like this is a bug in passing in parameter values. Internally it is expecting a collection but this is not happening.

Best if you raise a https://github.com/salk31/RedQueryBuilder bug report here?

NB Should be "IN" not "="

salk31
  • 995
  • 2
  • 8
  • 13
  • The output of the query builder arguments is always an array of strings (one for each query param whatever the field type). So ideally it should take the same argument list back in that it puts out. I'll fill out a bug report. – Matt S Oct 17 '13 at 13:41
  • You are right. Internally might be an array but for SQL input/output it should get expanded to extra ? and simple values. Doh. – salk31 Oct 17 '13 at 18:11