active_force 0.27.0 → 0.27.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c4cc417eaaf0ad9a412c1a39374d80e4a723d0f8d6184eba87c09371e3ba56a
4
- data.tar.gz: d8cdb8bc16ab43f8d1fbe4840788e412d5aa0ad3a25734cbc2b85d7138626c75
3
+ metadata.gz: cc1c415b6de1e133528660a416b470d81eee1b8e075f7150ee9244f32d6c9c4c
4
+ data.tar.gz: c4a24611cdc27f447c0c3b3e29d14c16c5e8c5b701f9cfcdd6f0469b057e5622
5
5
  SHA512:
6
- metadata.gz: c005126087818d2afa9ef019e537ae5920fea69f9275ba74293cbe97ea9335cfb62da1deedd1c58e707536357f45cf322dcfa48d38b6d007e89f5210dfaf86b2
7
- data.tar.gz: 43623c0cda29edc52f3ccaddad50010a76d88417d6ebcbe5d80c2bd838518eddbaef217a41ec14c0e372ba50dbe8cad4cf3eaebe1f1f0998734bde19a4251d63
6
+ metadata.gz: 2de4234e2f417c7fc79c04d2dbbc039399f55fa63ea083a5e4b2b45eaf568d18d66fba3d577928d665a4ff816cb45dd15d0169df1837bc4495b6d8d369ebefe5
7
+ data.tar.gz: 0d35e111badf4d1226d1a422c586fffe0eaa93fd0c50f54b88b381ba1b062b5460cc035e6989baf15583cae916e42c4e2042fce433fb95bfae0db0ebe0ea2c1d
data/CHANGELOG.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  ## Not released
4
4
 
5
+ ## 0.27.1
6
+ - `find` and `find!` quote the id the same way `where` quotes string values. The SOQL does not change for ids without `'` or `\`. (https://github.com/Beyond-Finance/active_force/pull/TBD)
7
+
5
8
  ## 0.27.0
6
9
  - Emit `query.active_force` notifications for logical query executions, including aggregates and composite batch queries, with SOQL, model, client identity, transport, and standard exception payloads. Cache hits count as logical queries, not API calls. (https://github.com/Beyond-Finance/active_force/pull/117)
7
10
 
@@ -241,10 +241,6 @@ module ActiveForce
241
241
  end
242
242
  end
243
243
 
244
- def quote_string(s)
245
- "'#{s.gsub(/(['\\])/, '\\\\\\1')}'"
246
- end
247
-
248
244
  def result
249
245
  soql = self.to_s
250
246
 
@@ -74,7 +74,7 @@ module ActiveForce
74
74
  end
75
75
 
76
76
  def find id
77
- where("#{ @table_id } = '#{ id }'").limit 1
77
+ where("#{ @table_id } = #{ quote_string(id.to_s) }").limit 1
78
78
  end
79
79
 
80
80
  def first
@@ -112,6 +112,10 @@ module ActiveForce
112
112
  end
113
113
 
114
114
  protected
115
+ def quote_string(s)
116
+ "'#{s.gsub(/(['\\])/, '\\\\\\1')}'"
117
+ end
118
+
115
119
  def and_conditions
116
120
  "(#{@conditions.join(') AND (')})" unless @conditions.empty?
117
121
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveForce
4
- VERSION = '0.27.0'
4
+ VERSION = '0.27.1'
5
5
  end
@@ -465,6 +465,11 @@ describe ActiveForce::ActiveQuery do
465
465
  expect(client).to have_received(:query).with("SELECT Id FROM #{sobject.table_name} WHERE (Id = '#{id}') LIMIT 1")
466
466
  end
467
467
 
468
+ it 'escapes the id in the query' do
469
+ active_query.find!("x' OR Id != 'y")
470
+ expect(client).to have_received(:query).with("SELECT Id FROM #{sobject.table_name} WHERE (Id = 'x\\' OR Id != \\'y') LIMIT 1")
471
+ end
472
+
468
473
  context 'when record is found' do
469
474
  let(:record) { build_restforce_sobject(id: id) }
470
475
 
@@ -119,6 +119,29 @@ describe ActiveForce::Query do
119
119
  it "should return a query for 1 record" do
120
120
  expect(query.find(2).to_s).to eq "SELECT Id, name, etc FROM table_name WHERE (Id = '2') LIMIT 1"
121
121
  end
122
+
123
+ {
124
+ '15-character id' => ['001A000000abcde', "'001A000000abcde'"],
125
+ '18-character id' => ['001A000000abcdeAAA', "'001A000000abcdeAAA'"],
126
+ 'nil' => [nil, "''"],
127
+ 'integer' => [1006, "'1006'"],
128
+ 'symbol' => [:abc, "'abc'"],
129
+ 'uuid' => ['eb68d128-9a9b-4cd0-b98a-9abe31194c59', "'eb68d128-9a9b-4cd0-b98a-9abe31194c59'"]
130
+ }.each do |description, (id, literal)|
131
+ it "builds the same SOQL as before for a #{description}" do
132
+ expect(query.find(id).to_s).to eq "SELECT Id, name, etc FROM table_name WHERE (Id = #{literal}) LIMIT 1"
133
+ end
134
+ end
135
+
136
+ it "escapes single quotes in the id" do
137
+ expect(query.find("x' OR Name != 'y").to_s)
138
+ .to eq "SELECT Id, name, etc FROM table_name WHERE (Id = 'x\\' OR Name != \\'y') LIMIT 1"
139
+ end
140
+
141
+ it "escapes backslashes in the id" do
142
+ expect(query.find("x\\' OR Name != 'y").to_s)
143
+ .to eq "SELECT Id, name, etc FROM table_name WHERE (Id = 'x\\\\\\' OR Name != \\'y') LIMIT 1"
144
+ end
122
145
  end
123
146
 
124
147
  describe ".order" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_force
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.27.0
4
+ version: 0.27.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eloy Espinaco