It's not web2py's fault that MySQL silently truncates data.
http://www.davidpashley.com/blog/databases/mysql/silently-truncated
On Wednesday, June 19, 2013 5:52:26 AM UTC-7, Chris wrote:
>
> The main problem is that the failure is silent. It makes no sense that a
> developer declares a field to be length 1000, and DAL arbitrarily reduces
> that to 255 instead of providing an error message. I understand why 255
> may be a safe default limit for MySQL; but if so then fail the field
> creation with a relevant error message (and maybe reference Jonathan's
> solution re: how to override maxcharlength if the developer knows the DBMS
> version can handle the larger limit).
>
> In the current 2.5.1 code, looking in dal.py:
>
> class MySQLAdapter(BaseAdapter):
> ....
> maxcharlength = 255
>
> ...
>
> class Table(object):
> ...
> def __init__( self,
> db,
> tablename,
> *fields,
> **args
> ):
> ...
> for field in fields:
> ...
> if db and not field.type in ('text', 'blob', 'json') and \
> db._adapter.maxcharlength < field.length:
> field.length = db._adapter.maxcharlength ### problem line
>
>
> I'd recommend the last line above, marked ### problem line, be replaced
> with something like, raise ValueError('Requested field length exceeds
> adapter maxcharlength, cannot create. See http://whatever for a way to
> override this limit.')
>
> ??
>
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.