List:Commits« Previous MessageNext Message »
From:Reggie Burnett Date:May 26 2011 6:25pm
Subject:bzr commit into connector-net-6.3 branch (reggie.burnett:992)
View as plain text  
#At file:///C:/Users/Reggie/work/connector-net/6.3/ based on revid:reggie.burnett@stripped

  992 Reggie Burnett	2011-05-26 [merge]
      merge

    modified:
      CHANGES
      MySql.Data.Entity/Provider/Fragments/SqlFragment.cs
      MySql.Data.Entity/Provider/Generators/Scope.cs
      MySql.Data.Entity/Provider/Generators/SqlGenerator.cs
      MySql.Data.Entity/Provider/Properties/SchemaDefinition-5.0.ssdl
      MySql.Data.Entity/Provider/Statements/SelectStatement.cs
=== modified file 'CHANGES'
=== modified file 'CHANGES'
--- a/CHANGES	2011-05-24 01:49:52 +0000
+++ b/CHANGES	2011-05-26 18:25:11 +0000
@@ -31,7 +31,7 @@
   are now hidden when running on the Compact Framework (MySQL bug #60600).
 - Fixed MembershipProvider to only return exact matches when calling GetUser(string username) and 
   GetUserNameByEmail (MySQL bug #61027, Oracle bug #12562287).
-- added the ability to raise a join on the right side of a join to a derived table in EF code generation
+- added the ability to raise a join on the right side of a join to a derived table in EF code generation (bug #48791)
 
 Version 6.3.6
 - Fixed TracingDriver so that it normalizes long queries before truncation so we don't get exceptions     

=== modified file 'MySql.Data.Entity/Provider/Fragments/SqlFragment.cs'
--- a/MySql.Data.Entity/Provider/Fragments/SqlFragment.cs	2011-05-25 03:39:25 +0000
+++ b/MySql.Data.Entity/Provider/Fragments/SqlFragment.cs	2011-05-26 18:24:31 +0000
@@ -136,6 +136,10 @@
         public string TableName { get; set; }
         public string ColumnName { get; set; }
         public string ColumnAlias { get; set; }
+        public string ActualColumnName
+        {
+            get { return String.IsNullOrEmpty(ColumnName) ? ColumnAlias : ColumnName; }
+        }
         public PropertyFragment PropertyFragment { get; set; }
 
         public override void WriteSql(StringBuilder sql)

=== modified file 'MySql.Data.Entity/Provider/Generators/Scope.cs'
--- a/MySql.Data.Entity/Provider/Generators/Scope.cs	2010-08-18 19:48:34 +0000
+++ b/MySql.Data.Entity/Provider/Generators/Scope.cs	2011-05-26 18:24:31 +0000
@@ -24,6 +24,7 @@
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
+using System.Diagnostics;
 
 namespace MySql.Data.Entity
 {
@@ -64,5 +65,28 @@
                 return null;
             return scopeTable[name];
         }
+
+        public InputFragment FindInputFromProperties(PropertyFragment fragment)
+        {
+            Debug.Assert(fragment != null);
+            PropertyFragment propertyFragment = fragment as PropertyFragment;
+            Debug.Assert(propertyFragment != null);
+
+            if (propertyFragment.Properties.Count >= 2)
+            {
+                for (int x = propertyFragment.Properties.Count - 2; x >= 0; x--)
+                {
+                    string reference = propertyFragment.Properties[x];
+                    InputFragment input = GetFragment(reference);
+                    if (input == null) continue;
+                    if (input.Scoped) return input;
+                    if (input is SelectStatement)
+                        return (input as SelectStatement).From;
+                    continue;
+                }
+            }
+            Debug.Fail("Should have found an input");
+            return null;
+        }
     }
 }

=== modified file 'MySql.Data.Entity/Provider/Generators/SqlGenerator.cs'
--- a/MySql.Data.Entity/Provider/Generators/SqlGenerator.cs	2011-05-24 01:47:48 +0000
+++ b/MySql.Data.Entity/Provider/Generators/SqlGenerator.cs	2011-05-26 18:24:31 +0000
@@ -83,7 +83,7 @@
 
             ColumnFragment column = new ColumnFragment(null, fragment.LastProperty);
             column.PropertyFragment = fragment;
-            InputFragment input = FindInputFromProperties(fragment);
+            InputFragment input = scope.FindInputFromProperties(fragment);
             if (input != null)
                 column.TableName = input.Name;
 
@@ -102,29 +102,6 @@
             return column;
         }
 
