Skip to content

Commit b5c811c

Browse files
author
Greger Stolt Nilsen
committed
Cleanups
1 parent 007cfec commit b5c811c

File tree

5 files changed

+18
-16
lines changed

5 files changed

+18
-16
lines changed

clickhouse_sqlalchemy/drivers/compilers/typecompiler.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def visit_map(self, type_, **kw):
131131
self.process(key_type, **kw),
132132
self.process(value_type, **kw)
133133
)
134-
134+
135135
def visit_point(self, type_, **kw):
136136
return 'Point'
137137

@@ -143,4 +143,3 @@ def visit_polygon(self, type_, *kw):
143143

144144
def visit_multipolygon(self, type_, *kw):
145145
return 'MultiPolygon'
146-

clickhouse_sqlalchemy/drivers/http/transport.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,29 @@ def nullable_converter(subtype_str, x):
4646
def nothing_converter(x):
4747
return None
4848

49+
4950
POINT_RE = re.compile(r'(-?\d*\.?\d+)')
5051
RING_RE = re.compile(r'(\(.*?\))')
5152
POLYGON_RE = re.compile(r'(\[.*?\])')
5253
MULTIPOLYGON_RE = re.compile(r'\[\[.*?\]\]')
5354

55+
5456
def point_converter(x):
5557
return tuple([float(f) for f in POINT_RE.findall(x[1:-1])])
5658

59+
5760
def ring_converter(x):
5861
return [point_converter(f) for f in RING_RE.findall(x[1:-1])]
5962

63+
6064
def polygon_converter(x):
6165
return [ring_converter(f) for f in POLYGON_RE.findall(x[1:-1])]
6266

67+
6368
def multipolygon_converter(x):
6469
return [polygon_converter(f) for f in MULTIPOLYGON_RE.findall(x[1:-1])]
6570

71+
6672
converters = {
6773
'Int8': int,
6874
'UInt8': int,

clickhouse_sqlalchemy/types/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,3 @@
7777
from .geo import Ring
7878
from .geo import Polygon
7979
from .geo import MultiPolygon
80-

clickhouse_sqlalchemy/types/geo.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
class Point(types.UserDefinedType):
55
__visit_name__ = "point"
66

7+
78
class Ring(types.UserDefinedType):
89
__visit_name__ = "ring"
910

11+
1012
class Polygon(types.UserDefinedType):
1113
__visit_name__ = "polygon"
1214

15+
1316
class MultiPolygon(types.UserDefinedType):
1417
__visit_name__ = "multipolygon"

tests/types/test_geo.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from tests.testcase import BaseTestCase
66
from tests.util import with_native_and_http_sessions
77

8+
89
@with_native_and_http_sessions
910
class GeoPointTestCase(BaseTestCase):
1011
table = Table(
@@ -18,7 +19,7 @@ def test_create_table(self):
1819
self.compile(CreateTable(self.table)),
1920
'CREATE TABLE test (p Point) ENGINE = Memory'
2021
)
21-
22+
2223
def test_select_insert(self):
2324
a = (10.1, 12.3)
2425

@@ -38,8 +39,6 @@ def test_select_where_point(self):
3839
self.table.c.p == (10.1, 12.3)).scalar(), a)
3940

4041

41-
42-
4342
@with_native_and_http_sessions
4443
class GeoRingTestCase(BaseTestCase):
4544
table = Table(
@@ -53,7 +52,7 @@ def test_create_table(self):
5352
self.compile(CreateTable(self.table)),
5453
'CREATE TABLE test (r Ring) ENGINE = Memory'
5554
)
56-
55+
5756
def test_select_insert(self):
5857
a = [(0, 0), (10, 0), (10, 10), (0, 10)]
5958

@@ -79,7 +78,8 @@ def test_create_table(self):
7978
)
8079

8180
def test_select_insert(self):
82-
a = [[(20, 20), (50, 20), (50, 50), (20, 50)], [(30, 30), (50, 50), (50, 30)]]
81+
a = [[(20, 20), (50, 20), (50, 50), (20, 50)],
82+
[(30, 30), (50, 50), (50, 30)]]
8383

8484
with self.create_table(self.table):
8585
self.session.execute(self.table.insert(), [{'pg': a}])
@@ -88,8 +88,6 @@ def test_select_insert(self):
8888
self.assertEqual(res, a)
8989

9090

91-
92-
9391
@with_native_and_http_sessions
9492
class GeoMultiPolygonTestCase(BaseTestCase):
9593
table = Table(
@@ -104,16 +102,13 @@ def test_create_table(self):
104102
'CREATE TABLE test (mpg MultiPolygon) ENGINE = Memory'
105103
)
106104

107-
108105
def test_select_insert(self):
109-
a = [[[(0, 0), (10, 0), (10, 10), (0, 10)]], [[(20, 20), (50, 20), (50, 50), (20, 50)],[(30, 30), (50, 50), (50, 30)]]]
106+
a = [[[(0, 0), (10, 0), (10, 10), (0, 10)]],
107+
[[(20, 20), (50, 20), (50, 50), (20, 50)],
108+
[(30, 30), (50, 50), (50, 30)]]]
110109

111110
with self.create_table(self.table):
112111
self.session.execute(self.table.insert(), [{'mpg': a}])
113112
qres = self.session.query(self.table.c.mpg)
114113
res = qres.scalar()
115114
self.assertEqual(res, a)
116-
117-
118-
119-

0 commit comments

Comments
 (0)