Skip to content

Commit

Permalink
Consider None values in TSQL conditions
Browse files Browse the repository at this point in the history
Fixes #262
  • Loading branch information
goodmami committed Dec 20, 2019
1 parent d84b012 commit 86fc039
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ these changes are prefixed with "**BREAKING**"
token, allowing for more informative syntax errors.
* `delphin.tsql.select()` will raise a `TSQLError` if a condition's
type does not match that of the column it checks ([#261][])
* `delphin.tsql.select()` now considers ``None`` values when checking
conditions ([#262][])


## [v1.0.3][]
Expand Down Expand Up @@ -1216,5 +1218,6 @@ information about changes, except for
[#253]: https://github.com/delph-in/pydelphin/issues/253
[#257]: https://github.com/delph-in/pydelphin/issues/257
[#261]: https://github.com/delph-in/pydelphin/issues/261
[#262]: https://github.com/delph-in/pydelphin/issues/262
[#263]: https://github.com/delph-in/pydelphin/issues/263
[#264]: https://github.com/delph-in/pydelphin/issues/264
6 changes: 3 additions & 3 deletions delphin/tsql.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,15 +440,15 @@ def func(row):
index = field_index[body[0]]
field = fields[index]
value = tsdb.cast(field.datatype, row[index])
return re.search(body[1], value)
return value is not None and re.search(body[1], value)

elif op == '!~':

def func(row):
index = field_index[body[0]]
field = fields[index]
value = tsdb.cast(field.datatype, row[index])
return not re.search(body[1], value)
return value is None or not re.search(body[1], value)

else:
compare = _operator_functions[op]
Expand All @@ -457,7 +457,7 @@ def func(row):
index = field_index[body[0]]
field = fields[index]
value = tsdb.cast(field.datatype, row[index])
return compare(value, body[1])
return value is not None and compare(value, body[1])

return func

Expand Down

0 comments on commit 86fc039

Please sign in to comment.