Skip to content

Commit

Permalink
SAL-3248 | FEATURE | Add ids method AF query objects
Browse files Browse the repository at this point in the history
  • Loading branch information
cdelpone-beyond-finance committed May 25, 2024
1 parent be44e31 commit a7d5756
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/active_force/query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ def sum field
clone_and_set_instance_variables(query_fields: ["sum(#{field})"])
end

def ids
clone_and_set_instance_variables(query_fields: ["Id"])
end

protected
def and_conditions
"(#{@conditions.join(') AND (')})" unless @conditions.empty?
Expand Down
7 changes: 7 additions & 0 deletions spec/active_force/query_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,11 @@
expect(query.where("name = 'cool'").sum(:field1).to_s).to eq "SELECT sum(field1) FROM table_name WHERE (name = 'cool')"
end
end

describe ".ids" do
it "should return the query for plucking the ids" do
query_with_ids = query.where("name = 'cool'").ids
expect(query_with_ids.to_s).to eq "SELECT Id FROM table_name WHERE (name = 'cool')"
end
end
end

0 comments on commit a7d5756

Please sign in to comment.