Skip to content

Commit

Permalink
Remove explicit default value for not nullable columns
Browse files Browse the repository at this point in the history
# Conflicts:
#	test/EntityFramework6.Npgsql.Tests/EntityFrameworkMigrationTests.cs
  • Loading branch information
xklonx authored and rwasef1830 committed Sep 22, 2017
1 parent 172e589 commit c1cf255
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
8 changes: 0 additions & 8 deletions src/EntityFramework6.Npgsql/NpgsqlMigrationSqlGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -585,14 +585,6 @@ void AppendColumn(ColumnModel column, StringBuilder sql)
break;
}
}
else if (column.IsNullable != null
&& !column.IsNullable.Value
&& (column.StoreType == null ||
(column.StoreType.IndexOf("rowversion", StringComparison.OrdinalIgnoreCase) == -1)))
{
sql.Append(" DEFAULT ");
AppendValue(column.ClrDefaultValue, sql);
}
}

void AppendColumnType(ColumnModel column, StringBuilder sql, bool setSerial)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,13 @@ public void CreateBloggingContext()
expectedColumns.Remove((string)reader[0]);
Assert.AreEqual("integer", (string)reader[1]);
Assert.AreEqual("NO", (string)reader[2]);
Assert.AreEqual("0", (string)reader[3]);
Assert.That(string.IsNullOrEmpty(reader[3] as string));
break;
case "UniqueId":
expectedColumns.Remove((string)reader[0]);
Assert.AreEqual("uuid", (string)reader[1]);
Assert.AreEqual("NO", (string)reader[2]);
Assert.AreEqual("'00000000-0000-0000-0000-000000000000'::uuid", reader[3] as string);
Assert.That(string.IsNullOrEmpty(reader[3] as string));
//Assert.AreEqual("uuid_generate_v4()", reader[3] as string);
break;
case "Rating":
Expand Down Expand Up @@ -358,7 +358,7 @@ public void CreateTableOperation()
Assert.AreEqual("CREATE SCHEMA IF NOT EXISTS \"someSchema\"", statments.ElementAt(0).Sql);
else
Assert.AreEqual("CREATE SCHEMA \"someSchema\"", statments.ElementAt(0).Sql);
Assert.AreEqual("CREATE TABLE \"someSchema\".\"someTable\"(\"SomeString\" varchar(233) NOT NULL DEFAULT '',\"AnotherString\" text,\"SomeBytes\" bytea,\"SomeLong\" serial8,\"SomeDateTime\" timestamp)", statments.ElementAt(1).Sql);
Assert.AreEqual("CREATE TABLE \"someSchema\".\"someTable\"(\"SomeString\" varchar(233) NOT NULL,\"AnotherString\" text,\"SomeBytes\" bytea,\"SomeLong\" serial8,\"SomeDateTime\" timestamp)", statments.ElementAt(1).Sql);
}

[Test]
Expand Down

0 comments on commit c1cf255

Please sign in to comment.