]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- fixed bug where selectable.corresponding_column(selectable.c.col)
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 6 Jun 2007 23:39:25 +0000 (23:39 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 6 Jun 2007 23:39:25 +0000 (23:39 +0000)
would not return selectable.c.col, if the selectable is a join
of a table and another join involving the same table.  messed
up ORM decision making [ticket:593]
- removed is_natural_case function from ANSIIdentifierPreparer

CHANGES
lib/sqlalchemy/ansisql.py
lib/sqlalchemy/schema.py
lib/sqlalchemy/sql.py
test/sql/select.py
test/sql/selectable.py

diff --git a/CHANGES b/CHANGES
index 5f4e67e01354760002d98e7db09386ef4bb07d23..9952137830d4c364191cdf14b97e8c8c57fdfa2a 100644 (file)
--- a/CHANGES
+++ b/CHANGES
 - sql
   - long-identifier detection fixed to use > rather than >= for 
     max ident length [ticket:589]
+  - fixed bug where selectable.corresponding_column(selectable.c.col)
+     would not return selectable.c.col, if the selectable is a join
+     of a table and another join involving the same table.  messed
+     up ORM decision making [ticket:593]
+
 
 - mysql
   - added 'fields' to reserved words [ticket:590]
index 090368a58ed41d81e3c5c4a80dc78b4b18aff1ca..c489d7929ae618a555ee39f1b62547f92afee7de 100644 (file)
@@ -1042,9 +1042,6 @@ class ANSIIdentifierPreparer(object):
     def should_quote(self, object):
         return object.quote or self._requires_quotes(object.name, object.case_sensitive)
 
-    def is_natural_case(self, object):
-        return object.quote or self._requires_quotes(object.name, object.case_sensitive)
-
     def format_sequence(self, sequence):
         return self.__generic_obj_format(sequence, sequence.name)
 
index a27adf06eec604bec3cc977182c3669a095186c4..492210061e867005062eed4585a4d6bc4ff6672d 100644 (file)
@@ -103,6 +103,13 @@ class SchemaItem(object):
         return True
 
     def _get_case_sensitive(self):
+        """late-compile the 'case-sensitive' setting when first accessed.
+        
+        typically the SchemaItem will be assembled into its final structure
+        of other SchemaItems at this point, whereby it can attain this setting 
+        from its containing SchemaItem if not defined locally.
+        """
+        
         try:
             return self.__case_sensitive
         except AttributeError:
index 265a9c1fdfabb13c8fac9495b892b357d97084cc..afdfc9cb0919dd08926bf202da0441ddc6c5be8b 100644 (file)
@@ -1671,6 +1671,8 @@ class FromClause(Selectable):
           the exported columns of this ``FromClause``.
         """
 
+        if column in self.c:
+            return column
         if require_embedded and column not in util.Set(self._get_all_embedded_columns()):
             if not raiseerr:
                 return None
index 2f627ee8fe4fcd5567ada32b9ea9c6bcdc1540c6..557527d056ee150fe67f94947f4deb9f40c319d5 100644 (file)
@@ -249,6 +249,11 @@ sq.myothertable_othername AS sq_myothertable_othername FROM (" + sqstring + ") A
             table1.select((table1.c.myid != 12) & ~(table1.c.name=='john')), 
             "SELECT mytable.myid, mytable.name, mytable.description FROM mytable WHERE mytable.myid != :mytable_myid AND NOT (mytable.name = :mytable_name)"
         )
+
+        self.runtest(
+            table1.select((table1.c.myid != 12) & ~table1.c.name), 
+            "SELECT mytable.myid, mytable.name, mytable.description FROM mytable WHERE mytable.myid != :mytable_myid AND NOT mytable.name"
+        )
         
         self.runtest(
             literal("a") + literal("b") * literal("c"), ":literal + (:literal_1 * :literal_2)"
index cd434a18450187a9c5ae7a9e6bf2bb3421863d41..221d8430c409522cfd23bbdb24defe2c729eae61 100755 (executable)
@@ -27,6 +27,13 @@ table2 = Table('table2', db,
 )\r
 \r
 class SelectableTest(testbase.AssertMixin):\r
+    def testjoinagainstjoin(self):\r
+        j  = outerjoin(table, table2, table.c.col1==table2.c.col2)\r
+        jj = select([ table.c.col1.label('bar_col1')],from_obj=[j]).alias('foo')\r
+        jjj = join(table, jj, table.c.col1==jj.c.bar_col1)\r
+        assert jjj.corresponding_column(jjj.c.table1_col1) is jjj.c.table1_col1\r
+        \r
+        \r
     def testtablealias(self):\r
         a = table.alias('a')\r
         \r