Skip to content

Commit

Permalink
Fix copy tests on PostgreSQL < 9.4
Browse files Browse the repository at this point in the history
The force_null option was added in PostgreSQL 9.4
  • Loading branch information
elprans committed Sep 8, 2017
1 parent e0c44ce commit 327058f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tests/test_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,12 +418,19 @@ async def test_copy_to_table_basics(self):
)
f.seek(0)

if self.con.get_server_version() < (9, 4):
force_null = None
forced_null_expected = 'n-u-l-l'
else:
force_null = ('b~',)
forced_null_expected = None

res = await self.con.copy_to_table(
'copytab', source=f, columns=('a', 'b~'),
schema_name='public', format='csv',
delimiter='|', null='n-u-l-l', header=True,
quote='*', escape='!', force_not_null=('a',),
force_null=('b~',))
force_null=force_null)

self.assertEqual(res, 'COPY 7')

Expand All @@ -435,7 +442,7 @@ async def test_copy_to_table_basics(self):
self.assertEqual(
output,
[
('*', None, None),
('*', forced_null_expected, None),
('a1', 'b1', None),
('a2', 'b2', None),
('a3', 'b3', None),
Expand Down

0 comments on commit 327058f

Please sign in to comment.