Skip to content

Commit 327058f

Browse files
committed
Fix copy tests on PostgreSQL < 9.4
The force_null option was added in PostgreSQL 9.4
1 parent e0c44ce commit 327058f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tests/test_copy.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,12 +418,19 @@ async def test_copy_to_table_basics(self):
418418
)
419419
f.seek(0)
420420

421+
if self.con.get_server_version() < (9, 4):
422+
force_null = None
423+
forced_null_expected = 'n-u-l-l'
424+
else:
425+
force_null = ('b~',)
426+
forced_null_expected = None
427+
421428
res = await self.con.copy_to_table(
422429
'copytab', source=f, columns=('a', 'b~'),
423430
schema_name='public', format='csv',
424431
delimiter='|', null='n-u-l-l', header=True,
425432
quote='*', escape='!', force_not_null=('a',),
426-
force_null=('b~',))
433+
force_null=force_null)
427434

428435
self.assertEqual(res, 'COPY 7')
429436

@@ -435,7 +442,7 @@ async def test_copy_to_table_basics(self):
435442
self.assertEqual(
436443
output,
437444
[
438-
('*', None, None),
445+
('*', forced_null_expected, None),
439446
('a1', 'b1', None),
440447
('a2', 'b2', None),
441448
('a3', 'b3', None),

0 commit comments

Comments
 (0)