Skip to content

Commit

Permalink
Fix #134
Browse files Browse the repository at this point in the history
  • Loading branch information
xzkostyan committed Jul 26, 2021
1 parent 14958fb commit 2cc7c49
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions clickhouse_sqlalchemy/drivers/http/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

import sqlalchemy as sa

from .utils import FORMAT_SUFFIX
from ...util.compat import string_types
from ..base import ClickHouseDialect, ClickHouseExecutionContextBase
from . import connector
Expand All @@ -8,8 +10,6 @@
# Export connector version
VERSION = (0, 0, 2, None)

FORMAT_SUFFIX = 'FORMAT TabSeparatedWithNamesAndTypes'


class ClickHouseExecutionContext(ClickHouseExecutionContextBase):
def pre_exec(self):
Expand Down
3 changes: 2 additions & 1 deletion clickhouse_sqlalchemy/drivers/http/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from .escaper import Escaper
from .transport import RequestsTransport
from .utils import FORMAT_SUFFIX

# PEP 249 module globals
apilevel = '2.0'
Expand Down Expand Up @@ -109,7 +110,7 @@ def execute(self, operation, parameters=None, context=None):

raw_sql_big = raw_sql.upper()
if 'FORMAT' not in raw_sql_big and 'INSERT' not in raw_sql_big:
raw_sql += ' FORMAT TabSeparatedWithNamesAndTypes'
raw_sql += ' ' + FORMAT_SUFFIX

self._reset_state()
self._begin_query()
Expand Down
3 changes: 3 additions & 0 deletions clickhouse_sqlalchemy/drivers/http/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import codecs


FORMAT_SUFFIX = 'FORMAT TabSeparatedWithNamesAndTypes'


def unescape(value, errors=None):
if errors is None:
errors = 'replace'
Expand Down
5 changes: 4 additions & 1 deletion tests/testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
from sqlalchemy.orm import Query

from tests.config import database, host, port, http_port, user, password
from tests.session import http_session, native_session, system_native_session, http_engine, native_engine
from tests.session import http_session, native_session, \
system_native_session, http_engine
from tests.util import skip_by_server_version


Expand Down Expand Up @@ -96,12 +97,14 @@ class HttpSessionTestCase(BaseTestCase):
port = http_port
session = http_session


class HttpEngineTestCase(BaseTestCase):
""" Explicitly HTTP-based session Test Case """

port = http_port
engine = http_engine


class NativeSessionTestCase(BaseTestCase):
""" Explicitly Native-protocol-based session Test Case """

Expand Down

0 comments on commit 2cc7c49

Please sign in to comment.