nathggns / Scaffold

Lightweight PHP API Framework
Other
8 stars 2 forks source link

Should schema types be respected at the driver level? #126

Open nathggns opened 11 years ago

nathggns commented 11 years ago

For example, should id always be converted to an int?

ClaudioAlbertin commented 11 years ago

Only the model contains a schema definition and should perform type casting (modifiers, validators etc.) I'm not sure about the driver level. The driver however should only perform the queries requested, and not any more. Thus it can't know anything about the database schema and should not perform any operations based on that.

nathggns commented 11 years ago

Oh I had forgotten about that. How about at the model level? It certainly has information about the schema and it's types.

nathggns commented 11 years ago

Maybe even ignore schema types, just test for numeric values and typecast them that way?

ClaudioAlbertin commented 11 years ago

The developer will know what type he wants to use. I'm a bit fed up with frameworks trying to prevent every possible mistake. It's what makes PHP so terrible to use. Just fail early and fail hard. The DBMS already does typecasting anyway. We should only do it on model level, together with validation.

nathggns commented 11 years ago

Okay, cool. We'll do that then. I assume it should be done in ModelDatabase::value (ModelDatabase::__get), which ModelDatabase::export uses anyway.