You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it "keeps the sql in order that it was called when raw where methods used with non-raw"do
query =UserQuery.new.where("first_name = ?", "Paul").name("Smith").query
query.statement.should eq "SELECT #{User::COLUMN_SQL} FROM users WHERE first_name = 'Paul' AND users.name = $1"
query.args.should eq ["Smith"]
end
Failure message:
Failure/Error: query.statement.should eq "SELECT #{User::COLUMN_SQL} FROM users WHERE first_name = 'Paul' AND users.name = $1"
Expected: "SELECT users.id, users.created_at, users.updated_at, users.name, users.age, users.year_born, users.nickname, users.joined_at, users.total_score, users.average_score, users.available_for_hire FROM users WHERE first_name = 'Paul' AND users.name = $1"
got: "SELECT users.id, users.created_at, users.updated_at, users.name, users.age, users.year_born, users.nickname, users.joined_at, users.total_score, users.average_score, users.available_for_hire FROM users WHERE users.name = $1 AND first_name = 'Paul'"
Raw wheres are currently stored separately from the regular where clauses (source). The raw wheres are appended to the end where statement when make the full sql string. This is fine when our api only supports AND statements but is a problem when OR is added to the API.
Potential Solutions
Do not allow further "where" methods if a raw where method is used
Unify the where and raw where list so that the order is preserved
???
The text was updated successfully, but these errors were encountered:
Failing spec:
Failure message:
Raw wheres are currently stored separately from the regular where clauses (source). The raw wheres are appended to the end where statement when make the full sql string. This is fine when our api only supports
AND
statements but is a problem whenOR
is added to the API.Potential Solutions
The text was updated successfully, but these errors were encountered: