Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    whereClause "IN" error

    Hello,

    I am using an operationBinding with a ansiJoinClause and whereClause. I have a custom field that is type integer and labeled as customSQL="true".
    When I pass in an advancedCriteria into the whereClause,

    (example) <whereClause>($defaultWhereClause) AND TB.column IN ($advancedCriteria.customField)</whereClause>

    I get an array wrapped inside a string (ex. '[number, number...]' ) which results in a bad criteria return. I set the criteria as a Long array.
    Is this a bug in the framework or I'm I doing something wrong?

    Best regards.
    Last edited by zhene; 3 Nov 2020, 09:28.

    #2
    SQL templating is done via Velocity per docs, so you are seeing what Velocity does with an Array.

    It's not clear why you're doing this via SQL templating, since you can just add the criteria you have in mind, client or server - SetCriterion is the server class. If you don't want this particular field to be used for any other operations, you can use customCriteriaFields to turn on automatic SQL generation just for this operation.

    You could also get the SQL generated for you using SQLDataSource.getSQLClause(where), passing in a request that has just the IN_SET operator.

    Once you have the SQL string you want, whether you used getSQLClause() or you're own Java code to create it, and just use dsRequest.addToTemplateContext() to make it available inside <whereClause> and other SQL templates.

    Comment

    Working...
    X