Skip to content

Commit

Permalink
Merge branch 'hotfix/2.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
roji committed Jan 11, 2018
2 parents 1f49ab1 + 5a89128 commit 0e7acbf
Show file tree
Hide file tree
Showing 25 changed files with 200 additions and 77 deletions.
9 changes: 4 additions & 5 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
image: Visual Studio 2017 Preview
version: 2.0.0-{build}
version: 2.0.1-{build}
services:
- postgresql
environment:
Expand All @@ -23,12 +23,11 @@ build_script:
- msbuild /p:Configuration=Release
- dotnet pack src\EFCore.PG\EFCore.PG.csproj -c Release --version-suffix ci-%PADDED_BUILD_NUMBER%
test_script:
- cd test\EFCore.PG.Tests && dotnet xunit && cd ..\..\
- cd test\EFCore.PG.FunctionalTests && dotnet xunit && cd ..\..\
- cd test\EFCore.PG.Design.FunctionalTests && dotnet xunit && cd ..\..\
- dotnet test test\EFCore.PG.Tests\EFCore.PG.Tests.csproj
- dotnet test test\EFCore.PG.FunctionalTests\EFCore.PG.FunctionalTests.csproj
- dotnet test test\EFCore.PG.Design.FunctionalTests\EFCore.PG.Design.FunctionalTests.csproj
artifacts:
- path: 'src\EFCore.PG\bin\**\*.nupkg'
- path: 'src\EFCore.PG.Design\bin\**\*.nupkg'
deploy:
- provider: NuGet
server: https://www.myget.org/F/npgsql-unstable/api/v2/package
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*.userprefs
/*.nupkg
.nuget/
.vs/
[Bb]in/
[Bb]uild/
[Oo]bj/
Expand Down
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ env:
before_script:
- dotnet restore -v Minimal
script:
- cd test/EFCore.PG.Tests && dotnet xunit -framework netcoreapp2.0 && cd ../../
- cd test/EFCore.PG.FunctionalTests && dotnet xunit -framework netcoreapp2.0 && cd ../../
- cd test/EFCore.PG.Design.FunctionalTests && dotnet xunit -framework netcoreapp2.0 && cd ../../
- dotnet test test/EFCore.PG.Tests/EFCore.PG.Tests.csproj
- dotnet test test/EFCore.PG.FunctionalTests/EFCore.PG.FunctionalTests.csproj
- dotnet test test/EFCore.PG.Design.FunctionalTests/EFCore.PG.Design.FunctionalTests.csproj

cache:
directories:
Expand Down
6 changes: 3 additions & 3 deletions src/EFCore.PG/EFCore.PG.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<VersionPrefix>2.0.0</VersionPrefix>
<VersionPrefix>2.0.1</VersionPrefix>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<AssemblyName>Npgsql.EntityFrameworkCore.PostgreSQL</AssemblyName>
<RootNamespace>Microsoft.EntityFrameworkCore</RootNamespace>
Expand All @@ -25,8 +25,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="2.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.0" />
<PackageReference Include="Npgsql" Version="3.2.5" />
Expand Down
14 changes: 0 additions & 14 deletions src/EFCore.PG/Migrations/NpgsqlMigrationsSqlGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -787,20 +787,6 @@ public virtual void Transfer(
.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(newSchema));
}

protected override void ForeignKeyAction(ReferentialAction referentialAction, MigrationCommandListBuilder builder)
{
Check.NotNull(builder, nameof(builder));

if (referentialAction == ReferentialAction.Restrict)
{
builder.Append("NO ACTION");
}
else
{
base.ForeignKeyAction(referentialAction, builder);
}
}

#endregion Utilities

#region System column utilities
Expand Down
8 changes: 4 additions & 4 deletions src/EFCore.PG/NpgsqlDbFunctionsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static bool ILike(
[CanBeNull] this DbFunctions _,
[CanBeNull] string matchExpression,
[CanBeNull] string pattern)
=> LikeCore(matchExpression, pattern, escapeCharacter: null);
=> ILikeCore(matchExpression, pattern, escapeCharacter: null);

/// <summary>
/// An implementation of the PostgreSQL ILIKE operation, which is an insensitive LIKE.
Expand All @@ -38,7 +38,7 @@ public static bool ILike(
[CanBeNull] string matchExpression,
[CanBeNull] string pattern,
[CanBeNull] string escapeCharacter)
=> LikeCore(matchExpression, pattern, escapeCharacter);
=> ILikeCore(matchExpression, pattern, escapeCharacter);

// Regex special chars defined here:
// https://msdn.microsoft.com/en-us/library/4edbef7e(v=vs.110).aspx
Expand All @@ -56,7 +56,7 @@ private static string BuildEscapeRegexCharsPattern(IEnumerable<char> regexSpecia
return string.Join("|", regexSpecialChars.Select(c => @"\" + c));
}

private static bool LikeCore(string matchExpression, string pattern, string escapeCharacter)
private static bool ILikeCore(string matchExpression, string pattern, string escapeCharacter)
{
//TODO: this fixes https://github.com/aspnet/EntityFramework/issues/8656 by insisting that
// the "escape character" is a string but just using the first character of that string,
Expand Down Expand Up @@ -133,7 +133,7 @@ var regexPattern
return Regex.IsMatch(
matchExpression,
@"\A" + regexPattern + @"\s*\z",
RegexOptions.Singleline,
RegexOptions.IgnoreCase | RegexOptions.Singleline,
_regexTimeout);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ public virtual Expression Translate(MethodCallExpression methodCallExpression)
=> methodCallExpression.Method.Name == nameof(ToString) &&
methodCallExpression.Arguments.Count == 0 &&
methodCallExpression.Object != null &&
SupportedTypes.Contains(methodCallExpression.Object.Type.UnwrapNullableType().UnwrapEnumType())
SupportedTypes.Contains(
AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue9894", out var enabled)
&& enabled
? methodCallExpression.Object.Type.UnwrapNullableType().UnwrapEnumType()
: methodCallExpression.Object.Type.UnwrapNullableType()
)
? new ExplicitCastExpression(methodCallExpression.Object, typeof(string))
: null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected override Expression VisitSubQuery(SubQueryExpression expression)
if (properties.Count == 0)
return null;
var lastPropertyType = properties[properties.Count - 1].ClrType;
if (lastPropertyType.IsArray && lastPropertyType.GetArrayRank() == 1)
if (lastPropertyType.IsArray && lastPropertyType.GetArrayRank() == 1 && subQueryModel.ResultOperators.Count > 0)
{
// Translate someArray.Length
if (subQueryModel.ResultOperators.First() is CountResultOperator)
Expand Down
11 changes: 9 additions & 2 deletions src/EFCore.PG/Scaffolding/Internal/NpgsqlDatabaseModelFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void GetTables()

const string GetColumnsQuery = @"
SELECT
nspname, relname, attisdropped, attname, typ.typname, atttypmod, description,
nspname, relname, attisdropped, attname, typ.typname, atttypmod, description, basetyp.typname AS domtypname,
CASE WHEN pg_proc.proname='array_recv' THEN 'a' ELSE typ.typtype END AS typtype,
CASE
WHEN pg_proc.proname='array_recv' THEN elemtyp.typname
Expand All @@ -177,6 +177,7 @@ FROM pg_class AS cls
LEFT OUTER JOIN pg_type AS typ ON attr.atttypid = typ.oid
LEFT OUTER JOIN pg_proc ON pg_proc.oid = typ.typreceive
LEFT OUTER JOIN pg_type AS elemtyp ON (elemtyp.oid = typ.typelem)
LEFT OUTER JOIN pg_type AS basetyp ON (basetyp.oid = typ.typbasetype)
LEFT OUTER JOIN pg_description AS des ON des.objoid = cls.oid AND des.objsubid = attnum
WHERE
relkind = 'r' AND
Expand Down Expand Up @@ -261,6 +262,9 @@ void GetColumns()
case 'e':
column[NpgsqlAnnotationNames.PostgresTypeType] = PostgresTypeType.Enum;
break;
case 'd':
column.StoreType = GetStoreType(reader.GetValueOrDefault<string>("domtypname"), typeModifier);
break;
default:
Logger.Logger.LogWarning($"Can't scaffold column '{columnName}' of type '{dataType}': unknown type char '{typeChar}'");
continue;
Expand Down Expand Up @@ -535,7 +539,10 @@ void GetSequences()
Debug.Assert(sequence.MinValue.HasValue);
defaultStart = sequence.MinValue.Value;
} else {
defaultMin = long.MinValue + 1;
// PostgreSQL 10 changed the default minvalue for a descending sequence, see #264
defaultMin = _connection.PostgreSqlVersion >= new Version(10,0)
? long.MinValue
: long.MinValue + 1;
defaultMax = -1;
Debug.Assert(sequence.MaxValue.HasValue);
defaultStart = sequence.MaxValue.Value;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Data;
using JetBrains.Annotations;

namespace Microsoft.EntityFrameworkCore.Storage.Internal
{
public class NpgsqlDateTimeOffsetTypeMapping : DateTimeOffsetTypeMapping
{
private const string DateTimeOffsetFormatConst = "{0:yyyy-MM-ddTHH:mm:ss.fffzzz}";

public NpgsqlDateTimeOffsetTypeMapping(
[NotNull] string storeType,
[NotNull] DbType? dbType = System.Data.DbType.DateTimeOffset)
: base(storeType, dbType: dbType)
{
}

public override RelationalTypeMapping Clone(string storeType, int? size)
=> new NpgsqlDateTimeOffsetTypeMapping(storeType, DbType);

protected override string SqlLiteralFormatString => $"'{DateTimeOffsetFormatConst}'";
}
}
2 changes: 1 addition & 1 deletion src/EFCore.PG/Storage/Internal/NpgsqlEFTypeMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void AddCustomizedMappings()

_baseClrMappings[typeof(char)] = new CharTypeMapping("text", DbType.String);
_baseClrMappings[typeof(DateTime)] = _storeTypeMappings["timestamp"] = new DateTimeTypeMapping("timestamp", DbType.DateTime);
_storeTypeMappings["timestamptz"] = new DateTimeTypeMapping("timestamptz", DbType.DateTime);
_baseClrMappings[typeof(DateTimeOffset)] = _storeTypeMappings["timestamptz"] = new NpgsqlDateTimeOffsetTypeMapping("timestamptz", DbType.DateTimeOffset);
_baseClrMappings[typeof(bool)] = _storeTypeMappings["bool"] = new NpgsqlBoolTypeMapping();

_baseClrMappings[typeof(decimal)] = new DecimalTypeMapping("numeric", DbType.Decimal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFrameworks>net461;netcoreapp2.0</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT' OR '$(CoreOnly)' == 'True'">netcoreapp2.0</TargetFrameworks>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests</AssemblyName>
<RootNamespace>Npgsql.EntityFrameworkCore.PostgreSQL.Design.FunctionalTests</RootNamespace>
Expand All @@ -19,10 +20,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0-*" />
<PackageReference Include="xunit.core" Version="2.3.0-*" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.0-*" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational.Design.Specification.Tests" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational.Design.Specification.Tests" Version="2.0.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public void It_reads_primary_key()
var sql = "CREATE TABLE place (id int PRIMARY KEY, name int UNIQUE, location int);" +
"CREATE INDEX ix_location_name ON place (location, name);";

var dbModel = CreateModel(sql);
var dbModel = CreateModel(sql, new List<string> { "place" });

var pkIndex = dbModel.Tables.Single().PrimaryKey;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
DROP TABLE IF EXISTS "AllDataTypes";

DROP DOMAIN IF EXISTS domain_type;
CREATE DOMAIN domain_type AS smallint CONSTRAINT domain_type_check CHECK (((VALUE >= (-50)) AND (VALUE <= 50)));

CREATE TABLE "AllDataTypes" (
"AllDataTypesID" serial PRIMARY KEY,

Expand All @@ -22,7 +26,9 @@ CREATE TABLE "AllDataTypes" (

"byteaColumn" bytea NULL,
"boolColumn" boolean NOT NULL,
"uuidColumn" uuid NULL
"uuidColumn" uuid NULL,

"domainColumn" domain_type NOT NULL
);

DROP TABLE IF EXISTS "PropertyConfiguration";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ namespace E2ETest.Namespace
public string VarcharColumn { get; set; }
public DateTime DateColumn { get; set; }
public DateTime? TimestampColumn { get; set; }
public DateTime? TimestampTzColumn { get; set; }
public DateTimeOffset? TimestampTzColumn { get; set; }
public TimeSpan? TimeColumn { get; set; }
public byte[] ByteaColumn { get; set; }
public bool BoolColumn { get; set; }
public Guid? UuidColumn { get; set; }
public short DomainColumn { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ namespace E2ETest.Namespace

entity.Property(e => e.DecimalColumn).HasColumnName("decimalColumn");

entity.Property(e => e.DomainColumn).HasColumnName("domainColumn");

entity.Property(e => e.DoubleColumn).HasColumnName("doubleColumn");

entity.Property(e => e.IntColumn).HasColumnName("intColumn");
Expand All @@ -73,9 +75,7 @@ namespace E2ETest.Namespace

entity.Property(e => e.TimestampColumn).HasColumnName("timestampColumn");

entity.Property(e => e.TimestampTzColumn)
.HasColumnName("timestampTzColumn")
.HasColumnType("timestamptz");
entity.Property(e => e.TimestampTzColumn).HasColumnName("timestampTzColumn");

entity.Property(e => e.UuidColumn).HasColumnName("uuidColumn");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ namespace E2ETest.Namespace
public DateTime DateColumn { get; set; }
[Column("timestampColumn")]
public DateTime? TimestampColumn { get; set; }
[Column("timestampTzColumn", TypeName = "timestamptz")]
public DateTime? TimestampTzColumn { get; set; }
[Column("timestampTzColumn")]
public DateTimeOffset? TimestampTzColumn { get; set; }
[Column("timeColumn", TypeName = "time")]
public TimeSpan? TimeColumn { get; set; }
[Column("byteaColumn")]
Expand All @@ -45,5 +45,7 @@ namespace E2ETest.Namespace
public bool BoolColumn { get; set; }
[Column("uuidColumn")]
public Guid? UuidColumn { get; set; }
[Column("domainColumn")]
public short DomainColumn { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ public override void OnModelCreating(ModelBuilder modelBuilder)

modelBuilder.Entity<MappedDataTypes>().Property(e => e.Xid).HasColumnType("xid");
modelBuilder.Entity<MappedNullableDataTypes>().Property(e => e.Xid).HasColumnType("xid");

// TimeTz
modelBuilder.Entity<MappedDataTypes>().Property(e => e.Timetz).HasColumnType("timetz");
modelBuilder.Entity<MappedNullableDataTypes>().Property(e => e.Timetz).HasColumnType("timetz");
}

private static void MapColumnTypes<TEntity>(ModelBuilder modelBuilder) where TEntity : class
Expand Down Expand Up @@ -197,10 +201,10 @@ public class MappedDataTypes
public byte[] Bytea { get; set; }

public DateTime Timestamp { get; set; }
//public DateTime Timestamptz { get; set; }
public DateTime Timestamptz { get; set; }
public DateTime Date { get; set; }
public TimeSpan Time { get; set; }
//public DateTimeOffset Timetz { get; set; }
public DateTimeOffset Timetz { get; set; }
public TimeSpan Interval { get; set; }

public Guid Uuid { get; set; }
Expand Down
Loading

0 comments on commit 0e7acbf

Please sign in to comment.