#34863: sqlite math functions don't accept character fields as input -------------------------------------+------------------------------------- Reporter: zacroker | Owner: nobody Type: Bug | Status: new Component: Database layer | Version: 4.2 (models, ORM) | Severity: Normal | Resolution: Keywords: sqlite, math | Triage Stage: | Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Description changed by zacroker:
Old description: > We have a view that performs some trig calculations. It works when > testing in MySQL, but fails when using sqlite. > > I have overridden the "RADIANS" function implementation from django in > our conftest.py file. Details not that important, but essentially is > this: > > ``` > connection.create_function("RADIANS", 1, lambda x: math.radians(float(x)) > if x is not None else None) > ``` > > The issue is, there is a lat/lon field in our database, which is stored > as a CharField (we can debate that decision later...), so when it gets > passed into the `_sqlite_radians` function the test fails as it is > invalid input. I think that these functions should be able to take in > string values. > > I have started a PR but thought before I submit it I should see if it is > a 'genuine' bug or a decision not to support this field. New description: We have a view that performs some trig calculations. It works when testing in MySQL, but fails when using sqlite. I have overridden the "RADIANS" function implementation from django in our conftest.py file. Details not that important, but essentially is this: `connection.create_function("RADIANS", 1, lambda x: math.radians(float(x)) if x is not None else None)` The issue is, there is a lat/lon field in our database, which is stored as a CharField (we can debate that decision later...), so when it gets passed into the `_sqlite_radians` function the test fails as it is invalid input. I think that these functions should be able to take in string values. I have started a PR but thought before I submit it I should see if it is a 'genuine' bug or a decision not to support this field. -- -- Ticket URL: <https://code.djangoproject.com/ticket/34863#comment:1> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/0107018abbe2318c-d81273c3-cd0d-4cd3-ae3c-b6c0e5e0c371-000000%40eu-central-1.amazonses.com.