Hi there,
I got a problem about 'sqlalchemy.exc.ArgumentError: SQL expression object expected, got object of type <class 'property'> instead'
My SQLAlchemy version is 1.3.22. I have a database like
Class Genome:
id = Column(Integer, primary_key=True)
created_date = Column(Datetime, nullable=False)
@property
def attributes(self):
return "something"
If using the query, it reports an error through the elements.py in the sqlAlchemy
def _literal_as(element, text_fallback):
if isinstance(element, Visitable):
return element
elif hasattr(element, "__clause_element__"):
return element.__clause_element__()
elif isinstance(element, util.string_types):
return text_fallback(element)
elif isinstance(element, (util.NoneType, bool)):
return _const_expr(element)
else:
raise exc.ArgumentError(
"SQL expression object expected, got object of type %r "
"instead" % type(element)
)
This exception is not raised if I directly query genome's column name such as created_date or id.
I am wondering 1) could the column name and property be used interchangeably in some way? Or say how could to query a table's property in the way of querying a table's column? 2) what are some significant differences between table's column name and property?
Thanks.