add alias-property to Expression
Sometimes it is necessary to check if the Expression/Field instance has an alias and get the value of it
@@ -1617,6 +1617,11 @@ class Expression(object):
def with_alias(self, alias):
return Expression(self.db, self._dialect._as, self, alias, self.type)
+ @property
+ def alias(self):
+ if self.op == self._dialect._as:
+ return self.second
+
# GIS expressions
def st_asgeojson(self, precision=15, options=0):
