quickbase_record 0.2.2 → 0.2.3
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 +8 -8
- data/README.md +14 -2
- data/lib/quickbase_record/queries.rb +11 -13
- data/lib/quickbase_record/version.rb +1 -1
- data/quickbase_record-0.2.2.gem +0 -0
- data/spec/queries_spec.rb +9 -4
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MTFlNzllN2NmODI1M2U5OWFlMTQyZTliOGQ3YTdhMDExMTA4OGM2Zg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YTA1NjViZjNjYWQyODZhYWY0YmVjNDU2OTc2YTVkODBkOTZjNWNkYQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YzNkMDE4ZDdmZDllMjYxMDQ3N2ViNTYzM2ZmNDJjYjVkYzA2MTIxZDBlZjM2
|
10
|
+
NDM4NzIwZDk2OTVmNWYxMDRhZGFlNDUwNzI4Y2RhOTMyMDc4NzhkYWM5OGEy
|
11
|
+
NDUzZDA3YjlhMDc5MDgzMmVkNzVkMTFlNDRmZDQ4MDQyMDdjMzI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDVlYzNlYjhkMjU0NmIwMzMzNGUyOWU2YjI1Y2YzNTQzYmU0NjM0YjA3OTY3
|
14
|
+
ZDM2Mzc5ZjBlMTYxNGE2ZTc4NTlkZWYyODY3ZjhlNGQzMjQwNzZlYjRkNjVk
|
15
|
+
ZDU0YTVmNzA1ZTczNmEwY2FmMjI3YzAzZTA4ODEyZTFiN2ZmMjY=
|
data/README.md
CHANGED
@@ -118,12 +118,21 @@ Database callbacks (i.e. `before_save :create_token!`) are not fully functional
|
|
118
118
|
# {'8'.EX.'Socrates'}OR{'8'.EX.'Socrates'}
|
119
119
|
```
|
120
120
|
|
121
|
-
- To use a
|
121
|
+
- To use a comparator other than 'EX' pass the value as another hash with the key as the comparator
|
122
122
|
```
|
123
123
|
Post.where(author: {XEX: 'Cullen Jett'})
|
124
124
|
# {'8'.XEX.'Cullen Jett'}
|
125
125
|
```
|
126
126
|
|
127
|
+
- Combine arrays and hashes to build more complex queries
|
128
|
+
```
|
129
|
+
Post.where(id: [{XEX: 123}, {OBF: 'today'}])
|
130
|
+
# "{'3'.XEX.'123'}OR{'3'.OAF.'today'}"
|
131
|
+
|
132
|
+
Post.where(id: {XEX: 123, OAF: 'today'})
|
133
|
+
# "{'3'.XEX.'123'}AND{'3'.OAF.'today'}"
|
134
|
+
```
|
135
|
+
|
127
136
|
- Also accepts a string in the standard QuickBase query format
|
128
137
|
* Works with field names or FIDs
|
129
138
|
```
|
@@ -159,7 +168,7 @@ Database callbacks (i.e. `before_save :create_token!`) are not fully functional
|
|
159
168
|
```
|
160
169
|
|
161
170
|
* **#update_attributes(attributes_hash)**
|
162
|
-
- **
|
171
|
+
- **IMPORTANT: Updates *and* saves the object with the new attributes**
|
163
172
|
- Returns the object
|
164
173
|
```
|
165
174
|
@post = Post.where(author: 'Cullen Jett').first
|
@@ -176,6 +185,9 @@ Database callbacks (i.e. `before_save :create_token!`) are not fully functional
|
|
176
185
|
@post.save
|
177
186
|
```
|
178
187
|
|
188
|
+
* **.qb_client and #qb_client**
|
189
|
+
- Access the quickbase API client (advantage_quickbase gem) directly
|
190
|
+
|
179
191
|
## Testing
|
180
192
|
Unfortunately you will not be able to run the test suite unless you have access to the QuickBase application used as the test database *or* you create your own QuickBase app to test against that mimics the test fakes. Eventually the test calls will be stubbed out so anyone can test it, but I've got stuff to do -- pull requests are welcome :)
|
181
193
|
|
@@ -75,30 +75,28 @@ module QuickbaseRecord
|
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
-
def join_with_and(fid, value,
|
79
|
-
"{'#{fid}'.#{
|
78
|
+
def join_with_and(fid, value, comparator="EX")
|
79
|
+
"{'#{fid}'.#{comparator}.'#{value}'}"
|
80
80
|
end
|
81
81
|
|
82
|
-
def join_with_or(fid, array,
|
82
|
+
def join_with_or(fid, array, comparator="EX")
|
83
83
|
array.map do |value|
|
84
84
|
if value.is_a? Hash
|
85
85
|
join_with_custom(fid, value)
|
86
86
|
else
|
87
|
-
"{'#{fid}'.#{
|
87
|
+
"{'#{fid}'.#{comparator}.'#{value}'}"
|
88
88
|
end
|
89
89
|
end.join("OR")
|
90
90
|
end
|
91
91
|
|
92
92
|
def join_with_custom(fid, hash)
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
end
|
101
|
-
|
93
|
+
hash.map do |comparator, value|
|
94
|
+
if value.is_a? Array
|
95
|
+
join_with_or(fid, value, comparator)
|
96
|
+
else
|
97
|
+
"{'#{fid}'.#{comparator}.'#{value}'}"
|
98
|
+
end
|
99
|
+
end.join('AND')
|
102
100
|
end
|
103
101
|
|
104
102
|
def convert_field_name_to_fid(field_name)
|
Binary file
|
data/spec/queries_spec.rb
CHANGED
@@ -159,21 +159,26 @@ RSpec.describe QuickbaseRecord::Queries do
|
|
159
159
|
expect(TeacherFake.build_query(hash)).to eq("{'3'.EX.'1'}OR{'3'.EX.'2'}")
|
160
160
|
end
|
161
161
|
|
162
|
-
it "accepts custom
|
162
|
+
it "accepts custom comparators via a nested hash" do
|
163
163
|
hash = {id: {XEX: 1}}
|
164
164
|
expect(TeacherFake.build_query(hash)).to eq("{'3'.XEX.'1'}")
|
165
165
|
end
|
166
166
|
|
167
|
-
it "combines custom
|
167
|
+
it "combines custom comparators using arrays with OR" do
|
168
168
|
hash = {id: {XEX: [1, 2]}}
|
169
169
|
expect(TeacherFake.build_query(hash)).to eq("{'3'.XEX.'1'}OR{'3'.XEX.'2'}")
|
170
170
|
end
|
171
171
|
|
172
|
-
it "combines different
|
173
|
-
hash = {id: [{XEX:
|
172
|
+
it "combines different comparators with OR" do
|
173
|
+
hash = {id: [{XEX: 123}, {OAF: 'today'}]}
|
174
174
|
expect(TeacherFake.build_query(hash)).to eq("{'3'.XEX.'123'}OR{'3'.OAF.'today'}")
|
175
175
|
end
|
176
176
|
|
177
|
+
it "combines different comparators with AND" do
|
178
|
+
hash = {id: {XEX: 123, OAF: 'today'}}
|
179
|
+
expect(TeacherFake.build_query(hash)).to eq("{'3'.XEX.'123'}AND{'3'.OAF.'today'}")
|
180
|
+
end
|
181
|
+
|
177
182
|
it "converts field names to FIDs" do
|
178
183
|
hash = "{name.EX.'Cullen Jett'}"
|
179
184
|
expect(TeacherFake.build_query(hash)).to eq("{6.EX.'Cullen Jett'}")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quickbase_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cullen Jett
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- quickbase_record-0.1.0.gem
|
119
119
|
- quickbase_record-0.2.0.gem
|
120
120
|
- quickbase_record-0.2.1.gem
|
121
|
+
- quickbase_record-0.2.2.gem
|
121
122
|
- quickbase_record.gemspec
|
122
123
|
- spec/fakes/student_fake.rb
|
123
124
|
- spec/fakes/teacher_fake.rb
|