Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Add additional binary types #83

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,4 @@ state.json

# IDE
.vscode
.idea
2 changes: 1 addition & 1 deletion tap_mysql/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

LOGGER = singer.get_logger('tap_mysql')

CONNECT_TIMEOUT_SECONDS = 30
CONNECT_TIMEOUT_SECONDS = 300

# We need to hold onto this for self-signed SSL
MATCH_HOSTNAME = ssl.match_hostname
Expand Down
2 changes: 1 addition & 1 deletion tap_mysql/discover_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

DATETIME_TYPES = {'datetime', 'timestamp', 'time', 'date'}

BINARY_TYPES = {'binary', 'varbinary'}
BINARY_TYPES = {'binary', 'varbinary', 'tinyblob', 'blob', 'mediumblob', 'longblob'}

SPATIAL_TYPES = {'geometry', 'point', 'linestring',
'polygon', 'multipoint', 'multilinestring',
Expand Down
64 changes: 49 additions & 15 deletions tests/integration/test_tap_mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ def setUpClass(cls):
c_multilinestring MULTILINESTRING,
c_multipolygon MULTIPOLYGON,
c_geometrycollection GEOMETRYCOLLECTION,
c_blob BLOB
c_blob BLOB,
c_binary BINARY (1),
c_varbinary VARBINARY (1)
)''')

catalog = test_utils.discover_catalog(conn, {})
Expand Down Expand Up @@ -118,7 +120,7 @@ def test_tinyint(self):
maximum=127))
self.assertEqual(self.get_metadata_for_column('c_tinyint'),
{'selected-by-default': True,
'sql-datatype': 'tinyint(4)',
'sql-datatype': 'tinyint',
'datatype': 'tinyint'})

def test_tinyint_1(self):
Expand All @@ -132,11 +134,13 @@ def test_tinyint_1(self):

def test_tinyint_1_unsigned(self):
self.assertEqual(self.schema.properties['c_tinyint_1_unsigned'],
Schema(['null', 'boolean'],
Schema(['null', 'integer'],
minimum=0,
maximum=255,
inclusion='available'))
self.assertEqual(self.get_metadata_for_column('c_tinyint_1_unsigned'),
{'selected-by-default': True,
'sql-datatype': 'tinyint(1) unsigned',
'sql-datatype': 'tinyint unsigned',
'datatype': 'tinyint'})

def test_smallint(self):
Expand All @@ -147,7 +151,7 @@ def test_smallint(self):
maximum=32767))
self.assertEqual(self.get_metadata_for_column('c_smallint'),
{'selected-by-default': True,
'sql-datatype': 'smallint(6)',
'sql-datatype': 'smallint',
'datatype': 'smallint'})

def test_mediumint(self):
Expand All @@ -158,7 +162,7 @@ def test_mediumint(self):
maximum=8388607))
self.assertEqual(self.get_metadata_for_column('c_mediumint'),
{'selected-by-default': True,
'sql-datatype': 'mediumint(9)',
'sql-datatype': 'mediumint',
'datatype': 'mediumint'})

def test_int(self):
Expand All @@ -169,7 +173,7 @@ def test_int(self):
maximum=2147483647))
self.assertEqual(self.get_metadata_for_column('c_int'),
{'selected-by-default': True,
'sql-datatype': 'int(11)',
'sql-datatype': 'int',
'datatype': 'int'})

def test_bigint(self):
Expand All @@ -180,7 +184,7 @@ def test_bigint(self):
maximum=9223372036854775807))
self.assertEqual(self.get_metadata_for_column('c_bigint'),
{'selected-by-default': True,
'sql-datatype': 'bigint(20)',
'sql-datatype': 'bigint',
'datatype': 'bigint'})

def test_bigint_unsigned(self):
Expand All @@ -192,7 +196,7 @@ def test_bigint_unsigned(self):

self.assertEqual(self.get_metadata_for_column('c_bigint_unsigned'),
{'selected-by-default': True,
'sql-datatype': 'bigint(20) unsigned',
'sql-datatype': 'bigint unsigned',
'datatype': 'bigint'})

def test_float(self):
Expand Down Expand Up @@ -247,7 +251,7 @@ def test_year(self):
'unsupported')
self.assertEqual(self.get_metadata_for_column('c_year'),
{'selected-by-default': False,
'sql-datatype': 'year(4)',
'sql-datatype': 'year',
'datatype': 'year'})

def test_pk(self):
Expand Down Expand Up @@ -327,13 +331,43 @@ def test_multipolygon(self):

def test_geometrycollection(self):
self.assertEqual(self.schema.properties['c_geometrycollection'],
Schema(['null', 'object'],
format='spatial',
inclusion='available'))
Schema(None,
description='Unsupported column type geomcollection',
inclusion='unsupported'))
self.assertEqual(self.get_metadata_for_column('c_geometrycollection'),
{'selected-by-default': False,
'sql-datatype': 'geomcollection',
'datatype': 'geomcollection'})

def test_binary(self):
self.assertEqual(self.schema.properties['c_blob'],
Schema(['null', 'string'],
format='binary',
inclusion='available'))
self.assertEqual(self.get_metadata_for_column('c_blob'),
{'selected-by-default': True,
'sql-datatype': 'blob',
'datatype': 'blob'})

def test_varbinary(self):
self.assertEqual(self.schema.properties['c_binary'],
Schema(['null', 'string'],
format='binary',
inclusion='available'))
self.assertEqual(self.get_metadata_for_column('c_binary'),
{'selected-by-default': True,
'sql-datatype': 'binary(1)',
'datatype': 'binary'})

def test_blob(self):
self.assertEqual(self.schema.properties['c_varbinary'],
Schema(['null', 'string'],
format='binary',
inclusion='available'))
self.assertEqual(self.get_metadata_for_column('c_varbinary'),
{'selected-by-default': True,
'sql-datatype': 'geometrycollection',
'datatype': 'geometrycollection'})
'sql-datatype': 'varbinary(1)',
'datatype': 'varbinary'})


class TestSelectsAppropriateColumns(unittest.TestCase):
Expand Down