def test_split_sql_comment_between_statements(self): text = "select a from b;\n" text += "--comment here\n" text += "select a from b;" expected = ["select a from b;","\n\nselect a from b;"] self.assertEqual(expected, list(sqlprep.split_sql(text)))
def test_split_sql_inline_comment(self): text = "select a from b; --comment here\n" text += "select a from b;" expected = [(None, ";", "select a from b"), (";", "--", ' '), ("--", "\n", 'comment here'), ("\n", ";", 'select a from b'), (";", None, '')] self.assertEqual(expected, list(sqlprep.split_sql(text)))
def test_split_sql_inline_comment(self): text = "select a from b; --comment here\n" text += "select a from b;" expected = [(None, ";", "select a from b"), (";", "--", ' '), ("--", "\n", 'comment here'), ("\n", ";", 'select a from b'), (";", None, '')] self.assertEquals(expected, list(sqlprep.split_sql(text)))
def test_split_sql_comment_between_statements(self): text = "select a from b;\n" text += "--comment here\n" text += "select a from b;" expected = [(None, ";", "select a from b"), (";", "\n", ''), ("\n", "--", ''), ("--", "\n", 'comment here'), ("\n", ";", 'select a from b'), (";", None, '')] self.assertEquals(expected, list(sqlprep.split_sql(text)))
def test_split_sql_comment_between_statements(self): text = "select a from b;\n" text += "--comment here\n" text += "select a from b;" expected = [(None, ";", "select a from b"), (";", "\n", ''), ("\n", "--", ''), ("--", "\n", 'comment here'), ("\n", ";", 'select a from b'), (";", None, '')] self.assertEqual(expected, list(sqlprep.split_sql(text)))
def test_split_sql_nothing_interesting(self): text = "abcd123" expected = [(None, None, "abcd123")] self.assertEqual(expected, list(sqlprep.split_sql(text)))
def test_split_sql_trailing_semicolon(self): text = "abcd123;" expected = [(None, ";", "abcd123"), (";", None, '')] self.assertEqual(expected, list(sqlprep.split_sql(text)))
def test_split_sql_nothing_interesting(self): text = "abcd123" expected = [(None, None, "abcd123")] self.assertEquals(expected, list(sqlprep.split_sql(text)))
def test_split_sql_trailing_semicolon(self): text = "abcd123;" expected = [(None, ";", "abcd123"), (";", None, '')] self.assertEquals(expected, list(sqlprep.split_sql(text)))
def test_split_sql_inline_comment(self): text = "select a from b; --comment here\n" text += "select a from b;" expected = ["select a from b;", " \nselect a from b;"] self.assertEqual(expected, list(sqlprep.split_sql(text)))
def test_split_sql_trailing_semicolon(self): text = "abcd123;" expected = [text] self.assertEqual(expected, list(sqlprep.split_sql(text)))