On Thu, Aug 21, 2008 at 7:23 PM, Brion Vibber <brion(a)wikimedia.org> wrote:
In my opinion that would be a bit horrifyingly scary.
;) Domain-specific
knowledge is better placed in domain-specific classes...
Well, having pgsql and all the other BOOL-supporting DBMSes forced to
use integer types just because devs are too lazy to make sure things
work properly on all databases is exactly the sort of thing the
abstraction layer is meant to prevent. Each database should be able
to properly use its own features. Introducing domain-specific
knowledge is kind of icky, but I can't think of any other way to do
it.
Of course this logic could be properly factored out of Database.php.
For instance, we could add another argument to the constructor (or add
a mutator, which could allow extensions to join the fun) that would
allow you to pass in an array of fieldname => type mappings. Then
whatever instantiates the Database object we use could pass that in
when it constructs the object.
Proper behavior for overlong input can vary. Sometimes
we want to reject
it outright, since it's invalid -- an overlong page title, username, or
group name wouldn't function correctly truncated.
I suggested truncation because that's what MySQL would normally do,
and so it's what we're probably relying on in some cases already.
More sensible behavior would be to throw an exception, rather than
having it silently sort of work on MySQL but fail elsewhere (including
MySQL in strict mode).