Opened 15 months ago

Last modified 15 months ago

#34863 closed Bug

sqlite math functions don't accept character fields as input — at Initial Version

Reported by: Zachary Croker Owned by: nobody
Component: Database layer (models, ORM) Version: 4.2
Severity: Normal Keywords: sqlite, math
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

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.

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top