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 +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/active_force/active_query.rb +0 -4
- data/lib/active_force/query.rb +5 -1
- data/lib/active_force/version.rb +1 -1
- data/spec/active_force/active_query_spec.rb +5 -0
- data/spec/active_force/query_spec.rb +23 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cc1c415b6de1e133528660a416b470d81eee1b8e075f7150ee9244f32d6c9c4c
|
|
4
|
+
data.tar.gz: c4a24611cdc27f447c0c3b3e29d14c16c5e8c5b701f9cfcdd6f0469b057e5622
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
data/lib/active_force/query.rb
CHANGED
|
@@ -74,7 +74,7 @@ module ActiveForce
|
|
|
74
74
|
end
|
|
75
75
|
|
|
76
76
|
def find id
|
|
77
|
-
where("#{ @table_id } =
|
|
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
|
data/lib/active_force/version.rb
CHANGED
|
@@ -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
|