String fields with number are considered numeric and it causes a Numeric Overflow error
See original GitHub issueString fields with number are considered numeric and it causes a Numeric Overflow error When importing an Excel Spreadsheet string fields with number are considered numeric and it causes a Numeric Overflow error.
For instance in the file attached you will find 2 columns (CUIT and CUIL), those are CharField on the app models
To Reproduce
Steps to reproduce the behavior:
- Import file
- Result get True on result.has_errors()
Versions (please complete the following information):
- Django Import Export: 2.9.0
- Python: 3.10.6
- Django: 4.1.1
Expected behavior Import with no errors
Screenshots
Import empleados.xlsx
Additional context
** resourses.py **
class EmpleadoResource(resources.ModelResource):
empresa = fields.Field(
column_name='CUIT', attribute='CUIT Empresa',
widget={
ForeignKeyWidget(Empresa, 'cuit'),
CharWidget()
})
leg = fields.Field(column_name='Leg')
name = fields.Field(column_name='Nombre')
cuil = fields.Field(column_name='cuil',
widget=CharWidget())
class Meta:
model = Empleado
fields = ('empresa', 'leg', 'name', 'cuil')
** models.py **
class Empresa(models.Model):
name = models.CharField(max_length=120, verbose_name='Razon Social')
cuit = models.CharField(max_length=11, validators=[MinLengthValidator(11)])
class Empleado(models.Model):
leg = models.PositiveSmallIntegerField()
empresa = models.ForeignKey(Empresa, on_delete=models.CASCADE)
name = models.CharField(max_length=120, verbose_name='Nombre', null=True, blank=True)
cuil = models.CharField(max_length=11, validators=[MinLengthValidator(11)])
** views.py **
def import_empleados(request):
context = {
'error': '',
'results': ''
}
if request.method == 'POST':
empleado_resource = EmpleadoResource()
dataset = Dataset()
nuevos_empleados = request.FILES['xlsfile']
print(nuevos_empleados)
try:
imported_data = dataset.load(nuevos_empleados.read())
print(imported_data)
result = empleado_resource.import_data(dataset, dry_run=True)
except UnsupportedFormat:
context['error'] = "Formato de archivo incorrecto"
except Exception as err:
context['error'] = f"Unexpected {err=}, {type(err)=}"
if not result.has_errors():
print(result)
return render(request, 'export_lsd/export/empleados.html', context)
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
numeric overflow with "NULL" column (0,3)
SQL Navigator showed "error" as value for this column. Table was created as select. Now it is truncated and refilled and NULL rows...
Read more >Designer error: numeric field over flow - Alteryx Community
Solved: Hello community, I recently created a workflow which pulls data from a SQL table, runs through already-fixed macros, and the final ...
Read more >FIELD NUMERIC OVERFLOW - Viva Clipper - WordPress.com
This error message usually indicates that a function has been used in either a label or report form but has not been invoked...
Read more >ERROR: " (19) Numeric overflow; (75) Numeric overflow "
This issue occurs for SMALLINT datatype because the value '-32768' is out of range for SMALLINT datatype in Informatica Data Vault. It has...
Read more >What could cause a Numeric Overflow exception? — oracle-tech
We have a jdbc application that reads from one Oracle table and builds a prepared statement to do an insert into a different...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, please. Thank you very much for all!
Thanks for raising - we’ll look into it