YaleSTC / shifts

Application to easily track shifts, reports, and payforms for employees.
MIT License
23 stars 18 forks source link

Public view is broken #324

Closed mnquintana closed 9 years ago

mnquintana commented 10 years ago

Trying to access /public_view returns this error:

Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1)' at line 1: SELECT `shifts`.* FROM `shifts`  WHERE (start >= '2014-08-27 04:00:00' AND end <= '2014-09-03 04:00:00' AND location_id = 1 AND active is 1)

MySQL syntax error? Oops. This looks like it might be a problem deeper than public_view - we should investigate.

njlxyaoxinwei commented 10 years ago

The shifts_between method of location model is broken somehow and this causes the error

njlxyaoxinwei commented 10 years ago
Shift.where('active is true') # Correct syntax
Shift.where('active is ?', true) # WRONG! It gets translated to FROM `shifts` WHERE (active IS 1)
Shift.where('active = ?', true) # The right way to pass in the value with Active Record Query Interface
# However:
Shift.where('active is ?', nil) # This works
Shift.where('active = ?', nil) # This works too
# So passing in NULL value works with both syntaxes
njlxyaoxinwei commented 10 years ago

Location::shifts_between is the only place where this incorrect syntax appears