Forum OpenACS Development: Proposal of new database api function: db_column_size

I've made a new function to know how big is a column in the database. Let me explain why I think it could be a nice feature to be added in 00-database-procs.tcl, maybe, on next release?

By default, we have 200 char limit on some kind of columns (titles or names, keys...) that should be large enough, but sometimes, users break your wonderful idea. University Courses usually have (too) large subjects. Even worst, a forum inside a course could have a too big forum name. We, at UNED, have resized some columns on our database to allow bigger course names.

When I have to try some form, I always get tempted to overfill title fields... And it's too frustrating to get an oracle error. One solution is validating the forum elements (server-side), of course, but it could be nice if I could be advised somehow before posting (client-side). The simplest idea is using the MAXLENGTH value on input fields, so the browser didn't let the user write any more. (We have talked about that on irc, I'm going to write a summary post)

Using the same idea as db_column_type, I have written a db_column_size function that tells me how big is a field. On Oracle is just quering user_tab_columns table. Mario Aguado told me that the postgres version is as simple as adding a "size" column to the view user_tab_columns.

So, when using template::element to create a input text form, I'm adding the maxlength this way:

set forum_name_max_size [ad_call_proc_if_exists db_column_size forums_forums name]

template::element create $form_name ${prefix}name \

-label [_ forums.Name] \

-datatype text \

-widget text \

-html "size 60 maxlength $forum_name_max_size"

Note that I'm using ad_call_proc_if_exists just in case some upgrade didn't load my tcl library where I've write db_column_size (looking forward to include it on database-procs).