|
Eloy Lafuente (stronk7) committed 1 file to 'Moodle CVS' - 04/Nov/09 03:53 AM
Eloy Lafuente (stronk7) made changes - 04/Nov/09 03:55 AM
Eloy Lafuente (stronk7) committed 2 files to 'Moodle CVS' - 04/Nov/09 07:34 AM
Done,
implemented the normalise_value() function in mysql and postgresql drives (was already in mssql and oracle) that performs all the default "normalisation" like casting empty strings to cero when working with numeric columns. Tests passing now. Resolving as fixed. Petr, my only concern is if we should, in moodle_database.php: /**
* Normalise values based in RDBMS dependencies (booleans, LOBs...)
*
* @param database_column_info $column column metadata corresponding with the value we are going to normalise
* @param mixed $value value we are going to normalise
* @return mixed the normalised value
*/
private abstract function normalise_value($column, $value);
in order to "force" drivers implementators to have such good habit. Ciao
Eloy Lafuente (stronk7) made changes - 04/Nov/09 07:40 AM
you mean "protected abstract" right? +10 for that
ah, I was thinking really "private", cannot that be done?
private + abstract? looks weird, I doubt you would be able to call it from moodel_database if defined in native drivers. What other use would it have?
I did not test it, it might actually work in this weird PHP OOP model private + abstract means that ANY DB driver must implement it and only can be used by it. That's what I was exactly trying to do. And has sense. IMO.
If we do it protected that means that potential childs will be able to use it, but are we going to have childs of native drivers? I don't think so. I do not know if it applies here too but usually I saw protected instead of private for the UnitTesting purposes - ie if you need to have a testable subclass of the native driver. I suppose the DB testing scheme may be different though.
I don't think unit testing is the key here. We aren't going to have one test_normalise_value() function at all, because it will be covered by all the insert/update/set_field tests instead.
I do not like forcing people to define something private in drivers - private measn do it in any way you like which imo includes not use nay function for that at all
That's a good point, oki, declaring it as protected abstract. Ciao
Eloy Lafuente (stronk7) committed 7 files to 'Moodle CVS' - 04/Nov/09 09:19 PM
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
MySQL: insert/update/set_field
PostgreSQL: set_field
coming soon...ciao