-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
false positive migrations detection dependent on encoding #647
Comments
Can you provide a reproduction of a case where a model in Redis displays a false positive change? |
Sure thing @slorello89, forgot about that Having the following model, define a database with undecoded responses import redis
from redis_om import Field, Migrator, HashModel
class User(HashModel):
first_name: str
last_name: str = Field(index=True)
class Meta:
database = redis.from_url("redis://0.0.0.0:6379", decode_responses=False) and then just try to migrate that model m = Migrator()
# should migrate
assert len(m.migrations) == 0
m.detect_migrations()
assert len(m.migrations) > 0
# run,
m.run()
# reset migrations because migrator does not
m.migrations = []
# already migrated, should not have migrations after detection
m.detect_migrations()
assert len(m.migrations) == 0 # raises (for true positive migration checks, you can easily verify that the above code does not raise, if you change to |
@slorello89 any update with regards to this? |
@ivanbelenky - it's pretty clear to me that redis om python seems to depend on the The hash digests produced by the indexes assume that the string it gets back from redis is decoded into UTF-8, and when it isn't, it doesn't compare correctly. Do you need |
Thanks @slorello89 for your answer. In my particular case it comes to reutilizing "Pretty clear" + "seems to be" ~ strikes me as an oxymoronic statement.
|
Disclaimer: I lack knowledge on redis internals, and on the design criteria of the object mapping library.
Issue:
The migrator when running through the
model_registry
performs a hash calculation for the current schemato then compare it to the one it gets from the db
a connection without
decoded_responses=True
(and maybe with different charset) will create false positive migrations, because of distinct types, i.e.bytes
andstr
forstored_hash
andcurrent_hash
respectively.I guess that a default encoding schema for
bytes
responses would suffice, or a user warning.The text was updated successfully, but these errors were encountered: