﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
18367	LayerMapping.verify_ogr_field fails when trying to map OFTString to TextField	geoffhing@…	nobody	"In {{{LayerMapping.verify_ogr_field()}}}, there is this check around line 335 of contrib/gis/utils/layermapping.py:

{{{
                val = ogr_field.value
                if len(val) > model_field.max_length:
                    raise InvalidString('%s model field maximum string length is %s, given %s characters.' %
                                        (model_field.name, model_field.max_length, len(val)))
}}}

When model_field is an instance of {{{models.TextField}}} this check will fail because {{{model_field.max_length}}} is None.

I was able to fix this by checking model_field.max_length before the length test:

{{{
                val = ogr_field.value
                if model_field.max_length and len(val) > model_field.max_length:
                    raise InvalidString('%s model field maximum string length is %s, given %s characters.' %
                                        (model_field.name, model_field.max_length, len(val)))
}}}"	Bug	closed	GIS	1.4	Normal	fixed			Unreviewed	0	0	0	0	0	0
