Skip to content

Commit e61ad9a

Browse files
committed
fix #26 INSERT...SELECT causes an exception
1 parent bf40e41 commit e61ad9a

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

clickhouse_backend/driver/client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from .escape import escape_params
77

8-
insert_pattern = re.compile(r'\s*insert\s+into', flags=re.IGNORECASE)
8+
insert_pattern = re.compile(r'\s*insert\s+into.+?values\s*', flags=re.IGNORECASE)
99

1010

1111
class Client(client.Client):

tests/basic/tests.py

+7
Original file line numberDiff line numberDiff line change
@@ -829,3 +829,10 @@ def test_saving_an_object_again_does_not_create_a_new_object(self):
829829
a.headline = "Updated headline"
830830
a.save()
831831
self.assertEqual(a.id, current_id)
832+
833+
834+
class RawSQLTest(TestCase):
835+
def test_insert_select(self):
836+
table = Article._meta.db_table
837+
with connections[DEFAULT_DB_ALIAS].cursor() as cursor:
838+
cursor.execute(f'insert into {table} select * from {table}')

0 commit comments

Comments
 (0)