Пример #1
0
    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)))
Пример #2
0
    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)))
Пример #3
0
    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)))
Пример #4
0
    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)))
Пример #5
0
    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)))
Пример #6
0
 def test_split_sql_nothing_interesting(self):
     text = "abcd123"
     expected = [(None, None, "abcd123")]
     self.assertEqual(expected, list(sqlprep.split_sql(text)))
Пример #7
0
 def test_split_sql_trailing_semicolon(self):
     text = "abcd123;"
     expected = [(None, ";", "abcd123"), (";", None, '')]
     self.assertEqual(expected, list(sqlprep.split_sql(text)))
Пример #8
0
 def test_split_sql_nothing_interesting(self):
     text = "abcd123"
     expected = [(None, None, "abcd123")]
     self.assertEquals(expected, list(sqlprep.split_sql(text)))
Пример #9
0
 def test_split_sql_trailing_semicolon(self):
     text = "abcd123;"
     expected = [(None, ";", "abcd123"), (";", None, '')]
     self.assertEquals(expected, list(sqlprep.split_sql(text)))
Пример #10
0
    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)))
Пример #11
0
 def test_split_sql_trailing_semicolon(self):
     text = "abcd123;"
     expected = [text]
     self.assertEqual(expected, list(sqlprep.split_sql(text)))