PL/Python: Make regression tests pass with older Python versions
authorPeter Eisentraut <peter_e@gmx.net>
Sun, 7 Jul 2013 00:36:19 +0000 (20:36 -0400)
committerPeter Eisentraut <peter_e@gmx.net>
Sun, 7 Jul 2013 00:37:58 +0000 (20:37 -0400)
Avoid output formatting differences by printing str() instead of repr()
of the value.

src/pl/plpython/expected/plpython_types.out
src/pl/plpython/expected/plpython_types_3.out
src/pl/plpython/sql/plpython_types.sql

index edc51423e96bd04696d0cb0d11753298e865b381..91106e04550b274ef9e4d7903b54b2b9f0325191 100644 (file)
@@ -215,11 +215,11 @@ CONTEXT:  PL/Python function "test_type_conversion_int8"
 CREATE FUNCTION test_type_conversion_numeric(x numeric) RETURNS numeric AS $$
 # print just the class name, not the type, to avoid differences
 # between decimal and cdecimal
-plpy.info(x, x.__class__.__name__)
+plpy.info(str(x), x.__class__.__name__)
 return x
 $$ LANGUAGE plpythonu;
 SELECT * FROM test_type_conversion_numeric(100);
-INFO:  (Decimal('100'), 'Decimal')
+INFO:  ('100', 'Decimal')
 CONTEXT:  PL/Python function "test_type_conversion_numeric"
  test_type_conversion_numeric 
 ------------------------------
@@ -227,7 +227,7 @@ CONTEXT:  PL/Python function "test_type_conversion_numeric"
 (1 row)
 
 SELECT * FROM test_type_conversion_numeric(-100);
-INFO:  (Decimal('-100'), 'Decimal')
+INFO:  ('-100', 'Decimal')
 CONTEXT:  PL/Python function "test_type_conversion_numeric"
  test_type_conversion_numeric 
 ------------------------------
@@ -235,7 +235,7 @@ CONTEXT:  PL/Python function "test_type_conversion_numeric"
 (1 row)
 
 SELECT * FROM test_type_conversion_numeric(100.0);
-INFO:  (Decimal('100.0'), 'Decimal')
+INFO:  ('100.0', 'Decimal')
 CONTEXT:  PL/Python function "test_type_conversion_numeric"
  test_type_conversion_numeric 
 ------------------------------
@@ -243,7 +243,7 @@ CONTEXT:  PL/Python function "test_type_conversion_numeric"
 (1 row)
 
 SELECT * FROM test_type_conversion_numeric(100.00);
-INFO:  (Decimal('100.00'), 'Decimal')
+INFO:  ('100.00', 'Decimal')
 CONTEXT:  PL/Python function "test_type_conversion_numeric"
  test_type_conversion_numeric 
 ------------------------------
@@ -251,7 +251,7 @@ CONTEXT:  PL/Python function "test_type_conversion_numeric"
 (1 row)
 
 SELECT * FROM test_type_conversion_numeric(5000000000.5);
-INFO:  (Decimal('5000000000.5'), 'Decimal')
+INFO:  ('5000000000.5', 'Decimal')
 CONTEXT:  PL/Python function "test_type_conversion_numeric"
  test_type_conversion_numeric 
 ------------------------------
@@ -259,7 +259,7 @@ CONTEXT:  PL/Python function "test_type_conversion_numeric"
 (1 row)
 
 SELECT * FROM test_type_conversion_numeric(1234567890.0987654321);
-INFO:  (Decimal('1234567890.0987654321'), 'Decimal')
+INFO:  ('1234567890.0987654321', 'Decimal')
 CONTEXT:  PL/Python function "test_type_conversion_numeric"
  test_type_conversion_numeric 
 ------------------------------
@@ -267,7 +267,7 @@ CONTEXT:  PL/Python function "test_type_conversion_numeric"
 (1 row)
 
 SELECT * FROM test_type_conversion_numeric(-1234567890.0987654321);
-INFO:  (Decimal('-1234567890.0987654321'), 'Decimal')
+INFO:  ('-1234567890.0987654321', 'Decimal')
 CONTEXT:  PL/Python function "test_type_conversion_numeric"
  test_type_conversion_numeric 
 ------------------------------
@@ -275,7 +275,7 @@ CONTEXT:  PL/Python function "test_type_conversion_numeric"
 (1 row)
 
 SELECT * FROM test_type_conversion_numeric(null);
-INFO:  (None, 'NoneType')
+INFO:  ('None', 'NoneType')
 CONTEXT:  PL/Python function "test_type_conversion_numeric"
  test_type_conversion_numeric 
 ------------------------------
