List:Commits« Previous MessageNext Message »
From:Reggie Burnett Date:July 8 2010 9:53pm
Subject:bzr commit into connector-net-trunk branch (reggie.burnett:893)
View as plain text  
#At file:///C:/work/bzr-connector-net/clean-trunk/ based on revid:vvaintroub@stripped

  893 Reggie Burnett	2010-07-08
      fixed exception that was produced when generating the database from a model after the first time.  The issue was databaseName being null.  We chose to not include database name in the generated script since MySQL doesn't support schemas and this would allow the user to target the MySQL db of his/her choice.

    modified:
      MySql.Data.Entity/T4Templates/GenerateMySQL.Utility.ttinclude
      MySql.Data.Entity/T4Templates/SSDLToMySQL.tt
=== modified file 'MySql.Data.Entity/T4Templates/GenerateMySQL.Utility.ttinclude'
=== modified file 'MySql.Data.Entity/T4Templates/GenerateMySQL.Utility.ttinclude'
--- a/MySql.Data.Entity/T4Templates/GenerateMySQL.Utility.ttinclude	2010-04-09 19:38:48 +0000
+++ b/MySql.Data.Entity/T4Templates/GenerateMySQL.Utility.ttinclude	2010-07-08 21:53:20 +0000
@@ -42,7 +42,8 @@
 /// </summary>
 private static string MyId(string userIdentifier) 
 {
-    return userIdentifier.Replace("`", "``");
+	if (String.IsNullOrEmpty(userIdentifier)) return userIdentifier;
+	return userIdentifier.Replace("`", "``");
 }
 
 private static bool IsIdentity(EdmProperty property, Version targetVersion)

=== modified file 'MySql.Data.Entity/T4Templates/SSDLToMySQL.tt'
--- a/MySql.Data.Entity/T4Templates/SSDLToMySQL.tt	2010-05-20 04:15:01 +0000
+++ b/MySql.Data.Entity/T4Templates/SSDLToMySQL.tt	2010-07-08 21:53:20 +0000
@@ -45,6 +45,7 @@
 <#
     }
 #>
+
 -- -----------------------------------------------------------
 -- Entity Designer DDL Script for MySQL Server 4.1 and higher
 -- -----------------------------------------------------------
@@ -54,6 +55,7 @@
     {
 #>
 -- Generated from EDMX file: <#=MyId(edmxPath)#>
+-- Target version: <#=MyId(targetVersion.ToString())#>
 <#
     }
 #>
@@ -80,11 +82,10 @@
         ReferentialConstraint constraint = associationSet.ElementType.ReferentialConstraints.Single();
         string constraintName = MyId(WriteFKConstraintName(constraint));
         AssociationSetEnd dependentSetEnd = associationSet.AssociationSetEnds.Where(ase => ase.CorrespondingAssociationEndMember == constraint.ToRole).Single();
-        string schemaName = MyId(dependentSetEnd.EntitySet.GetSchemaName());
         string dependentTableName = MyId(dependentSetEnd.EntitySet.GetTableName());
         
 #>
---    ALTER TABLE `<#=databaseName#>`.`<#=dependentTableName#>` DROP CONSTRAINT `<#=constraintName#>`;
+--    ALTER TABLE `<#=dependentTableName#>` DROP CONSTRAINT `<#=constraintName#>`;
 <#
     }
 #>
@@ -96,10 +97,9 @@
 <#
     foreach (EntitySet entitySet in ExistingStore.GetAllEntitySets())
     { 
-        string schemaName = MyId(entitySet.GetSchemaName());
         string tableName = MyId(entitySet.GetTableName());
 #>
-    DROP TABLE IF EXISTS `<#=databaseName#>`.`<#=tableName#>`;
+    DROP TABLE IF EXISTS `<#=tableName#>`;
 <#
     }
 #>
