moskytw / mosql

Build SQL with native Python data structure smoothly.
http://mosql.mosky.tw
MIT License
140 stars 17 forks source link

None should be IS NULL in SQL? #1

Closed keitheis closed 11 years ago

keitheis commented 11 years ago
table = "wants"
updated_at_field = "wants.updated_at"

select_sql = select(table, {updated_at_field: None})

print(select_sql)
print(db.session.execute(select_sql).rowcount)

Output:
SELECT * FROM wants WHERE wants.updated_at = null
0

select_sql = ("SELECT * FROM " + table
              + " WHERE " + updated_at_field + " IS NULL")
print(select_sql)
print(db.session.execute(select_sql).rowcount)

Output:
SELECT * FROM wants WHERE wants.updated_at IS NULL
37