Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8182ffd

Browse files
committed
PL/Python: Make regression tests pass with older Python versions
Avoid output formatting differences by printing str() instead of repr()of the value.
1 parent5b571bb commit8182ffd

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

‎src/pl/plpython/expected/plpython_types.out

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -215,67 +215,67 @@ CONTEXT: PL/Python function "test_type_conversion_int8"
215215
CREATE FUNCTION test_type_conversion_numeric(x numeric) RETURNS numeric AS $$
216216
# print just the class name, not the type, to avoid differences
217217
# between decimal and cdecimal
218-
plpy.info(x, x.__class__.__name__)
218+
plpy.info(str(x), x.__class__.__name__)
219219
return x
220220
$$ LANGUAGE plpythonu;
221221
SELECT * FROM test_type_conversion_numeric(100);
222-
INFO: (Decimal('100'), 'Decimal')
222+
INFO: ('100', 'Decimal')
223223
CONTEXT: PL/Python function "test_type_conversion_numeric"
224224
test_type_conversion_numeric
225225
------------------------------
226226
100
227227
(1 row)
228228

229229
SELECT * FROM test_type_conversion_numeric(-100);
230-
INFO: (Decimal('-100'), 'Decimal')
230+
INFO: ('-100', 'Decimal')
231231
CONTEXT: PL/Python function "test_type_conversion_numeric"
232232
test_type_conversion_numeric
233233
------------------------------
234234
-100
235235
(1 row)
236236

237237
SELECT * FROM test_type_conversion_numeric(100.0);
238-
INFO: (Decimal('100.0'), 'Decimal')
238+
INFO: ('100.0', 'Decimal')
239239
CONTEXT: PL/Python function "test_type_conversion_numeric"
240240
test_type_conversion_numeric
241241
------------------------------
242242
100.0
243243
(1 row)
244244

245245
SELECT * FROM test_type_conversion_numeric(100.00);
246-
INFO: (Decimal('100.00'), 'Decimal')
246+
INFO: ('100.00', 'Decimal')
247247
CONTEXT: PL/Python function "test_type_conversion_numeric"
248248
test_type_conversion_numeric
249249
------------------------------
250250
100.00
251251
(1 row)
252252

253253
SELECT * FROM test_type_conversion_numeric(5000000000.5);
254-
INFO: (Decimal('5000000000.5'), 'Decimal')
254+
INFO: ('5000000000.5', 'Decimal')
255255
CONTEXT: PL/Python function "test_type_conversion_numeric"
256256
test_type_conversion_numeric
257257
------------------------------
258258
5000000000.5
259259
(1 row)
260260

261261
SELECT * FROM test_type_conversion_numeric(1234567890.0987654321);
262-
INFO: (Decimal('1234567890.0987654321'), 'Decimal')
262+
INFO: ('1234567890.0987654321', 'Decimal')
263263
CONTEXT: PL/Python function "test_type_conversion_numeric"
264264
test_type_conversion_numeric
265265
------------------------------
266266
1234567890.0987654321
267267
(1 row)
268268

269269
SELECT * FROM test_type_conversion_numeric(-1234567890.0987654321);
270-
INFO: (Decimal('-1234567890.0987654321'), 'Decimal')
270+
INFO: ('-1234567890.0987654321', 'Decimal')
271271
CONTEXT: PL/Python function "test_type_conversion_numeric"
272272
test_type_conversion_numeric
273273
------------------------------
274274
-1234567890.0987654321
275275
(1 row)
276276

277277
SELECT * FROM test_type_conversion_numeric(null);
278-
INFO: (None, 'NoneType')
278+
INFO: ('None', 'NoneType')
279279
CONTEXT: PL/Python function "test_type_conversion_numeric"
280280
test_type_conversion_numeric
281281
------------------------------

