Question
I am using the
DatabasePlugin (version 1.3) and I am doing a "DATABASE_SQL_REPEAT". Within this "tag" I am doing a "DATABASE_SQL_TABLE".
When I do this, I use the result of the "repeat" as an input to the command in the "table" tag.
The problem is that the plugin doesn't seem to be expanding the %var% in the "table" tag. I was wondering if there was a way to do this.
A contrived example:
%DATABASE_SQL_REPEAT{description="db" columns="id, date" command="select id, date from atable where status='done'"}%
%date%
%DATABASE_SQL_TABLE{description="db" headers="Name, Details" command="select name, details from atable where id = %id% order by details desc"}%
%DATABASE_SQL_REPEAT%
So, in this example, the "%id%" is passed straight to the db, and this error is seen in the browser: DBD::mysql::st execute failed: You have an error in your SQL syntax near '%id% order by details desc' at line 1 at /usr/share/perl5/TWiki/Plugins/DatabasePlugin.pm line 336.
Environment
--
TrevorGlen - 15 May 2004
Answer
I fixed this by changing the order of evaluation in
DatabasePlugin.pm:
574d573
< $_[0] =~ s/%DATABASE_SQL_REPEAT{(.*?)}%(.*?)%DATABASE_SQL_REPEAT%/&do_sql_repeat($1, $2)/seog;
577a577
> $_[0] =~ s/%DATABASE_SQL_REPEAT{(.*?)}%(.*?)%DATABASE_SQL_REPEAT%/&do_sql_repeat($1, $2)/seog;
This is not really an acceptable fix (eg if a DATABASE_SQL_REPEAT occurs within a DATABASE_REPEAT). I haven't thought about how to implement this properly, but it works for my purposes.
Should the status be changed to "AnsweredQuestions"?
--
TrevorGlen - 13 Aug 2004