]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Check some edge cases
authorAlessio Bogon <youtux@gmail.com>
Sun, 1 Sep 2019 11:56:05 +0000 (13:56 +0200)
committerAlessio Bogon <youtux@gmail.com>
Sun, 1 Sep 2019 11:56:05 +0000 (13:56 +0200)
test/ext/test_linter.py

index da9cce1748646a5a5c87eeb93f209a11257af490..763090b0913c2966659dbbec36517fdb4778e006 100644 (file)
@@ -161,6 +161,12 @@ class TestFinder(fixtures.TablesTest):
         assert start == self.d
         assert froms == {self.a, self.b, self.c}
 
+    def test_no_froms(self):
+        query = (select([1]))
+
+        froms, start = find_unmatching_froms(query)
+        assert not froms
+
 
 class TestLinter(fixtures.TablesTest):
     @classmethod
@@ -177,6 +183,15 @@ class TestLinter(fixtures.TablesTest):
         self.d = self.tables.table_d
         event.listen(testing.db, 'before_execute', linter.before_execute_hook)
 
+    def test_noop_for_unhandled_objects(self):
+        with testing.db.connect() as conn:
+            conn.execute('SELECT 1;').fetchone()
+
+    def test_does_not_modify_query(self):
+        with testing.db.connect() as conn:
+            [result] = conn.execute(select([1])).fetchone()
+            assert result == 1
+
     def test_integration(self):
         query = (
             select([self.a])