fix: update SQLAlchemy JSON accessors from astext to as_string and add validation script
parent
d910ef80d6
commit
6f50cb9852
@ -0,0 +1,21 @@
|
||||
from sqlalchemy import Column, JSON, String, select
|
||||
from sqlalchemy.orm import declarative_base
|
||||
|
||||
Base = declarative_base()
|
||||
|
||||
class Test(Base):
|
||||
__tablename__ = 'test'
|
||||
id = Column(String, primary_key=True)
|
||||
meta = Column(JSON)
|
||||
|
||||
try:
|
||||
s = select(Test).where(Test.meta["type"].as_string() == "target_reliability")
|
||||
print("as_string works")
|
||||
except Exception as e:
|
||||
print("as_string error:", e)
|
||||
|
||||
try:
|
||||
s = select(Test).where(Test.meta["type"].astext == "target_reliability")
|
||||
print("astext works")
|
||||
except Exception as e:
|
||||
print("astext error:", e)
|
||||
Loading…
Reference in New Issue