mirror of
				https://github.com/psycopg/psycopg2.git
				synced 2025-11-04 09:47:30 +03:00 
			
		
		
		
	Merge remote-tracking branch 'jdufresne/decimal'
This commit is contained in:
		
						commit
						fc8574fdd8
					
				| 
						 | 
					@ -72,11 +72,7 @@ _ext.register_adapter(type(None), _ext.NoneAdapter)
 | 
				
			||||||
# Register the Decimal adapter here instead of in the C layer.
 | 
					# Register the Decimal adapter here instead of in the C layer.
 | 
				
			||||||
# This way a new class is registered for each sub-interpreter.
 | 
					# This way a new class is registered for each sub-interpreter.
 | 
				
			||||||
# See ticket #52
 | 
					# See ticket #52
 | 
				
			||||||
try:
 | 
					 | 
				
			||||||
from decimal import Decimal
 | 
					from decimal import Decimal
 | 
				
			||||||
except ImportError:
 | 
					 | 
				
			||||||
    pass
 | 
					 | 
				
			||||||
else:
 | 
					 | 
				
			||||||
from psycopg2._psycopg import Decimal as Adapter
 | 
					from psycopg2._psycopg import Decimal as Adapter
 | 
				
			||||||
_ext.register_adapter(Decimal, Adapter)
 | 
					_ext.register_adapter(Decimal, Adapter)
 | 
				
			||||||
del Decimal, Adapter
 | 
					del Decimal, Adapter
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -98,11 +98,7 @@ class CursorTests(ConnectingTestCase):
 | 
				
			||||||
            cur.mogrify(u"SELECT %s;", (snowman,)))
 | 
					            cur.mogrify(u"SELECT %s;", (snowman,)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_mogrify_decimal_explodes(self):
 | 
					    def test_mogrify_decimal_explodes(self):
 | 
				
			||||||
        # issue #7: explodes on windows with python 2.5 and psycopg 2.2.2
 | 
					 | 
				
			||||||
        try:
 | 
					 | 
				
			||||||
        from decimal import Decimal
 | 
					        from decimal import Decimal
 | 
				
			||||||
        except:
 | 
					 | 
				
			||||||
            return
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        conn = self.conn
 | 
					        conn = self.conn
 | 
				
			||||||
        cur = conn.cursor()
 | 
					        cur = conn.cursor()
 | 
				
			||||||
| 
						 | 
					@ -138,11 +134,7 @@ class CursorTests(ConnectingTestCase):
 | 
				
			||||||
        self.assertEqual(42, curs.cast(20, '42'))
 | 
					        self.assertEqual(42, curs.cast(20, '42'))
 | 
				
			||||||
        self.assertAlmostEqual(3.14, curs.cast(700, '3.14'))
 | 
					        self.assertAlmostEqual(3.14, curs.cast(700, '3.14'))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try:
 | 
					 | 
				
			||||||
        from decimal import Decimal
 | 
					        from decimal import Decimal
 | 
				
			||||||
        except ImportError:
 | 
					 | 
				
			||||||
            self.assertAlmostEqual(123.45, curs.cast(1700, '123.45'))
 | 
					 | 
				
			||||||
        else:
 | 
					 | 
				
			||||||
        self.assertEqual(Decimal('123.45'), curs.cast(1700, '123.45'))
 | 
					        self.assertEqual(Decimal('123.45'), curs.cast(1700, '123.45'))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        from datetime import date
 | 
					        from datetime import date
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user