Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9885add

Browse files
authoredSep 26, 2021
add support to single scheme filed (#148)
* add support to single scheme filed
1 parent c8f85f2 commit 9885add

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed
 

‎redisearch/client.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,10 @@ def create_index(self, fields, no_term_offsets=False,
308308

309309
args.append('SCHEMA')
310310

311-
args += list(itertools.chain(*(f.redis_args() for f in fields)))
311+
try:
312+
args += list(itertools.chain(*(f.redis_args() for f in fields)))
313+
except TypeError:
314+
args += fields.redis_args()
312315

313316
return self.redis.execute_command(*args)
314317

@@ -323,7 +326,10 @@ def alter_schema_add(self, fields):
323326

324327
args = [self.ALTER_CMD, self.index_name, 'SCHEMA', 'ADD']
325328

326-
args += list(itertools.chain(*(f.redis_args() for f in fields)))
329+
try:
330+
args += list(itertools.chain(*(f.redis_args() for f in fields)))
331+
except TypeError:
332+
args += fields.redis_args()
327333

328334
return self.redis.execute_command(*args)
329335

‎test/test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -826,10 +826,10 @@ def testAlterSchemaAdd(self):
826826
client.redis.flushdb()
827827

828828
# Creating the index definition and schema
829-
client.create_index((TextField('title'),))
829+
client.create_index(TextField('title'))
830830

831831
# Using alter to add a field
832-
client.alter_schema_add((TextField('body'),))
832+
client.alter_schema_add(TextField('body'))
833833

834834
# Indexing a document
835835
client.add_document('doc1', title='MyTitle', body='Some content only in the body')

0 commit comments

Comments
 (0)
Please sign in to comment.