]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- some more interpret_as_froms
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 24 Jul 2012 00:59:46 +0000 (20:59 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 24 Jul 2012 00:59:46 +0000 (20:59 -0400)
lib/sqlalchemy/sql/expression.py
test/aaa_profiling/test_resultset.py
test/orm/test_query.py

index a518852d89e9d426ee656f249d7ef35507ca58f3..a26a71f16341d8725601e41e0b948d66323b124b 100644 (file)
@@ -3665,8 +3665,8 @@ class Join(FromClause):
         :class:`.FromClause` object.
 
         """
-        self.left = _literal_as_text(left)
-        self.right = _literal_as_text(right).self_group()
+        self.left = _interpret_as_from(left)
+        self.right = _interpret_as_from(right).self_group()
 
         if onclause is None:
             self.onclause = self._match_primaries(self.left, self.right)
@@ -4886,7 +4886,7 @@ class Select(SelectBase):
 
         if from_obj is not None:
             self._from_obj = util.OrderedSet(
-                                _literal_as_text(f)
+                                _interpret_as_from(f)
                                 for f in util.to_list(from_obj))
         else:
             self._from_obj = util.OrderedSet()
index bb16ea1240639643fa276e8170f81bb56da883eb..f6687f3dd4368c65dc499129ecd6941a552ec568 100644 (file)
@@ -38,8 +38,8 @@ class ResultSetTest(fixtures.TestBase, AssertsExecutionResults):
                                     '2.4': 13214,
                                     '2.6':14416,
                                     '2.7':14416,
-                                   '2.6+cextension': 336,
-                                   '2.7+cextension':336})
+                                   '2.6+cextension': 354,
+                                   '2.7+cextension':354})
     def test_string(self):
         [tuple(row) for row in t.select().execute().fetchall()]
 
@@ -48,8 +48,8 @@ class ResultSetTest(fixtures.TestBase, AssertsExecutionResults):
     @profiling.function_call_count(versions={
                                     '2.7':14396,
                                     '2.6':14396,
-                                   '2.6+cextension': 336, 
-                                   '2.7+cextension':336})
+                                   '2.6+cextension': 354,
+                                   '2.7+cextension':354})
     def test_unicode(self):
         [tuple(row) for row in t2.select().execute().fetchall()]
 
@@ -72,8 +72,8 @@ class ExecutionTest(fixtures.TestBase):
         # ensure initial connect activities complete
         c.execute("select 1")
 
-        @profiling.function_call_count(versions={'2.7':40, '2.6':40, '2.5':35, 
-                                                    '2.4':21, '3':40}, 
+        @profiling.function_call_count(versions={'2.7':40, '2.6':40, '2.5':35,
+                                                    '2.4':21, '3':40},
                                             variance=.10)
         def go():
             c.execute("select 1")
@@ -85,10 +85,10 @@ class ExecutionTest(fixtures.TestBase):
         # ensure initial connect activities complete
         e.execute("select 1")
 
-        @profiling.function_call_count(versions={'2.4':41, '2.5':65, 
+        @profiling.function_call_count(versions={'2.4':41, '2.5':65,
                                                     '2.6':65, '3':61,
                                                     '2.7':65,
-                                                    '2.6+cextension':65}, 
+                                                    '2.6+cextension':65},
                                             variance=.05)
         def go():
             e.execute("select 1")
index b80db67ebc066975f6e99671db9dd7374603bd59..44e016c861b3914d549fe571edafe16fea893c72 100644 (file)
@@ -130,6 +130,14 @@ class RawSelectTest(QueryTest, AssertsCompiledSQL):
             "SELECT * FROM users"
         )
 
+    def test_inline_select_from_entity(self):
+        User = self.classes.User
+
+        self.assert_compile(
+            select(['*'], from_obj=User),
+            "SELECT * FROM users"
+        )
+
     def test_select_from_aliased_entity(self):
         User = self.classes.User
         ua = aliased(User, name="ua")
@@ -193,6 +201,16 @@ class RawSelectTest(QueryTest, AssertsCompiledSQL):
             "SELECT ua.id, ua.name FROM users AS ua"
         )
 
+    def test_core_join(self):
+        User = self.classes.User
+        Address = self.classes.Address
+        from sqlalchemy.sql import join
+        self.assert_compile(
+            select([User]).select_from(join(User, Address)),
+            "SELECT users.id, users.name FROM users "
+            "JOIN addresses ON users.id = addresses.user_id"
+        )
+
 class GetTest(QueryTest):
     def test_get(self):
         User = self.classes.User