simple fix for wrong type detection of SQLCustomTypes

This commit is contained in:
Michele Comitini
2013-11-05 16:09:42 +01:00
parent c89ed53be1
commit e0ea9b78f8
+5 -2
View File
@@ -21,7 +21,7 @@ from gluon.html import FORM, INPUT, LABEL, OPTION, SELECT
from gluon.html import TABLE, THEAD, TBODY, TR, TD, TH, STYLE from gluon.html import TABLE, THEAD, TBODY, TR, TD, TH, STYLE
from gluon.html import URL, truncate_string, FIELDSET from gluon.html import URL, truncate_string, FIELDSET
from gluon.dal import DAL, Field, Table, Row, CALLABLETYPES, smart_query, \ from gluon.dal import DAL, Field, Table, Row, CALLABLETYPES, smart_query, \
bar_encode, Reference, REGEX_TABLE_DOT_FIELD, Expression bar_encode, Reference, REGEX_TABLE_DOT_FIELD, Expression, SQLCustomType
from gluon.storage import Storage from gluon.storage import Storage
from gluon.utils import md5_hash from gluon.utils import md5_hash
from gluon.validators import IS_EMPTY_OR, IS_NOT_EMPTY, IS_LIST_OF, IS_DATE, \ from gluon.validators import IS_EMPTY_OR, IS_NOT_EMPTY, IS_LIST_OF, IS_DATE, \
@@ -1685,7 +1685,10 @@ class SQLFORM(FORM):
name = str(field).replace('.', '-') name = str(field).replace('.', '-')
# treat ftype 'decimal' as 'double' # treat ftype 'decimal' as 'double'
# (this fixes problems but needs refactoring! # (this fixes problems but needs refactoring!
ftype = field.type.split(' ')[0] if isinstance(field.type, SQLCustomType):
ftype = field.type.type.split(' ')[0]
else:
ftype = field.type.split(' ')[0]
if ftype.startswith('decimal'): ftype = 'double' if ftype.startswith('decimal'): ftype = 'double'
elif ftype=='bigint': ftype = 'integer' elif ftype=='bigint': ftype = 'integer'
elif ftype.startswith('big-'): ftype = ftype[4:] elif ftype.startswith('big-'): ftype = ftype[4:]