Re: troubles with unicode

Oleg Broytman <[email protected]>
Newsgroups gmane.comp.python.sqlobject
Message-ID <[email protected]>
On Mon, Jan 30, 2012 at 02:23:56AM +0100, Petr Jake?? wrote:
> It was necessary to define all the column names and column types  manually
> in the table Class definition.

   That's ok. "fromDatabase" schema guessing in SQLObject is a bit
primitive. It works slightly better for The Big Three (MySQL, Postgres,
SQLite) but still far from ideal.
   You have a chance to improve the machinery for Firebird - it is in
FirebirdConnection class, methods columnsFromSchema and guessClass.

> Before inserting/updating to the database it is necessary to check, if the
> inserted value type is the same as declared in the table Class definition

   That strange - it's the job of validators.

> (it is not possible to send string in to the integer column for example).
> Strange.

   Well, that's that job - IntCol's validator doesn't allow strings but
allows any object that can be coerced to int.

> Is there some way how to check/set/convert column type according to the
> Class definition?

   See the code in .set() that converts input values:

            for name, value in kw.items():
                from_python = getattr(self, '_SO_from_python_%s' % name, None)
                if from_python:
                    dbValue = from_python(value, self._SO_validatorState)
                else:
                    dbValue = value
                to_python = getattr(self, '_SO_to_python_%s' % name, None)
                if to_python:
                    value = to_python(dbValue, self._SO_validatorState)

Oleg.
-- 
     Oleg Broytman            http://phdru.name/            [email protected]
           Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.