func should be there but also you can use a lambda instead, or a def that can even have imports in it.
On Jan 8, 2018 5:14 PM, "Jonathan Vanasco" <[email protected]> wrote: > I'm using declarative. > > I need to map a viewonly relationship that uses sqlalchemy.func.lower in > the primaryjoin. > > `func` doesn't seem available in `ext/declarative/clsregistry.py` and > can't be used in the string context. is that correct? > > i have a workaround of declaring the class, then mapping the relationship > via python code. i'd like to make sure I'm doing this right and not > missing another bit of the docs (with 99.9% of my issues have been). > > just to illustrate the above: > > > > class Table1(base): > # this won't work" > rel1 = sqlalchemy.orm.relationship( > "Table2", > primaryjoin="""sqlalchemy.func.lower(Table1.name)==foreign( > sqlalchemy.func.lower(Table2.name))""", > viewonly=True, > ) > > # this will work: > Table1.rel1 = sqlalchemy.orm.relationship( > Table2, > primaryjoin=sqlalchemy.func.lower(Table1.name)== sqlalchemy. > orm.foreign(sqlalchemy.func.lower(Table2.name)), > viewonly=True, > ) > > > > -- > SQLAlchemy - > The Python SQL Toolkit and Object Relational Mapper > > http://www.sqlalchemy.org/ > > To post example code, please provide an MCVE: Minimal, Complete, and > Verifiable Example. See http://stackoverflow.com/help/mcve for a full > description. > --- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/d/optout. > -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
