mirror of
				https://github.com/psycopg/psycopg2.git
				synced 2025-11-04 01:37:31 +03:00 
			
		
		
		
	NamedTupleCursor doesn't change exception when fetching with no result.
This commit is contained in:
		
							parent
							
								
									ef7a5ee8a9
								
							
						
					
					
						commit
						3cae0f3f5d
					
				| 
						 | 
					@ -3,6 +3,9 @@
 | 
				
			||||||
	* lib/extras.py: build the namedtuple only once per execution, not once
 | 
						* lib/extras.py: build the namedtuple only once per execution, not once
 | 
				
			||||||
	per fetch.
 | 
						per fetch.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						* lib/extras.py: don't change the exception raised when fetching without a
 | 
				
			||||||
 | 
						result from NamedTupleCursor.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
2010-11-10  Daniele Varrazzo  <daniele.varrazzo@gmail.com>
 | 
					2010-11-10  Daniele Varrazzo  <daniele.varrazzo@gmail.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	* psycopg/green.c: functions unused outside the module marked static.
 | 
						* psycopg/green.c: functions unused outside the module marked static.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -305,7 +305,7 @@ class NamedTupleCursor(_cursor):
 | 
				
			||||||
            raise self._exc
 | 
					            raise self._exc
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        def _make_nt(self, namedtuple=namedtuple):
 | 
					        def _make_nt(self, namedtuple=namedtuple):
 | 
				
			||||||
            return namedtuple("Record", [d[0] for d in self.description])
 | 
					            return namedtuple("Record", [d[0] for d in self.description or ()])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class LoggingConnection(_connection):
 | 
					class LoggingConnection(_connection):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -219,6 +219,15 @@ class NamedTupleCursorTest(unittest.TestCase):
 | 
				
			||||||
        self.assertEqual(r.bar, 2)
 | 
					        self.assertEqual(r.bar, 2)
 | 
				
			||||||
        self.assertRaises(AttributeError, getattr, r, 'foo')
 | 
					        self.assertRaises(AttributeError, getattr, r, 'foo')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @if_has_namedtuple
 | 
				
			||||||
 | 
					    def test_no_result_no_surprise(self):
 | 
				
			||||||
 | 
					        curs = self.conn.cursor()
 | 
				
			||||||
 | 
					        curs.execute("update nttest set s = s")
 | 
				
			||||||
 | 
					        self.assertRaises(psycopg2.ProgrammingError, curs.fetchone)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        curs.execute("update nttest set s = s")
 | 
				
			||||||
 | 
					        self.assertRaises(psycopg2.ProgrammingError, curs.fetchall)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @if_has_namedtuple
 | 
					    @if_has_namedtuple
 | 
				
			||||||
    def test_minimal_generation(self):
 | 
					    def test_minimal_generation(self):
 | 
				
			||||||
        # Instrument the class to verify it gets called the minimum number of times.
 | 
					        # Instrument the class to verify it gets called the minimum number of times.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user