Skip to content

Commit 7e3b7de

Browse files
authored
Merge pull request #26 from typesense/ts-server-v0.20.0-support
Support for Typesense Server v0.20.0
2 parents f5bb51c + afe6355 commit 7e3b7de

7 files changed

Lines changed: 25 additions & 15 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ typesense-server-peers
1515

1616
# rspec failure tracking
1717
.rspec_status
18+
typesense-data

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Tests are also a good place to know how the the library works internally: [spec]
3333

3434
| Typesense Server | typesense-ruby |
3535
|------------------|----------------|
36+
| \>= v0.20.0 | \>= v0.12.0 |
3637
| \>= v0.19.0 | \>= v0.11.0 |
3738
| \>= v0.18.0 | \>= v0.10.0 |
3839
| \>= v0.17.0 | \>= v0.9.0 |

lib/typesense/document.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ def delete
1616
@api_call.delete(endpoint_path)
1717
end
1818

19-
def update(partial_document)
20-
@api_call.patch(endpoint_path, partial_document)
19+
def update(partial_document, options = {})
20+
@api_call.patch(endpoint_path, partial_document, options)
2121
end
2222

2323
private

lib/typesense/documents.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ def initialize(collection_name, api_call)
1212
@documents = {}
1313
end
1414

15-
def create(document)
16-
@api_call.post(endpoint_path, document)
15+
def create(document, options = {})
16+
@api_call.post(endpoint_path, document, options)
1717
end
1818

19-
def upsert(document)
20-
@api_call.post(endpoint_path, document, action: :upsert)
19+
def upsert(document, options = {})
20+
@api_call.post(endpoint_path, document, options.merge(action: :upsert))
2121
end
2222

23-
def update(document)
24-
@api_call.post(endpoint_path, document, action: :update)
23+
def update(document, options = {})
24+
@api_call.post(endpoint_path, document, options.merge(action: :update))
2525
end
2626

2727
def create_many(documents, options = {})

lib/typesense/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module Typesense
4-
VERSION = '0.11.1'
4+
VERSION = '0.12.0'
55
end

spec/typesense/document_spec.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,14 @@
6868
headers: {
6969
'Content-Type' => 'application/json',
7070
'X-Typesense-Api-Key' => typesense.configuration.api_key
71+
},
72+
query: {
73+
dirty_values: 'coerce_or_reject'
7174
}
7275
)
7376
.to_return(status: 200, body: JSON.dump(partial_document), headers: { 'Content-Type': 'application/json' })
7477

75-
result = document_124.update(partial_document)
78+
result = document_124.update(partial_document, dirty_values: 'coerce_or_reject')
7679

7780
expect(result).to eq(partial_document)
7881
end

spec/typesense/documents_spec.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,13 @@
4949
headers: {
5050
'X-Typesense-Api-Key' => typesense.configuration.api_key,
5151
'Content-Type' => 'application/json'
52+
},
53+
query: {
54+
'dirty_values' => 'coerce_or_reject'
5255
})
5356
.to_return(status: 200, body: JSON.dump(document), headers: { 'Content-Type': 'application/json' })
5457

55-
result = companies_documents.create(document)
58+
result = companies_documents.create(document, dirty_values: 'coerce_or_reject')
5659

5760
expect(result).to eq(document)
5861
end
@@ -67,11 +70,12 @@
6770
'Content-Type' => 'application/json'
6871
},
6972
query: {
70-
'action' => 'update'
73+
'action' => 'update',
74+
'dirty_values' => 'coerce_or_reject'
7175
})
7276
.to_return(status: 200, body: JSON.dump(document), headers: { 'Content-Type': 'application/json' })
7377

74-
result = companies_documents.update(document)
78+
result = companies_documents.update(document, dirty_values: 'coerce_or_reject')
7579

7680
expect(result).to eq(document)
7781
end
@@ -86,11 +90,12 @@
8690
'Content-Type' => 'application/json'
8791
},
8892
query: {
89-
'action' => 'upsert'
93+
'action' => 'upsert',
94+
'dirty_values' => 'coerce_or_reject'
9095
})
9196
.to_return(status: 200, body: JSON.dump(document), headers: { 'Content-Type': 'application/json' })
9297

93-
result = companies_documents.upsert(document)
98+
result = companies_documents.upsert(document, dirty_values: 'coerce_or_reject')
9499

95100
expect(result).to eq(document)
96101
end

0 commit comments

Comments
 (0)