Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes #28

Merged
merged 2 commits into from
Apr 14, 2018
Merged

Bug fixes #28

merged 2 commits into from
Apr 14, 2018

Conversation

sparklespdx
Copy link
Contributor

@sparklespdx sparklespdx commented Apr 14, 2018

Treatment.timestamp needed a BigInt, updated the model.

Took a crack at un-hardcoding treatment location and making a validated zipcode lookup statement. This returns 400s for not-float latitude or longitude data.

http://docs.sqlalchemy.org/en/latest/core/sqlelement.html#sqlalchemy.sql.expression.TextClause.bindparams

Signed-off-by: Josh Farwell <josh.farwell@gmail.com>
This was hard-coded, which is a lot better than an injection site, but I
want my zip code to show up :)

I'm using sqlalchemy.sql.text() to give us parameterized and
type-validated input even though we're not using a model here.

Returning None for invalid data bubbles up to a 400 error which seems
appropriate to me.

Signed-off-by: Josh Farwell <josh.farwell@gmail.com>
@tmthyjames tmthyjames merged commit c40f208 into tmthyjames:master Apr 14, 2018
where ST_Contains(geom.geom, ST_MakePoint({lng}, {lat}))
""".format(lng=-86.725573627, lat=36.227447713)).first()
where ST_Contains(geom.geom, ST_MakePoint(:lng, :lat))
""").bindparams(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sparklespdx, I never knew about this bindparams method! Very cool!

@sparklespdx sparklespdx deleted the bugfix branch April 14, 2018 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants