def test_errors(self, statement, expected_num_errors):
        tokens = parser.parse_statement(statement)
        parsed_sql = [(statement, tokens)]

        result = StatementTimeoutMissingCheck.errors(parsed_sql)

        assert len(result) == expected_num_errors
    def test_errors(self):
        statement = "CREATE INDEX column_idx ON table (column)"
        tokens = parser.parse_statement(statement)
        parsed_sql = [(statement, tokens)]

        [error] = CreateIndexNotConcurrentlyCheck.errors(parsed_sql)

        assert error.code == "M202"
        assert error.line == 1
Ejemplo n.º 3
0
    def test_errors(self):
        statement = "ALTER TABLE ADD COLUMN NOT NULL"
        tokens = parser.parse_statement(statement)
        parsed_sql = [(statement, tokens)]

        [error] = AddColumnNotNullNoDefaultCheck.errors(parsed_sql)

        assert error.code == "M201"
        assert error.line == 1
Ejemplo n.º 4
0
    def check_sql(self, source: types.Source) -> List[types.MigrationError]:
        """Return all errors found."""
        parsed = []
        for statement in parser.split_sql(source):
            tokens = parser.parse_statement(statement)
            parsed.append((statement, tokens))

        errors = []
        for check in self.check_list:
            errors.extend(check.errors(parsed))

        return errors
 def test_is_applicable(self, statement, expected_is_match):
     tokens = parser.parse_statement(statement)
     assert (CreateIndexNotConcurrentlyCheck.is_applicable(tokens) is
             expected_is_match)
Ejemplo n.º 6
0
 def test_is_applicable(self, statement, expected_is_match):
     tokens = parser.parse_statement(statement)
     assert AddColumnNotNullNoDefaultCheck.is_applicable(tokens) is expected_is_match
Ejemplo n.º 7
0
 def test_is_match(self, statement, expected_is_match):
     tokens = parser.parse_statement(statement)
     assert NoDefaultValueSelector.is_match(tokens) is expected_is_match
Ejemplo n.º 8
0
 def test_is_match(self, statement, expected_is_match):
     tokens = parser.parse_statement(statement)
     assert AddColumnSelector.is_match(tokens) is expected_is_match