-        private InputFragment FindInputFromProperties(PropertyFragment fragment)
-        {
-            Debug.Assert(fragment != null);
-            PropertyFragment propertyFragment = fragment as PropertyFragment;
-            Debug.Assert(propertyFragment != null);
-
-            if (propertyFragment.Properties.Count >= 2)
-            {
-                for (int x = propertyFragment.Properties.Count - 2; x >= 0; x--)
-                {
-                    string reference = propertyFragment.Properties[x];
-                    InputFragment input = scope.GetFragment(reference);
-                    if (input == null) continue;
-                    if (input.Scoped) return input;
-                    if (input is SelectStatement)
-                        return (input as SelectStatement).From;
-                    continue;
-                }
-            }
-            Debug.Fail("Should have found an input");
-            return null;
-        }
-
         public override SqlFragment Visit(DbScanExpression expression)
         {
             EntitySetBase target = expression.Target;

=== modified file 'MySql.Data.Entity/Provider/Properties/SchemaDefinition-5.0.ssdl'
--- a/MySql.Data.Entity/Provider/Properties/SchemaDefinition-5.0.ssdl	2011-03-03 17:57:57 +0000
+++ b/MySql.Data.Entity/Provider/Properties/SchemaDefinition-5.0.ssdl	2011-05-26 18:15:34 +0000
@@ -22,8 +22,8 @@
     <EntitySet Name="STableColumns" EntityType="Self.TableColumn">
       <DefiningQuery>
         SELECT /* Table columns */
-        CONCAT('`', TABLE_SCHEMA, '`.`', TABLE_NAME, '`.`', COLUMN_NAME, '`') AS `Id`,
-        CONCAT('`', TABLE_SCHEMA, '`.`', TABLE_NAME, '`') AS `ParentId`,
+        CONCAT(TABLE_SCHEMA, '.', TABLE_NAME, '.', COLUMN_NAME) AS `Id`,
+        CONCAT(TABLE_SCHEMA, '.', TABLE_NAME) AS `ParentId`,
         COLUMN_NAME AS `Name`,
         ORDINAL_POSITION AS `Ordinal`,
         CASE IS_NULLABLE WHEN 'YES' THEN 1 ELSE 0 END AS `IsNullable`,
@@ -52,7 +52,7 @@
     <EntitySet Name="SViews" EntityType="Self.View">
       <DefiningQuery>
         SELECT /* Views */
-        CONCAT('`', TABLE_SCHEMA, '`.`', TABLE_NAME, '`') AS `Id`,
+        CONCAT(TABLE_SCHEMA, '.', TABLE_NAME) AS `Id`,
         TABLE_CATALOG AS`CatalogName`,
         TABLE_SCHEMA AS `SchemaName`,
         TABLE_NAME AS `Name`,
@@ -65,8 +65,8 @@
     <EntitySet Name="SViewColumns" EntityType="Self.ViewColumn">
       <DefiningQuery>
         SELECT /* View columns */
-        CONCAT('`', TABLE_SCHEMA, '`.`', TABLE_NAME, '`.`', COLUMN_NAME, '`') AS `Id`,
-        CONCAT('`', TABLE_SCHEMA, '`.`', TABLE_NAME, '`') AS `ParentId`,
+        CONCAT(TABLE_SCHEMA, '.', TABLE_NAME, '.', COLUMN_NAME) AS `Id`,
+        CONCAT(TABLE_SCHEMA, '.', TABLE_NAME) AS `ParentId`,
         COLUMN_NAME AS `Name`,
         ORDINAL_POSITION AS `Ordinal`,
         CASE IS_NULLABLE WHEN 'YES' THEN 1 ELSE 0 END AS `IsNullable`,
@@ -95,7 +95,7 @@
     <EntitySet Name="SFunctions" EntityType="Self.Function">
       <DefiningQuery>
         SELECT /* Functions */
-        CONCAT('`', ROUTINE_SCHEMA, '`.`', SPECIFIC_NAME, '`') AS `Id`,
+        CONCAT(ROUTINE_SCHEMA, '.', SPECIFIC_NAME) AS `Id`,
         ROUTINE_CATALOG AS `CatalogName`,
         ROUTINE_SCHEMA AS `SchemaName`,
         ROUTINE_NAME AS `Name`,
@@ -123,7 +123,7 @@
     <EntitySet Name="SProcedures" EntityType="Self.Procedure">
       <DefiningQuery>
         SELECT /* Procedures */
-        CONCAT('`', ROUTINE_SCHEMA, '`.`', SPECIFIC_NAME, '`') AS `Id`,
+        CONCAT(ROUTINE_SCHEMA, '.', SPECIFIC_NAME) AS `Id`,
         ROUTINE_CATALOG AS `CatalogName`,
         ROUTINE_SCHEMA AS `SchemaName`,
         ROUTINE_NAME AS `Name`
@@ -186,8 +186,8 @@
     <EntitySet Name="SConstraints" EntityType="Self.Constraint">
       <DefiningQuery>
         SELECT  /* Constraints */
-        CONCAT('`', CONSTRAINT_SCHEMA, '`.`', TABLE_NAME, '`.`', CONSTRAINT_NAME, '`') AS `Id`,
-        CONCAT('`', TABLE_SCHEMA, '`.`', TABLE_NAME, '`') AS `ParentId`,
+        CONCAT(CONSTRAINT_SCHEMA, '.', TABLE_NAME, '.', CONSTRAINT_NAME) AS `Id`,
+        CONCAT(TABLE_SCHEMA, '.', TABLE_NAME) AS `ParentId`,
         CONSTRAINT_NAME AS `Name`,
         CONSTRAINT_TYPE AS `ConstraintType`,
         0 AS `IsDeferrable`,
@@ -208,8 +208,8 @@
     <EntitySet Name="SConstraintColumns" EntityType="Self.ConstraintColumn">
       <DefiningQuery>
         SELECT  /* Constraint columns */
-        CONCAT('`', CONSTRAINT_SCHEMA, '`.`', TABLE_NAME, '`.`', CONSTRAINT_NAME, '`') AS `ConstraintId`,
-        CONCAT('`', TABLE_SCHEMA, '`.`', TABLE_NAME, '`.`', COLUMN_NAME, '`') AS `ColumnId`
+        CONCAT(CONSTRAINT_SCHEMA, '.', TABLE_NAME, '.', CONSTRAINT_NAME) AS `ConstraintId`,
+        CONCAT(TABLE_SCHEMA, '.', TABLE_NAME, '.', COLUMN_NAME) AS `ColumnId`
         FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE TABLE_SCHEMA=schema()
       </DefiningQuery>
     </EntitySet>
@@ -217,7 +217,7 @@
     <EntitySet Name="SForeignKeyConstraints" EntityType="Self.ForeignKeyConstraint">
       <DefiningQuery>
         SELECT
-        CONCAT('`', CONSTRAINT_SCHEMA, '`.`', TABLE_NAME, '`.`', CONSTRAINT_NAME, '`') AS `Id`,
+        CONCAT(CONSTRAINT_SCHEMA, '.', TABLE_NAME, '.', CONSTRAINT_NAME) AS `Id`,
         'NO ACTION' AS `UpdateRule`,
         'NO ACTION' AS `DeleteRule`
         FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE CONSTRAINT_TYPE='FOREIGN KEY'
@@ -227,10 +227,10 @@
     <EntitySet Name="SForeignKeys" EntityType="Self.ForeignKey">
       <DefiningQuery>
         SELECT  /* Foreign keys */
-        CONCAT('`', KCU.TABLE_SCHEMA, '`.`', KCU.CONSTRAINT_NAME, '`.`', KCU.ORDINAL_POSITION, '`') AS `Id`,
-        CONCAT('`', KCU.REFERENCED_TABLE_SCHEMA, '`.`', KCU.REFERENCED_TABLE_NAME, '`.`', KCU.REFERENCED_COLUMN_NAME, '`') AS `ToColumnId`,
-        CONCAT('`', KCU.TABLE_SCHEMA, '`.`', KCU.TABLE_NAME, '`.`', KCU.COLUMN_NAME, '`') AS `FromColumnId`,
-        CONCAT('`', KCU.TABLE_SCHEMA, '`.`', KCU.TABLE_NAME, '`.`', KCU.CONSTRAINT_NAME, '`') AS `ConstraintId`,
+        CONCAT(KCU.TABLE_SCHEMA, '.', KCU.CONSTRAINT_NAME, '.', KCU.ORDINAL_POSITION) AS `Id`,
+        CONCAT(KCU.REFERENCED_TABLE_SCHEMA, '.', KCU.REFERENCED_TABLE_NAME, '.', KCU.REFERENCED_COLUMN_NAME) AS `ToColumnId`,
+        CONCAT(KCU.TABLE_SCHEMA, '.', KCU.TABLE_NAME, '.', KCU.COLUMN_NAME) AS `FromColumnId`,
+        CONCAT(KCU.TABLE_SCHEMA, '.', KCU.TABLE_NAME, '.', KCU.CONSTRAINT_NAME) AS `ConstraintId`,
         KCU.ORDINAL_POSITION AS `Ordinal`
         FROM
         INFORMATION_SCHEMA.TABLE_CONSTRAINTS TC

=== modified file 'MySql.Data.Entity/Provider/Statements/SelectStatement.cs'
--- a/MySql.Data.Entity/Provider/Statements/SelectStatement.cs	2011-05-25 03:39:25 +0000
+++ b/MySql.Data.Entity/Provider/Statements/SelectStatement.cs	2011-05-26 18:24:31 +0000
@@ -118,19 +118,19 @@
         {
             base.Wrap(scope);
 
+            // now we need to add default columns if necessary
+            if (Columns.Count == 0)
+                AddDefaultColumns(scope);
+
             // next we need to remove child extents of the select from scope
             if (Name != null)
             {
                 scope.Remove(this);
                 scope.Add(Name, this);
             }
-
-            // now we need to add default columns if necessary
-            if (Columns.Count == 0)
-                AddDefaultColumns();
         }
 
-        void AddDefaultColumns()
+        void AddDefaultColumns(Scope scope)
         {
             if (columnHash == null)
                 columnHash = new Dictionary<string, ColumnFragment>();
@@ -139,7 +139,11 @@
 
             foreach (ColumnFragment column in columns)
             {
-                column.TableName = column.PropertyFragment.Properties[0];
+                // first we need to set the input for this column
+                InputFragment input = scope.FindInputFromProperties(column.PropertyFragment);
+                column.TableName = input.Name;
+
+                // then we rename the column if necessary
                 if (columnHash.ContainsKey(column.ColumnName))
                 {
                     column.ColumnAlias = MakeColumnNameUnique(column.ColumnName);
@@ -174,8 +178,8 @@
                 SelectStatement select = input as SelectStatement;
                 foreach (ColumnFragment cf in select.Columns)
                 {
-                    ColumnFragment newColumn = new ColumnFragment(cf.TableName, cf.ColumnName);
-                    newColumn.PushInput(cf.ColumnName);
+                    ColumnFragment newColumn = new ColumnFragment(cf.TableName, cf.ActualColumnName);
+                    newColumn.PushInput(cf.ActualColumnName);
                     columns.Add(newColumn);
                 }
             }

No bundle (reason: revision is a merge (you can force generation of a bundle with env var BZR_FORCE_BUNDLE=1)).
Thread
bzr commit into connector-net-6.3 branch (reggie.burnett:992) Reggie Burnett26 May