@@ -80,6 +80,16 @@ def __init__(self, obj):
8080 self .attr = attr
8181 self .jpql_func = jpql_func
8282
83+ @property
84+ def obj (self ):
85+ if self .jpql_func :
86+ return "%s(%s)" % (self .jpql_func , self .attr )
87+ else :
88+ return self .attr
89+
90+ def __repr__ (self ):
91+ return repr (self .obj )
92+
8393class OrderItem (ItemBase ):
8494 """Represent an item in the ORDER BY clause.
8595 """
@@ -113,6 +123,13 @@ def formatstr(self):
113123 else :
114124 return "%s"
115125
126+ @property
127+ def obj (self ):
128+ obj = super ().obj
129+ if self .direction :
130+ obj = (obj , self .direction )
131+ return obj
132+
116133
117134class ConditionItem (ItemBase ):
118135 """Represent an item in the WHERE clause.
@@ -129,6 +146,10 @@ def formatstr(self):
129146 else :
130147 return "%%s %s" % (rhs )
131148
149+ @property
150+ def obj (self ):
151+ return (super ().obj , self .rhs )
152+
132153# ========================== class Query =============================
133154
134155class Query ():
@@ -629,14 +650,30 @@ def limit_clause(self):
629650 def __repr__ (self ):
630651 """Return a formal representation of the query.
631652 """
632- return ("%s(%s, %s, attributes=%s, aggregate=%s, order=%s, "
633- "conditions=%s, includes=%s, limit=%s, join_specs=%s)"
634- % (self .__class__ .__name__ ,
635- repr (self .client ), repr (self .entity .BeanName ),
636- repr (self .attributes ), repr (self .aggregate ),
637- repr (self .order ), repr (self .conditions ),
638- repr (self .includes ), repr (self .limit ),
639- repr (self .join_specs )))
653+ kwargs = []
654+ if self .attributes :
655+ kwargs .append ("attributes=%s" % repr (self .attributes ))
656+ if self .aggregate :
657+ kwargs .append ("aggregate=%s" % repr (self .aggregate ))
658+ if self .order :
659+ kwargs .append ("order=%s" % repr (self .order ))
660+ if self .conditions :
661+ kwargs .append ("conditions=%s" % repr (self .conditions ))
662+ if self .includes :
663+ kwargs .append ("includes=%s" % repr (self .includes ))
664+ if self .limit :
665+ kwargs .append ("limit=%s" % repr (self .limit ))
666+ if self .join_specs :
667+ kwargs .append ("join_specs=%s" % repr (self .join_specs ))
668+ if kwargs :
669+ return ("%s(%s, %s, %s)"
670+ % (self .__class__ .__name__ ,
671+ repr (self .client ), repr (self .entity .BeanName ),
672+ ", " .join (kwargs )))
673+ else :
674+ return ("%s(%s, %s)"
675+ % (self .__class__ .__name__ ,
676+ repr (self .client ), repr (self .entity .BeanName )))
640677
641678 def __str__ (self ):
642679 """Return a string representation of the query.
0 commit comments