Hi,
I got strange error when tried to use SQLCustomType. I'm trying to create
custom type which will handle unicode<->utf8 conversions. Since DB stores
in utf8, but my app uses unicode, so I tried to create custom type which
handles such conversions. Here is my code:
db = DAL("sqlite:////tmp/base.sqlite")
utext = SQLCustomType(
type="text",
native="text",
encoder=(lambda x: x.encode("utf-8")),
decoder=(lambda x: x.decode("utf-8"))
)
db.define_table('posts',
Field('title', type=utext, default=""),
Field('text', type=utext, default=""),
Field('html', type=utext, default=""))
Now I'm doing insert into this table:
id = db.posts.insert(title=u"Один", text=u"Два", html=u"Три")
This leads to following error:
File "/Users/stunpix/Projects/app/logic/posts.py", line 28, in save
id = db.posts.insert(title=u"Один", text=u"Два", html=u"Три")
File "/Users/stunpix/Projects/app/contrib/web2py/dal.py", line 6829, in
insert
return self._db._adapter.insert(self,self._listify(fields))
File "/Users/stunpix/Projects/app/contrib/web2py/dal.py", line 928, in
insert
raise e
OperationalError: no such column: Два
I did something wrong? Why value of "text" field was interpreted as field's
name?