Skip to content
Closed
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
34 changes: 34 additions & 0 deletions tests/test_utils_parse_sql.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import pytest

from datajoint.utils import parse_sql


def test_parse_sql_with_trailing_delimiter(tmp_path):
sql_file = tmp_path / "script.sql"
sql_file.write_text(
"""
-- comment should be ignored
CREATE TABLE t (id INT);
INSERT INTO t VALUES (1);
"""
)
statements = list(parse_sql(sql_file))
assert statements == [
"CREATE TABLE t (id INT);",
"INSERT INTO t VALUES (1);",
]


def test_parse_sql_without_trailing_delimiter(tmp_path):
sql_file = tmp_path / "script.sql"
sql_file.write_text(
"""
CREATE TABLE t (id INT);
INSERT INTO t VALUES (1)
"""
)
statements = list(parse_sql(sql_file))
assert statements == [
"CREATE TABLE t (id INT);",
"INSERT INTO t VALUES (1)",
]
Loading