Skip to content

Commit 996154c

Browse files
authored
Merge branch 'main' into fix-pk
2 parents 80001db + c6fb00b commit 996154c

File tree

4 files changed

+27
-15
lines changed

4 files changed

+27
-15
lines changed

aredis_om/model/migrations/migrator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ async def create_index(conn: redis.Redis, index_name, schema, current_hash):
4747
f"You attempted to create an index in database {db_number}"
4848
)
4949
try:
50-
await conn.execute_command(f"ft.info {index_name}")
50+
await conn.ft(index_name).info()
5151
except redis.ResponseError:
5252
await conn.execute_command(f"ft.create {index_name} {schema}")
5353
# TODO: remove "type: ignore" when type stubs will be fixed
@@ -85,7 +85,7 @@ async def create(self):
8585

8686
async def drop(self):
8787
try:
88-
await self.conn.execute_command(f"FT.DROPINDEX {self.index_name}")
88+
await self.conn.ft(self.index_name).dropindex()
8989
except redis.ResponseError:
9090
log.info("Index does not exist: %s", self.index_name)
9191

@@ -115,7 +115,7 @@ async def detect_migrations(self):
115115
current_hash = hashlib.sha1(schema.encode("utf-8")).hexdigest() # nosec
116116

117117
try:
118-
await conn.execute_command("ft.info", cls.Meta.index_name)
118+
await conn.ft(cls.Meta.index_name).info()
119119
except redis.ResponseError:
120120
self.migrations.append(
121121
IndexMigration(

aredis_om/model/model.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from pydantic.main import ModelMetaclass, validate_model
3232
from pydantic.typing import NoArgAnyCallable
3333
from pydantic.utils import Representation
34+
from redis.commands.json.path import Path
3435
from typing_extensions import Protocol, get_args, get_origin
3536
from ulid import ULID
3637

@@ -1495,7 +1496,7 @@ async def save(
14951496
db = self._get_db(pipeline)
14961497

14971498
# TODO: Wrap response errors in a custom exception?
1498-
await db.execute_command("JSON.SET", self.key(), ".", self.json())
1499+
await db.json().set(self.key(), Path.root_path(), json.loads(self.json()))
14991500
return self
15001501

15011502
@classmethod
@@ -1540,8 +1541,8 @@ async def update(self, **field_values):
15401541

15411542
@classmethod
15421543
async def get(cls, pk: Any) -> "JsonModel":
1543-
document = await cls.db().execute_command("JSON.GET", cls.make_primary_key(pk))
1544-
if not document:
1544+
document = json.dumps(await cls.db().json().get(cls.make_key(pk)))
1545+
if document == "null":
15451546
raise NotFoundError
15461547
return cls.parse_raw(document)
15471548

pyproject.toml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,39 @@
11
[tool.poetry]
22
name = "redis-om"
33
version = "0.0.27"
4-
description = "Objecting mapping, and more, for Redis."
5-
authors = ["Andrew Brookins <andrew.brookins@redis.com>"]
6-
maintainers = ["Andrew Brookins <andrew.brookins@redis.com>"]
4+
description = "Object mappings, and more, for Redis."
5+
authors = ["Redis OSS <oss@redis.com>"]
6+
maintainers = ["Redis OSS <oss@redis.com>"]
77
license = "BSD-3-Clause"
88
readme = "README.md"
9-
repository = "https://github.com/redis-developer/redis-om-python"
9+
repository = "https://github.com/redis/redis-om-python"
1010
packages = [
1111
{ "include" = "aredis_om" },
1212
]
1313
classifiers = [
1414
"Development Status :: 3 - Alpha",
15+
"Environment :: Console",
1516
"Intended Audience :: Developers",
16-
"Topic :: Database :: Front-Ends",
17+
"Operating System :: OS Independent",
18+
"Topic :: Database",
19+
'License :: OSI Approved :: BSD License',
20+
'Programming Language :: Python :: 3.10',
21+
'Programming Language :: Python :: 3.6',
22+
'Programming Language :: Python :: 3.7',
23+
'Programming Language :: Python :: 3.8',
24+
'Programming Language :: Python :: 3.9',
25+
'Programming Language :: Python',
1726
]
1827
include=[
1928
"docs/*",
2029
"images/*",
2130
"redis_om/**/*",
2231
]
2332

33+
[tool.poetry.urls]
34+
"Code" = "https://github.com/redis/redis-om-python"
35+
"Issue tracker" = "https://github.com/redis/redis-om-python/issues"
36+
2437
[tool.poetry.dependencies]
2538
python = "^3.7,<=3.11"
2639
redis = ">=3.5.3,<5.0.0"
@@ -29,7 +42,6 @@ pydantic = "^1.8.2"
2942
click = "^8.0.1"
3043
pptree = "^3.1"
3144
types-redis = ">=3.5.9,<5.0.0"
32-
types-six = "^1.16.1"
3345
python-ulid = "^1.0.3"
3446
cleo = "1.0.0a5"
3547
typing-extensions = "^4.0.0"
@@ -40,7 +52,6 @@ more-itertools = "^8.14.0"
4052
mypy = "^0.971"
4153
pytest = "^7.1.2"
4254
ipdb = "^0.13.9"
43-
pylint = "^2.13.9"
4455
black = "^22.6"
4556
isort = "^5.9.3"
4657
flake8 = "^5.0.4"
@@ -60,4 +71,4 @@ migrate = "redis_om.model.cli.migrate:migrate"
6071

6172
[build-system]
6273
requires = ["poetry-core>=1.0.0"]
63-
build-backend = "poetry.core.masonry.api"
74+
build-backend = "poetry.core.masonry.api"

tests/test_json_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ async def test_saves_many_explicit_transaction(address, m):
293293
async with m.Member.db().pipeline(transaction=True) as pipeline:
294294
await m.Member.add(members, pipeline=pipeline)
295295
assert result == [member1, member2]
296-
assert await pipeline.execute() == ["OK", "OK"]
296+
assert await pipeline.execute() == [True, True]
297297

298298
assert await m.Member.get(pk=member1.pk) == member1
299299
assert await m.Member.get(pk=member2.pk) == member2

0 commit comments

Comments
 (0)