index 11c4c478c4fbe3bb90cdc74e1b1c78f5ea1c3587..523c2ecda23711c08bbec8cc573ef79233d4dc03 100644 (file)
@@ -215,11 +215,11 @@ CONTEXT:  PL/Python function "test_type_conversion_int8"
 CREATE FUNCTION test_type_conversion_numeric(x numeric) RETURNS numeric AS $$
 # print just the class name, not the type, to avoid differences
 # between decimal and cdecimal
-plpy.info(x, x.__class__.__name__)
+plpy.info(str(x), x.__class__.__name__)
 return x
 $$ LANGUAGE plpython3u;
 SELECT * FROM test_type_conversion_numeric(100);
-INFO:  (Decimal('100'), 'Decimal')
+INFO:  ('100', 'Decimal')
 CONTEXT:  PL/Python function "test_type_conversion_numeric"
  test_type_conversion_numeric 
 ------------------------------
@@ -227,7 +227,7 @@ CONTEXT:  PL/Python function "test_type_conversion_numeric"
 (1 row)
 
 SELECT * FROM test_type_conversion_numeric(-100);
-INFO:  (Decimal('-100'), 'Decimal')
+INFO:  ('-100', 'Decimal')
 CONTEXT:  PL/Python function "test_type_conversion_numeric"
  test_type_conversion_numeric 
 ------------------------------
@@ -235,7 +235,7 @@ CONTEXT:  PL/Python function "test_type_conversion_numeric"
 (1 row)
 
 SELECT * FROM test_type_conversion_numeric(100.0);
-INFO:  (Decimal('100.0'), 'Decimal')
+INFO:  ('100.0', 'Decimal')
 CONTEXT:  PL/Python function "test_type_conversion_numeric"
  test_type_conversion_numeric 
 ------------------------------
@@ -243,7 +243,7 @@ CONTEXT:  PL/Python function "test_type_conversion_numeric"
 (1 row)
 
 SELECT * FROM test_type_conversion_numeric(100.00);
-INFO:  (Decimal('100.00'), 'Decimal')
+INFO:  ('100.00', 'Decimal')
 CONTEXT:  PL/Python function "test_type_conversion_numeric"
  test_type_conversion_numeric 
 ------------------------------
@@ -251,7 +251,7 @@ CONTEXT:  PL/Python function "test_type_conversion_numeric"
 (1 row)
 
 SELECT * FROM test_type_conversion_numeric(5000000000.5);
-INFO:  (Decimal('5000000000.5'), 'Decimal')
+INFO:  ('5000000000.5', 'Decimal')
 CONTEXT:  PL/Python function "test_type_conversion_numeric"
  test_type_conversion_numeric 
 ------------------------------
@@ -259,7 +259,7 @@ CONTEXT:  PL/Python function "test_type_conversion_numeric"
 (1 row)
 
 SELECT * FROM test_type_conversion_numeric(1234567890.0987654321);
-INFO:  (Decimal('1234567890.0987654321'), 'Decimal')
+INFO:  ('1234567890.0987654321', 'Decimal')
 CONTEXT:  PL/Python function "test_type_conversion_numeric"
  test_type_conversion_numeric 
 ------------------------------
@@ -267,7 +267,7 @@ CONTEXT:  PL/Python function "test_type_conversion_numeric"
 (1 row)
 
 SELECT * FROM test_type_conversion_numeric(-1234567890.0987654321);
-INFO:  (Decimal('-1234567890.0987654321'), 'Decimal')
+INFO:  ('-1234567890.0987654321', 'Decimal')
 CONTEXT:  PL/Python function "test_type_conversion_numeric"
  test_type_conversion_numeric 
 ------------------------------
@@ -275,7 +275,7 @@ CONTEXT:  PL/Python function "test_type_conversion_numeric"
 (1 row)
 
 SELECT * FROM test_type_conversion_numeric(null);
-INFO:  (None, 'NoneType')
+INFO:  ('None', 'NoneType')
 CONTEXT:  PL/Python function "test_type_conversion_numeric"
  test_type_conversion_numeric 
 ------------------------------
index 68818807299b0074850cee7cc05565f7e1d8b1ad..e63d07e1f9aeec09e935dd7ee9528cd5ced7736a 100644 (file)
@@ -88,7 +88,7 @@ SELECT * FROM test_type_conversion_int8(null);
 CREATE FUNCTION test_type_conversion_numeric(x numeric) RETURNS numeric AS $$
 # print just the class name, not the type, to avoid differences
 # between decimal and cdecimal
-plpy.info(x, x.__class__.__name__)
+plpy.info(str(x), x.__class__.__name__)
 return x
 $$ LANGUAGE plpythonu;