I am using arrays in Postgres. I need to be able to compare a string value in a specific position of a text array field (text[] is a field type in Postgres) against a variable(argument) I am passing to my query. I am only using parts of the query to illustrate the problem as the rest is irrelevant. I replaced the table, field names and arguments with names that might make this more understandable.

First. I am finding arrays work fine with select statements in DTML when you use sqlvar to request a specific value from the array.


a_table.an_array_field[<dtml-sqlvar some_value type="int">][2]
FROM ....(rest of query)

But when you put them inside a sqltest tag for evaluating values it throws an error because DTML cannot parse it.


blah blah.....
<dtml-sqltest column=a_table.an_array_field[<dtml-sqlvar an_array_key type="int">][2] name=a_title_var op="eq" type="string" optional>
..... (rest of query)

The issue is how to test against these values when DTML cannot parse them? My raw sql query works fine giving me the desired results but I cannot construct the statement in DTML.

The part of the query that throws the error is the dtml-sqltest tag (it gives a parsing error). ie.

<dtml-sqltest column=a_db.an_array_field[<dtml-sqlvar an_array_key type="int">][2] name=a_title op="eq" type="string" optional>

should translate to:

a_table.an_array_field[1][2] = 'This is a title' (This is a valid expression for Postgres)

where an_array_key is a variable with value of 1 and a_title is variable with a value of 'This is a title'

The above would give an invalid attribute name error for the an_array_key (variable/argument).

Is this a bug or is there something else I ought to be doing? If this is a limitation of DTML, is there a work around?


Zope maillist  -  Zope@zope.org
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to