@@ -112,12 +112,11 @@
 <#
     foreach (EntitySet entitySet in Store.GetAllEntitySets())
     {
-        string schemaName = MyId(entitySet.GetSchemaName());
         string tableName = MyId(entitySet.GetTableName());
 #>
 -- Creating table '<#=tableName#>'
 
-CREATE TABLE `<#=databaseName#>`.`<#=tableName#>` (
+CREATE TABLE `<#=tableName#>` (
 <#
         for (int p = 0; p < entitySet.ElementType.Properties.Count; p++)
         {
@@ -132,6 +131,8 @@
 <# 
     } 
 #>
+
+
 -- --------------------------------------------------
 -- Creating all PRIMARY KEY constraints
 -- --------------------------------------------------
@@ -139,7 +140,6 @@
 <#
     foreach (EntitySet entitySet in Store.GetAllEntitySets())
     {
-        string schemaName = MyId(entitySet.GetSchemaName());
         string tableName = MyId(entitySet.GetTableName());
 		
 		bool hasAutoColumn = false;
@@ -155,13 +155,15 @@
 #>
 -- Creating primary key on <#=WriteMySqlColumns(entitySet.ElementType.GetKeyProperties(), ',')#> in table '<#=tableName#>'
 
-ALTER TABLE `<#=databaseName#>`.`<#=tableName#>`
+ALTER TABLE `<#=tableName#>`
 ADD CONSTRAINT `PK_<#=tableName#>`
     PRIMARY KEY (<#=WriteMySqlColumns(entitySet.ElementType.GetKeyProperties(), ',')#> );
 
 <#
     }
 #>
+
+
 -- --------------------------------------------------
 -- Creating all FOREIGN KEY constraints
 -- --------------------------------------------------
@@ -172,16 +174,15 @@
         ReferentialConstraint constraint = associationSet.ElementType.ReferentialConstraints.Single();
         AssociationSetEnd dependentSetEnd = associationSet.AssociationSetEnds.Where(ase => ase.CorrespondingAssociationEndMember == constraint.ToRole).Single();
         AssociationSetEnd principalSetEnd = associationSet.AssociationSetEnds.Where(ase => ase.CorrespondingAssociationEndMember == constraint.FromRole).Single();
-        string schemaName = MyId(dependentSetEnd.EntitySet.GetSchemaName());
         string dependentTableName = MyId(dependentSetEnd.EntitySet.GetTableName());
         string principalTableName = MyId(principalSetEnd.EntitySet.GetTableName());
 #>
 -- Creating foreign key on <#=WriteMySqlColumns(constraint.ToProperties, ',')#> in table '<#=dependentTableName#>'
 
-ALTER TABLE `<#=databaseName#>`.`<#=dependentTableName#>`
+ALTER TABLE `<#=dependentTableName#>`
 ADD CONSTRAINT `<#=WriteFKConstraintName(constraint)#>`
     FOREIGN KEY (<#=WriteMySqlColumns(constraint.ToProperties, ',')#>)
-    REFERENCES `<#=databaseName#>`.`<#=principalTableName#>`
+    REFERENCES `<#=principalTableName#>`
         (<#=WriteMySqlColumns(constraint.FromProperties, ',')#>)
     ON DELETE <#=GetDeleteAction(constraint)#> ON UPDATE NO ACTION;
 <#      
@@ -192,8 +193,8 @@
 
 -- Creating non-clustered index for FOREIGN KEY '<#=WriteFKConstraintName(constraint)#>'
 
-CREATE INDEX `IX_<#=WriteFKConstraintName(constraint)#>`
-ON `<#=databaseName#>`.`<#=dependentTableName#>`
+CREATE INDEX `IX_<#=WriteFKConstraintName(constraint)#>` 
+    ON `<#=dependentTableName#>`
     (<#=WriteMySqlColumns(constraint.ToProperties, ',')#>);
 <#      
         }
@@ -204,4 +205,4 @@
 #>
 -- --------------------------------------------------
 -- Script has ended
--- --------------------------------------------------
\ No newline at end of file
+-- --------------------------------------------------


Attachment: [text/bzr-bundle] bzr/reggie.burnett@oracle.com-20100708215320-ef6ye32od0xbdtsj.bundle
Thread
bzr commit into connector-net-trunk branch (reggie.burnett:893) Reggie Burnett8 Jul