|
From: Oleg B. <ph...@ph...> - 2005-06-06 08:25:17
|
Hello. Dear All, I'd like to ask this question:
How strict, do you suppose, should SQLObject be in regard to column
types and values?
For example, if one declares table(s) with StringCol(s), IntCol(s),
FloatCol(s) and (s)he reads values from those column and receives 8-bit
strings, integers and float values, it's ok; if one would want to read
another type (s)he attaches a validator/converter to the column. No
problems so far.
But how strict SQLObject should be when accepting data from a
program? Should it accepts a unicode for a StringCol? a float? an object
with __str__() method? and convert them to string calling str()? Or
should it raise an exception?
Should it accepts a string for a FloatCol? an object with
__float__()? and call float() on them?
In my opinion it should not. I'd like SQLObject to be strict. If one
reads a float from a FloatCol (s)he must put a float to the column.
Integer for IntCol. 8-bit string for a StringCol, etc.
There are few exceptions. One can put a long integer into an IntCol,
and one can put int/long into a FloatCol; that's allowed because such
numeric coercion is pretty normal in all programming languages and all
databases I know of. But not the other way around - one cannot put a
float into IntCol.
Another exception is one can put a string into a UnicodeCol, though
I'd like to recommend avoid this or at least put only an ASCII string. I
don't know what to do with the opposite - putting a unicode string (even
if contains only ascii characters) into a StringCol; I think it should
be prohibited.
Well, that's my opinion. What do you think? Do you agree or disagree
with me, and why?
Oleg.
--
Oleg Broytmann http://phd.pp.ru/ ph...@ph...
Programmers don't die, they just GOSUB without RETURN.
|