Skip to content

Commit

Permalink
[middleware] support dict parameters type in flask middleware
Browse files Browse the repository at this point in the history
Fixes #62.

Bumps version to 2.5.1
  • Loading branch information
tredman committed May 13, 2019
1 parent 8e43efb commit 14017a3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# beeline-python changelog

## 2.5.1 2019-05-13

Fixes

- Support parameters of type `dict` in the flask-sqlachemy middleware. Addresses [#62](https://github.com/honeycombio/beeline-python/issues/62).
18 changes: 14 additions & 4 deletions beeline/middleware/flask/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,20 @@ def before_cursor_execute(self, conn, cursor, statement, parameters, context, ex
return

params = []
for param in parameters:
if type(param) == datetime.datetime:
param = param.isoformat()
params.append(param)

# the type of parameters passed in varies depending on DB - handle both list, dict, and tuple
if type(parameters) == tuple or type(parameters) == list:
for param in parameters:
if type(param) == datetime.datetime:
param = param.isoformat()
params.append(param)
elif type(parameters) == dict:
for k,v in parameters.items():
param = "%s=" % k
if type(v) == datetime.datetime:
v = v.isoformat()
param += "%s" % v
params.append(param)

self.state.span = beeline.start_span(context={
"name": "flask_db_query",
Expand Down
2 changes: 1 addition & 1 deletion beeline/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = '2.5.0'
VERSION = '2.5.1'
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
setup(
python_requires='>=2.7',
name='honeycomb-beeline',
version='2.5.0',
version='2.5.1',
description='Honeycomb library for easy instrumentation',
url='https://github.com/honeycombio/beeline-python',
author='Honeycomb.io',
Expand Down

0 comments on commit 14017a3

Please sign in to comment.