Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion altimate_packages/altimate/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def sql_parse_errors(sql: str, dialect: str):

def get_start_and_end_position(sql: str, invalid_string: str):
start, end, num_occurences = find_single_occurrence_indices(sql, invalid_string)
if start and end:
if start is not None and end is not None:
return (
list(get_line_and_column_from_position(sql, start)),
list(get_line_and_column_from_position(sql, end)),
Expand Down
15 changes: 15 additions & 0 deletions altimate_packages/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import sys
import unittest
sys.path.insert(0, 'altimate_packages')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider avoiding manual sys.path insertion; setting PYTHONPATH or using proper package installation can improve test reliability.

from altimate.utils import get_start_and_end_position

class TestGetStartEndPosition(unittest.TestCase):
def test_invalid_token_at_beginning(self):
sql = "invalid_token SELECT * FROM table"
start, end, count = get_start_and_end_position(sql, "invalid_token")
self.assertEqual(start, [0, 1])
self.assertEqual(end, [0, len("invalid_token") + 1])
self.assertEqual(count, 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test case, doesn't test new behavior.


if __name__ == "__main__":
unittest.main()
Loading