Forum OpenACS Q&A: Re: Where is the table user_arguments?

Collapse
Posted by russ m on
check package-procs-(postgresql|oracle).xql to see how that is actually being handled now... the former contents of user_arguments now seem to live in acs_function_args...
Collapse
Posted by Steve Manning on
Thanks.

Your quite right there is a query in package-procs-postgresql.xql which selects from acs_function_args. I didn't look in the xql because the db_list provided its own select statement. So I have learnt 2 things:

1. You can have a query in the xql and in the proc and the one in the xql overides the one in the proc (I would have expected this to be the other way around so that the query name can be overloaded easily in the proc).

2. The select statement in the proc is superfluous and could be removed. In fact if it points to a no existant table it perhaps should be removed to avoid confusion.

Does this sound right?

    Steve

Collapse
Posted by Jarkko Laine on
Steve,

1. The "overloading" has to be this way. It wouldn't work the other way round. An example: you use a SQL/92 outer join in a general query. This happens not work in oracle so you have to write the query using oracle's own syntax in -oracle.xql. Now if the query in curly braces (or general xql file) would override the one in oracle file, this query would never work with oracle. I.e. the query in curlies is a default query, used if nothing with that query name can be found from xql files.

So the order is: 1. rdbms specific xql, 2. generic xql, 3. curlies. Of course the normal practice nowadays is not to put anything inside the curlies, so yes, you should remove the query from the tcl file.

The example I gave is actually a bad one, since you should only use such queries in general places that really work with all (both) rdbms's. But I think it should explain the reason for the parse order.

Collapse
Posted by Malte Sussdorff on
Can we make it a rule, that no new code makes it into the CVS as long as it has SQL queries in the curlies? This is definitly confusing for newcomers. Though I have to agree that developing code is considerably easier with the queries in the TCL file, but hey, we got query-extractor :).
Collapse
Posted by Jeff Davis on
I think we should make it a rule that we make no new rules until we adhere to the rules we already made.
Collapse
7: Rule Book (response to 6)
Posted by Malte Sussdorff on
Can we post a rule book somewhere? Or, if it exists, make it more prominent at e.g. the doc section?

Just a n-pager stating: If you want to develop for the OpenACS core, these are the rules and good principles you should be following. Obviously, the rule about taking out SQL queries from tcl files should be high on that list 😊.

Collapse
Posted by Steve Manning on
Indeed that makes perfect sense. Thank you.

    Steve