Forum OpenACS Development: Convention for highlighting SQL in Tcl?

Posted by Andrew Piskorski on
Well, we'll definitely have to get the query browser to support the query dispatcher, as Tom J. and Mark A. just pointed out here. I usually use Emacs to read OpenACS code, only occasionally using the query browser for special cases (generally for search), so I didn't even realize yet that it doesn't support the XQL files.

I was wondering about one more thing: After years of using the older ACS toolkits (4.2, 3.x, 2.x, etc.), I only started using OpenACS with its multi database support and XQL query dispatcher fairly recently. One thing I've noticed, is that with the SQL in the separate xql files, as I scan through the Tcl source code the database commands are often so short that I just miss them entirely.

E.g., take this old style (Oracle only, SQL in the Tcl file) query:

set static_page_id [db_exec_plsql do_sp_new {
  :1 :=
    filename   => :sp_filename
    ,title     => :page_title
    ,folder_id => :parent_folder_id
    ,mime_type => :mime_type
With multi-datbase support, it becomes just:
set static_page_id [db_exec_plsql do_sp_new {}]

I hate the idea of leaving obsolete, non-functional SQL in the Tcl file - doing so has already bitten me more than once. But, is there some other convention that would make the Tcl source code more transparent?

For example, maybe including a marker like this to catch the eye when scanning through code:

set static_page_id [db_exec_plsql do_sp_new {
  -- SQL
Or, maybe even run some tool to copy the query out of one of the XQL files, and put it back into the Tcl file as a comment, so that it's very clear that this SQL code in fact doesn't and can't do the real work at all:
set static_page_id [db_exec_plsql do_sp_new {
  -- begin
  -- :1 :=
  --   filename   => :sp_filename
  --   ,title     => :page_title
  --   ,folder_id => :parent_folder_id
  --   ,mime_type => :mime_type
  -- );
  -- end;

Or perhaps there's no advantage to any new changes or conventions like this at all, and the current system is fine. For you folks who have been dealing with XQL files for a long time now, what do you think?