1

I'm having problems with SqlAlchemy as follows: A derived method, called firstName_lastName_regular, returns a hybrid property. But the if condition (which includes valid SqlAlchemy functions) throws

TypeError: Boolean value of this clause is not defined

Before returning I need to check if my components are not NULL and length > 0. The line if (func.charlength(first_name) > 0 and func.charlength(last_name) > 0) is failing.

@hybrid_method
def firstName_lastName_regular(self):
    first_name = self.get_first_name(self)
    last_name = self.get_last_name(self)
    result = ''
    if (func.charlength(first_name) > 0 and func.charlength(last_name) > 0):
        result = func.concat (
                func.upper(func.substr(first_name,1,1)), func.lower(func.substr(first_name,2)), ' ',
                func.upper(func.substr(last_name,1,1)), func.lower(func.substr(last_name,2))
                )
    return result  
gene b.
  • 10,512
  • 21
  • 115
  • 227
  • Does this answer your question? [SQLAlchemy: unexpected results when using \`and\` and \`or\`](https://stackoverflow.com/questions/42681231/sqlalchemy-unexpected-results-when-using-and-and-or) – snakecharmerb Jul 07 '21 at 18:19

0 Answers0