@@ -514,14 +514,15 @@ class Cursor(pg_api.Cursor):
514514 _cursor_type = None
515515
516516 @classmethod
517- def from_query (type ,
517+ def from_query (
518+ typ ,
518519 parameters , query ,
519520 with_hold = False ,
520521 with_scroll = False ,
521522 insensitive = True ,
522523 fetchcount = None ,
523524 ):
524- c = super ().__new__ (type )
525+ c = super ().__new__ (typ )
525526 c .parameters = parameters
526527 c .query = query
527528 c .with_hold = with_hold
@@ -532,7 +533,7 @@ def from_query(type,
532533 # If the cursor is not scrollable, and fetchcount
533534 # was not supplied, set it as the default fetchcount.
534535 if not with_scroll and fetchcount is None :
535- fetchcount = type .default_fetchcount
536+ fetchcount = typ .default_fetchcount
536537 c .__init__ (ID (c ), query .connection , fetchcount = fetchcount )
537538 return c
538539
@@ -948,15 +949,16 @@ class PreparedStatement(pg_api.PreparedStatement):
948949 statement_id = None
949950
950951 @classmethod
951- def from_query_string (type ,
952+ def from_query_string (
953+ typ ,
952954 string : "SQL statement to prepare" ,
953955 connection : "connection to bind the query to" ,
954956 statement_id : "statement_id to use instead of generating one" = None
955957 ) -> "PreparedStatement instance" :
956958 """
957959 Create a PreparedStatement from a query string.
958960 """
959- r = super ().__new__ (type )
961+ r = super ().__new__ (typ )
960962 r .string = string
961963 r .__init__ (statement_id or ID (r ), connection )
962964 return r
@@ -973,8 +975,8 @@ def __repr__(self):
973975 return '<{mod}.{name}[{ci}] {state}>' .format (
974976 mod = type (self ).__module__ ,
975977 name = type (self ).__name__ ,
976- ci = ci ,
977- state = self .closed and 'closed' or 'prepared' ,
978+ ci = self . connection . connector . _pq_iri ,
979+ state = self .state ,
978980 )
979981
980982 @property
@@ -991,6 +993,17 @@ def command(self) -> str:
991993 def closed (self ) -> bool :
992994 return self ._cid != self .connection ._cid
993995
996+ @property
997+ def state (self ) -> str :
998+ if self .closed :
999+ if self ._pq_xact is not None :
1000+ if self .string is not None :
1001+ return 'parsing'
1002+ else :
1003+ return 'describing'
1004+ return 'closed'
1005+ return 'prepared'
1006+
9941007 def close (self ):
9951008 if self ._cid == self .connection ._cid :
9961009 self .connection ._closestatements .append (self ._pq_statement_id )
@@ -1010,11 +1023,10 @@ def prepare(self):
10101023
10111024 def ife_snapshot_text (self ):
10121025 s = ""
1013- if self .closed :
1014- s += "[closed] "
1015- if self .title :
1016- s += self .title + ", "
1017- s += "statement_id(" + repr (self ._pq_statement_id or self .statement_id ) + ")"
1026+ s += "[" + self .state + "] "
1027+ if self .ife_object_title != pg_api .InterfaceElement .ife_object_title :
1028+ s += self .ife_object_title + ", "
1029+ s += "statement_id(" + repr (self .statement_id ) + ")"
10181030 s += os .linesep + ' ' * 2 + (os .linesep + ' ' * 2 ).join (
10191031 str (self .string ).split (os .linesep )
10201032 )
@@ -1051,6 +1063,7 @@ def _init(self):
10511063 )
10521064 )
10531065 self ._pq_xact = pq .Transaction (cmd )
1066+ self .ife_descend (self ._pq_xact )
10541067 self .connection ._pq_push (self ._pq_xact )
10551068
10561069 def _fini (self ):
0 commit comments