File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ import pytest
2+
3+ from datajoint .utils import parse_sql
4+
5+
6+ def test_parse_sql_with_trailing_delimiter (tmp_path ):
7+ sql_file = tmp_path / "script.sql"
8+ sql_file .write_text (
9+ """
10+ -- comment should be ignored
11+ CREATE TABLE t (id INT);
12+ INSERT INTO t VALUES (1);
13+ """
14+ )
15+ statements = list (parse_sql (sql_file ))
16+ assert statements == [
17+ "CREATE TABLE t (id INT);" ,
18+ "INSERT INTO t VALUES (1);" ,
19+ ]
20+
21+
22+ def test_parse_sql_without_trailing_delimiter (tmp_path ):
23+ sql_file = tmp_path / "script.sql"
24+ sql_file .write_text (
25+ """
26+ CREATE TABLE t (id INT);
27+ INSERT INTO t VALUES (1)
28+ """
29+ )
30+ statements = list (parse_sql (sql_file ))
31+ assert statements == [
32+ "CREATE TABLE t (id INT);" ,
33+ "INSERT INTO t VALUES (1)" ,
34+ ]
You can’t perform that action at this time.
0 commit comments