File tree Expand file tree Collapse file tree 6 files changed +74
-8
lines changed Expand file tree Collapse file tree 6 files changed +74
-8
lines changed Original file line number Diff line number Diff line change 1
1
## [ Unreleased]
2
2
3
+ ## [ 0.9.0] - 2024-07-08
4
+
5
+ - Add object.replace method which uses PUT which performs a complete object replacement
6
+
7
+ ### Breaking
8
+ - Change the object.update method to use PATCH which only performs a partial update(previously performed a replacement)
9
+
3
10
## [ 0.8.11] - 2024-07-02
11
+ - Allow the user to specify any options they want for multi-tenancy when creating a schema using their own hash
12
+ - Allow Ollama vectorizer
4
13
5
14
## [ 0.8.10] - 2024-01-25
6
15
Original file line number Diff line number Diff line change 1
1
PATH
2
2
remote: .
3
3
specs:
4
- weaviate-ruby (0.8.11 )
4
+ weaviate-ruby (0.9.0 )
5
5
faraday (>= 2.0.1 , < 3.0 )
6
6
graphlient (~> 0.7.0 )
7
7
Original file line number Diff line number Diff line change @@ -168,14 +168,17 @@ client.objects.exists?(
168
168
id: " uuid"
169
169
)
170
170
171
- # Delete a single data object from Weaviate .
172
- client.objects.delete (
171
+ # Perform a partial update on an object based on its uuid .
172
+ client.objects.update (
173
173
class_name: " Question" ,
174
- id: " uuid"
174
+ id: " uuid" ,
175
+ properties: {
176
+ category: " simple-math"
177
+ }
175
178
)
176
179
177
- # Update a single data object based on its uuid.
178
- client.objects.update (
180
+ # Replace an object based on its uuid.
181
+ client.objects.replace (
179
182
class_name: " Question" ,
180
183
id: " uuid" ,
181
184
properties: {
@@ -185,6 +188,12 @@ client.objects.update(
185
188
}
186
189
)
187
190
191
+ # Delete a single data object from Weaviate.
192
+ client.objects.delete(
193
+ class_name: " Question" ,
194
+ id: " uuid"
195
+ )
196
+
188
197
# Batch create objects
189
198
client.objects.batch_create(objects: [
190
199
{
Original file line number Diff line number Diff line change @@ -122,6 +122,31 @@ def update(
122
122
)
123
123
validate_consistency_level! ( consistency_level ) unless consistency_level . nil?
124
124
125
+ response = client . connection . patch ( "#{ PATH } /#{ class_name } /#{ id } " ) do |req |
126
+ req . params [ "consistency_level" ] = consistency_level . to_s . upcase unless consistency_level . nil?
127
+
128
+ req . body = { }
129
+ req . body [ "id" ] = id
130
+ req . body [ "class" ] = class_name
131
+ req . body [ "properties" ] = properties
132
+ req . body [ "vector" ] = vector unless vector . nil?
133
+ req . body [ "tenant" ] = tenant unless tenant . nil?
134
+ end
135
+
136
+ response . body
137
+ end
138
+
139
+ # Replace an individual data object based on its uuid.
140
+ def replace (
141
+ class_name :,
142
+ id :,
143
+ properties :,
144
+ vector : nil ,
145
+ tenant : nil ,
146
+ consistency_level : nil
147
+ )
148
+ validate_consistency_level! ( consistency_level ) unless consistency_level . nil?
149
+
125
150
response = client . connection . put ( "#{ PATH } /#{ class_name } /#{ id } " ) do |req |
126
151
req . params [ "consistency_level" ] = consistency_level . to_s . upcase unless consistency_level . nil?
127
152
Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
3
3
module Weaviate
4
- VERSION = "0.8.11 "
4
+ VERSION = "0.9.0 "
5
5
end
Original file line number Diff line number Diff line change 132
132
let ( :response ) { OpenStruct . new ( success? : true , body : object_fixture ) }
133
133
134
134
before do
135
- allow_any_instance_of ( Faraday ::Connection ) . to receive ( :put )
135
+ allow_any_instance_of ( Faraday ::Connection ) . to receive ( :patch )
136
136
. with ( "objects/Question/123" )
137
137
. and_return ( response )
138
138
end
151
151
end
152
152
end
153
153
154
+ describe "#replace" do
155
+ let ( :response ) { OpenStruct . new ( success? : true , body : object_fixture ) }
156
+
157
+ before do
158
+ allow_any_instance_of ( Faraday ::Connection ) . to receive ( :put )
159
+ . with ( "objects/Question/123" )
160
+ . and_return ( response )
161
+ end
162
+
163
+ it "returns the schema" do
164
+ response = objects . replace (
165
+ class_name : "Question" ,
166
+ id : "123" ,
167
+ properties : {
168
+ question : "What does 6 times 7 equal to?" ,
169
+ category : "math" ,
170
+ answer : "42"
171
+ }
172
+ )
173
+ expect ( response . dig ( "class" ) ) . to eq ( "Question" )
174
+ end
175
+ end
176
+
154
177
describe "#batch_create" do
155
178
let ( :response ) { OpenStruct . new ( success? : true , body : objects_fixture ) }
156
179
You can’t perform that action at this time.
0 commit comments