Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#12 #134

Merged
merged 3 commits into from
Jul 26, 2021
Merged

#12 #134

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
4 changes: 4 additions & 0 deletions clickhouse_sqlalchemy/drivers/http/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ def execute(self, operation, parameters=None, context=None):
if parameters is not None:
raw_sql = raw_sql % self._params_escaper.escape(parameters)

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

self._reset_state()
self._begin_query()

Expand Down
10 changes: 7 additions & 3 deletions tests/drivers/http/test_cursor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from tests.testcase import HttpSessionTestCase
from tests.testcase import HttpSessionTestCase, HttpEngineTestCase


class CursorTestCase(HttpSessionTestCase):
def test_check_iter_cursor(self):
class CursorTestCase(HttpSessionTestCase, HttpEngineTestCase):
def test_check_iter_cursor_by_session(self):
rv = self.session.execute('SELECT number FROM system.numbers LIMIT 5')
self.assertListEqual(list(rv), [(x,) for x in range(5)])

def test_check_iter_cursor_by_engine(self):
rv = self.engine.execute('SELECT number FROM system.numbers LIMIT 5')
self.assertListEqual(list(rv), [(x,) for x in range(5)])
6 changes: 4 additions & 2 deletions tests/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
from clickhouse_sqlalchemy import make_session
from tests.config import http_uri, native_uri, system_native_uri

http_session = make_session(create_engine(http_uri))
http_engine = create_engine(http_uri)
http_session = make_session(http_engine)
http_stream_session = make_session(create_engine(http_uri + '?stream=1'))
native_session = make_session(create_engine(native_uri))
native_engine = create_engine(native_uri)
native_session = make_session(native_engine)

system_native_session = make_session(create_engine(system_native_uri))

Expand Down
7 changes: 6 additions & 1 deletion tests/testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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
from tests.session import http_session, native_session, system_native_session, http_engine, native_engine
from tests.util import skip_by_server_version


Expand Down Expand Up @@ -96,6 +96,11 @@ 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