In my SQLModel statement query I have .where(col(Table5.Cname).in_(['string3', 'string4']))
at the end of it.
And then I run it as such: result = session.exec(statement).mappings().all()
However, I get and empty list like so []
, and when printing the statement
variable it shows after IN
: (__[POSTCOMPILE_string1])
How do I fix the POSTCOMPILE
in SQLModel? I saw how to do it using SQLAlchemy, but it did not help.
But after removing the problematic .join()
and after the result = session.exec(statement).mappings().all()
I get a list of dictionaries. While a shorter version of the same statement gives []
How do I return it in FastAPI not as list of dictionaries?
The original statement query:
statement = select(
Table5.Cname,
Table1.Imlast,
Table5.Cconc,
Table1.ImUm
).join(Table2, (Table5.Cid == Table2.IbId) & (Table5.CoC == Table2.Ibmc)).join(Table1, Table1.ImId== Table2.IbId).where(col(Table5.CoLe) == 'string1').where(col(Table2.Ibmc) == 'string2').where(col(Table5.Cname).in_(['string3', 'string4']))
result = session.exec(statement).mappings().all()
return result
Shorter statement:
statement = select(
Table5.Cname,
Table5.Cconc,
).join(Table2, (Table5.Cid == Table2.IbId) & (Table5.CoC == Table2.Ibmc)).where(col(Table5.CoLe) == 'string1').where(col(Table2.Ibmc) == 'string2').where(col(Table5.Cname) == 'string3'))
Thanks!