‎src/pl/plpython/expected/plpython_types_3.out

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -215,67 +215,67 @@ CONTEXT: PL/Python function "test_type_conversion_int8"
215215
CREATE FUNCTION test_type_conversion_numeric(x numeric) RETURNS numeric AS $$
216216
# print just the class name, not the type, to avoid differences
217217
# between decimal and cdecimal
218-
plpy.info(x, x.__class__.__name__)
218+
plpy.info(str(x), x.__class__.__name__)
219219
return x
220220
$$ LANGUAGE plpython3u;
221221
SELECT * FROM test_type_conversion_numeric(100);
222-
INFO: (Decimal('100'), 'Decimal')
222+
INFO: ('100', 'Decimal')
223223
CONTEXT: PL/Python function "test_type_conversion_numeric"
224224
test_type_conversion_numeric
225225
------------------------------
226226
100
227227
(1 row)
228228

229229
SELECT * FROM test_type_conversion_numeric(-100);
230-
INFO: (Decimal('-100'), 'Decimal')
230+
INFO: ('-100', 'Decimal')
231231
CONTEXT: PL/Python function "test_type_conversion_numeric"
232232
test_type_conversion_numeric
233233
------------------------------
234234
-100
235235
(1 row)
236236

237237
SELECT * FROM test_type_conversion_numeric(100.0);
238-
INFO: (Decimal('100.0'), 'Decimal')
238+
INFO: ('100.0', 'Decimal')
239239
CONTEXT: PL/Python function "test_type_conversion_numeric"
240240
test_type_conversion_numeric
241241
------------------------------
242242
100.0
243243
(1 row)
244244

245245
SELECT * FROM test_type_conversion_numeric(100.00);
246-
INFO: (Decimal('100.00'), 'Decimal')
246+
INFO: ('100.00', 'Decimal')
247247
CONTEXT: PL/Python function "test_type_conversion_numeric"
248248
test_type_conversion_numeric
249249
------------------------------
250250
100.00
251251
(1 row)
252252

253253
SELECT * FROM test_type_conversion_numeric(5000000000.5);
254-
INFO: (Decimal('5000000000.5'), 'Decimal')
254+
INFO: ('5000000000.5', 'Decimal')
255255
CONTEXT: PL/Python function "test_type_conversion_numeric"
256256
test_type_conversion_numeric
257257
------------------------------
258258
5000000000.5
259259
(1 row)
260260

261261
SELECT * FROM test_type_conversion_numeric(1234567890.0987654321);
262-
INFO: (Decimal('1234567890.0987654321'), 'Decimal')
262+
INFO: ('1234567890.0987654321', 'Decimal')
263263
CONTEXT: PL/Python function "test_type_conversion_numeric"
264264
test_type_conversion_numeric
265265
------------------------------
266266
1234567890.0987654321
267267
(1 row)
268268

269269
SELECT * FROM test_type_conversion_numeric(-1234567890.0987654321);
270-
INFO: (Decimal('-1234567890.0987654321'), 'Decimal')
270+
INFO: ('-1234567890.0987654321', 'Decimal')
271271
CONTEXT: PL/Python function "test_type_conversion_numeric"
272272
test_type_conversion_numeric
273273
------------------------------
274274
-1234567890.0987654321
275275
(1 row)
276276

277277
SELECT * FROM test_type_conversion_numeric(null);
278-
INFO: (None, 'NoneType')
278+
INFO: ('None', 'NoneType')
279279
CONTEXT: PL/Python function "test_type_conversion_numeric"
280280
test_type_conversion_numeric
281281
------------------------------

‎src/pl/plpython/sql/plpython_types.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ SELECT * FROM test_type_conversion_int8(null);
8888
CREATEFUNCTIONtest_type_conversion_numeric(xnumeric) RETURNSnumericAS $$
8989
# print just the class name, not the type, to avoid differences
9090
# between decimal and cdecimal
91-
plpy.info(x,x.__class__.__name__)
91+
plpy.info(str(x),x.__class__.__name__)
9292
return x
9393
$$ LANGUAGE plpythonu;
9494

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp