[ic] Excact match don't works on searches for empty values - how do error handling in the page?

interchange-users@interchange.redhat.com interchange-users@interchange.redhat.com
Sat Oct 6 11:38:01 2001


On Sat, Oct 06, 2001 at 04:57:45PM +0200, Steffen Dettmer wrote:
> Hi, 
> 
> imagine the following data:
> 
> playdb=> select * from test;
>  id | group_id |  info
> ----+----------+--------
>   1 |        0 | null
>   2 |        1 | eins
> 
> Now I tried a [loop search] the get a list of all infos for a
> given group_id into some <table>:
> 
>   [comment]debug: overwriting group_id[/comment]
>   [set group_id]0[/set]
> 
>   [loop search="ra=no/fi=test/em=yes/se=[scratch group_id]/sf=group_id"]
>     <tr>
>       <td> [loop-code]                </td>
>       <td> [loop-data test group_id]  </td>
>       <td> [loop-data test info]      </td>
>     </tr>
>   [/loop]
> 
> This works. If I [set] it to 1, it works (returns right values).
> Even if I [set]0 [/set] it works (returns nothing) as expected on
> mv_exact_match=yes. But on [set group_id][/set] it fails and
> returns _all_ records; it looks like "" matches no anything. 
> I configured "Database test numeric group_id". So I would expect
> some error when [scratch group_id] is non-numeric - in error.log
> it's found as "> You had no search string specified.", but of
> course I need it in the page. Is there a [onerror] like
> possibility?
> 
> What do I am missing?


die "Pathological group_id ($group_id)" unless($group_id);
die "group_id ($group_id) not in range" unless($group_id=~/^\d\d\d\d\d\d$/);

YMMV

> 
> BTW, another question. In this search, is the condition evaluated
> by the database or are all records fetched and evaluated by
> interchange? It looks like the second, since the database
> evaluates i.e. : "select * from test where group_id = ''" as
> matching on zero (PostgreSQL pg_atoi() function returns zero [and
> no error] for ''). But this would be bad, since no indexes would
> improve speed and a lot of useless data would transferred over
> the network. 

???  I don't understand that.  I'd suggest you would want to index
on anything by which you select.

> 
> oki,
> 
> Steffen
> 
> -- 
> Dieses Schreiben wurde maschinell erstellt,
> es tr?gt daher weder Unterschrift noch Siegel.
> _______________________________________________
> interchange-users mailing list
> interchange-users@interchange.redhat.com
> http://interchange.redhat.com/mailman/listinfo/interchange-users

-- 

Christopher F. Miller, Publisher                               cfm@maine.com
MaineStreet Communications, Inc           208 Portland Road, Gray, ME  04039
1.207.657.5078                                         http://www.maine.com/
Content/site management, online commerce, internet integration, Debian linux