Skip to content

Commit

Permalink
#123 escapeNames not correctly passed down postgresql indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
martinjw committed Jul 30, 2021
1 parent ab9ebe8 commit 89312a8
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 10 deletions.
4 changes: 2 additions & 2 deletions CopyToSQLite/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.7.8.0")]
[assembly: AssemblyFileVersion("2.7.8.0")]
[assembly: AssemblyVersion("2.7.9.0")]
[assembly: AssemblyFileVersion("2.7.9.0")]
3 changes: 2 additions & 1 deletion DatabaseSchemaReader/DatabaseSchemaReader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Description>Any ADO provider can be read (SqlServer, SqlServer CE 4, MySQL, SQLite, System.Data.OracleClient, ODP, Devart, PostgreSql, DB2...) into a single standard model.</Description>
<AssemblyTitle>DatabaseSchemaReader</AssemblyTitle>
<VersionPrefix>2.7.8</VersionPrefix>
<VersionPrefix>2.7.9</VersionPrefix>
<Authors>Martin Willey</Authors>
<TargetFrameworks>netstandard2.0;netstandard1.5;net45;net40;net35</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand All @@ -17,6 +17,7 @@
2.7.6: PostgreSql MigrationGenerator cascade escaping thanks @groogiam
2.7.7: fixes null 'RefersToTable' of FK when only one table is read thanks @mjalil
2.7.8: PostgreSql sequences missing thanks @groogiam
2.7.9: PostgreSql sqlgen escaping thanks @r-work
</PackageReleaseNotes>
<PackageProjectUrl>https://github.com/martinjw/dbschemareader</PackageProjectUrl>
<PackageLicenseUrl>http://www.microsoft.com/en-us/openness/licenses.aspx#MPL</PackageLicenseUrl>
Expand Down
4 changes: 2 additions & 2 deletions DatabaseSchemaReader/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.7.8.0")]
[assembly: AssemblyFileVersion("2.7.8.0")]
[assembly: AssemblyVersion("2.7.9.0")]
[assembly: AssemblyFileVersion("2.7.9.0")]
[assembly: CLSCompliant(true)]
[assembly: InternalsVisibleTo("DatabaseSchemaReaderTest")]
2 changes: 1 addition & 1 deletion DatabaseSchemaReader/SqlGen/Db2/TableGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ protected override string ConstraintWriter()
}
protected virtual IMigrationGenerator CreateMigrationGenerator()
{
return new Db2MigrationGenerator { IncludeSchema = IncludeSchema };
return new Db2MigrationGenerator { IncludeSchema = IncludeSchema, EscapeNames = EscapeNames};
}
private void AddIndexes(StringBuilder sb)
{
Expand Down
2 changes: 1 addition & 1 deletion DatabaseSchemaReader/SqlGen/MySql/TableGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ protected override string ConstraintWriter()
}
protected virtual IMigrationGenerator CreateMigrationGenerator()
{
return new MySqlMigrationGenerator { IncludeSchema = IncludeSchema };
return new MySqlMigrationGenerator { IncludeSchema = IncludeSchema, EscapeNames = EscapeNames};
}
private void AddIndexes(StringBuilder sb)
{
Expand Down
2 changes: 1 addition & 1 deletion DatabaseSchemaReader/SqlGen/PostgreSql/TableGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private static string TranslateCheckExpression(string expression)
}
protected virtual IMigrationGenerator CreateMigrationGenerator()
{
return new PostgreSqlMigrationGenerator { IncludeSchema = IncludeSchema };
return new PostgreSqlMigrationGenerator { IncludeSchema = IncludeSchema, EscapeNames = EscapeNames};
}
private void AddIndexes(StringBuilder sb)
{
Expand Down
1 change: 1 addition & 0 deletions DatabaseSchemaReader/SqlGen/SqlServer/TableGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ protected virtual IMigrationGenerator CreateMigrationGenerator()
var migrations = new SqlServerMigrationGenerator();
//ensure we're not writing schema prefixes
if (!IncludeSchema) migrations.IncludeSchema = false;
migrations.EscapeNames = EscapeNames;
return migrations;
}

Expand Down
1 change: 1 addition & 0 deletions DatabaseSchemaReaderTest/DatabaseSchemaReaderTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@
<Compile Include="SqlGen\Oracle\LongIntegerTest.cs" />
<Compile Include="SqlGen\PostgreSql\DateTimeDataTypesTest.cs" />
<Compile Include="SqlGen\PostgreSql\StringDataTypesTest.cs" />
<Compile Include="SqlGen\PostgreSql\GeneratorTest.cs" />
<Compile Include="SqlGen\SqlServerCe\AllTablesGeneratorTest.cs" />
<Compile Include="SqlGen\SqlServerCe\TableGeneratorTest.cs" />
<Compile Include="SqlGen\SqlServer\AccessCheckConstraintTest.cs" />
Expand Down
34 changes: 34 additions & 0 deletions DatabaseSchemaReaderTest/SqlGen/PostgreSql/GeneratorTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using DatabaseSchemaReader.DataSchema;
using DatabaseSchemaReader.SqlGen;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace DatabaseSchemaReaderTest.SqlGen.PostgreSql
{
[TestClass]
public class GeneratorTest
{
[TestMethod]
public void TestGeneratorEscaping()
{
//arrange
var schema = new DatabaseSchema(null, SqlType.PostgreSql);
var table = schema.AddTable("AllTypes")
.AddColumn<int>("Id").AddIdentity()
.AddColumn<string>("Name").AddLength(200)
.AddColumn<int>("Age")
.AddColumn<int>("Period")
.Table;
table.AddIndex("TableIndex", new[] { table.FindColumn("Name") });

var factory = new DdlGeneratorFactory(SqlType.PostgreSql);
var tableGen = factory.TableGenerator(table);
tableGen.EscapeNames = false;

//act
var ddl = tableGen.Write();

//assert
Assert.IsTrue(ddl.Contains("INDEX TableIndex ON AllTypes(Name)"));
}
}
}
4 changes: 2 additions & 2 deletions DatabaseSchemaViewer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.7.8.0")]
[assembly: AssemblyFileVersion("2.7.8.0")]
[assembly: AssemblyVersion("2.7.9.0")]
[assembly: AssemblyFileVersion("2.7.9.0")]

0 comments on commit 89312a8

Please sign in to comment.