question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

String fields with number are considered numeric and it causes a Numeric Overflow error

See original GitHub issue

String 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:

  1. Import file
  2. 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 image

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:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
lugezzcommented, Oct 28, 2022

Yes, please. Thank you very much for all!

1reaction
matthewhegartycommented, Oct 26, 2022

Thanks for raising - we’ll look into it

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found