Skip to content

Commit eca2412

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

File tree

5 files changed

+12
-13
lines changed

5 files changed

+12
-13
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: 2 additions & 10 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(
@@ -88,8 +87,6 @@ def test_select_insert(self):
8887
self.assertEqual(res, a)
8988

9089

91-
92-
9390
@with_native_and_http_sessions
9491
class GeoMultiPolygonTestCase(BaseTestCase):
9592
table = Table(
@@ -104,7 +101,6 @@ def test_create_table(self):
104101
'CREATE TABLE test (mpg MultiPolygon) ENGINE = Memory'
105102
)
106103

107-
108104
def test_select_insert(self):
109105
a = [[[(0, 0), (10, 0), (10, 10), (0, 10)]], [[(20, 20), (50, 20), (50, 50), (20, 50)],[(30, 30), (50, 50), (50, 30)]]]
110106

@@ -113,7 +109,3 @@ def test_select_insert(self):
113109
qres = self.session.query(self.table.c.mpg)
114110
res = qres.scalar()
115111
self.assertEqual(res, a)
116-
117-
118-
119-

0 commit comments

Comments
 (0)