Ticket #523 (in_QA enhancement)
Codegeneration for stored procedures / Support in Sql2005 Database adapter / Introduce db capability support
| Reported by: | akrohn | Owned by: | somebody |
|---|---|---|---|
| Priority: | important | Milestone: | 1.1.3 |
| Component: | Codegen | Version: | 1.1.1 Stable |
| Keywords: | stored procedures | Cc: |
Description
In the last weeks I worked in implementing codegeneration for stored procedures. This is splitted into the base part and the database adapter specific part. The first adapter to support this is the Sql2005 Database adapter.
DB ADAPTER CAPABILITY SUPPORT
Because not every database adapter supports this I implemented the functionality to check the capabilities of a database adapter. So the codegeneration can act differently depending on supported capability.
In QDatabaseBase is a new array $blnCapabilitesArray and some functions to check/set a capability. The Constructor sets the minimal capabilities (TableSupport? => true, StoredProcedureSupport? => false). This then can be overriden by the specific database adapter. So it should be backward compatible! But if anyone could check out with mysql and other datbases if it works, I would be glad.
CODEGENERATION FOR STORED PROCEDURES
This is splitted into the base part (QDatabaseBase, QDatabaseCodeGen) and the database adapter specific part (QSqlServer2005Database).
The implementation supports multiple resultsets, output paramters and return values.
The stored procedure class files will be generated in "MODEL_GEN/stored_procedures". The creation of this new directory is not included in this patch (Tortoise does not generate it). So a maintainer with write access should do this.
The class paths will be in the new file "MODEL_GEN/_stored_procedure_class_paths.inc.php". This is also not included in this patch. So a maintainer with write access should do this.
The new files QStoredProcedure.class.php and QStoredProcedureParameter.class.php have to be under "includes/qcubed/_core/codegen/". A maintainer with write access should do this.
CODEGEN TEMPLATE
The template for the stored procedure files has to be under "includes/qcubed/_core/codegen/templates/".
1. db_stored_procedure_main.tpl
There has to be a new directory "db_stored_procedure" and under this a new directory "class_gen". There goes this file with the name "_main.tpl". A maintainer with write access should do this.
CLASS PATH TEMPLATE
The template file has to be under "includes/qcubed/_core/codegen/templates/".
2. aggregate_db_stored_procedure_main.tpl
There has to be a new directory "aggregate_db_stored_procedure" and under this a new directory "class_paths". There goes this file with the name "_main.tpl". A maintainer with write access should do this.
This should be everything it needs and I hope it has no effect for database adapter that don't support stored procedures at this time. Please test it.
The implementation for other adapters should be possible with this infrastructure. At least I had this in mind when designing this.
Hope this brings QCubed to another step of code generation and others find this useful.
