Skip to content

Commit 465f6df

Browse files
committed
Merge branch 'hotfix/2.0.1'
2 parents 1f49ab1 + d90786a commit 465f6df

25 files changed

Lines changed: 203 additions & 80 deletions

.appveyor.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
image: Visual Studio 2017 Preview
2-
version: 2.0.0-{build}
2+
version: 2.0.1-{build}
33
services:
44
- postgresql
55
environment:
@@ -23,12 +23,11 @@ build_script:
2323
- msbuild /p:Configuration=Release
2424
- dotnet pack src\EFCore.PG\EFCore.PG.csproj -c Release --version-suffix ci-%PADDED_BUILD_NUMBER%
2525
test_script:
26-
- cd test\EFCore.PG.Tests && dotnet xunit && cd ..\..\
27-
- cd test\EFCore.PG.FunctionalTests && dotnet xunit && cd ..\..\
28-
- cd test\EFCore.PG.Design.FunctionalTests && dotnet xunit && cd ..\..\
26+
- dotnet test test\EFCore.PG.Tests\EFCore.PG.Tests.csproj
27+
- dotnet test test\EFCore.PG.FunctionalTests\EFCore.PG.FunctionalTests.csproj
28+
- dotnet test test\EFCore.PG.Design.FunctionalTests\EFCore.PG.Design.FunctionalTests.csproj
2929
artifacts:
3030
- path: 'src\EFCore.PG\bin\**\*.nupkg'
31-
- path: 'src\EFCore.PG.Design\bin\**\*.nupkg'
3231
deploy:
3332
- provider: NuGet
3433
server: https://www.myget.org/F/npgsql-unstable/api/v2/package

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*.userprefs
77
/*.nupkg
88
.nuget/
9+
.vs/
910
[Bb]in/
1011
[Bb]uild/
1112
[Oo]bj/

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ env:
1616
before_script:
1717
- dotnet restore -v Minimal
1818
script:
19-
- cd test/EFCore.PG.Tests && dotnet xunit -framework netcoreapp2.0 && cd ../../
20-
- cd test/EFCore.PG.FunctionalTests && dotnet xunit -framework netcoreapp2.0 && cd ../../
21-
- cd test/EFCore.PG.Design.FunctionalTests && dotnet xunit -framework netcoreapp2.0 && cd ../../
19+
- dotnet test test/EFCore.PG.Tests/EFCore.PG.Tests.csproj
20+
- dotnet test test/EFCore.PG.FunctionalTests/EFCore.PG.FunctionalTests.csproj
21+
- dotnet test test/EFCore.PG.Design.FunctionalTests/EFCore.PG.Design.FunctionalTests.csproj
2222

2323
cache:
2424
directories:

src/EFCore.PG/EFCore.PG.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<VersionPrefix>2.0.0</VersionPrefix>
4+
<VersionPrefix>2.0.1</VersionPrefix>
55
<TargetFrameworks>netstandard2.0</TargetFrameworks>
66
<AssemblyName>Npgsql.EntityFrameworkCore.PostgreSQL</AssemblyName>
77
<RootNamespace>Microsoft.EntityFrameworkCore</RootNamespace>
@@ -25,11 +25,11 @@
2525
</ItemGroup>
2626

2727
<ItemGroup>
28-
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.0.0" />
29-
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="2.0.0" />
28+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.0.1" />
29+
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="2.0.1" />
3030
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.0.0" />
3131
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.0" />
32-
<PackageReference Include="Npgsql" Version="3.2.5" />
32+
<PackageReference Include="Npgsql" Version="3.2.6" />
3333
</ItemGroup>
3434

3535
</Project>

src/EFCore.PG/Migrations/NpgsqlMigrationsSqlGenerator.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -787,20 +787,6 @@ public virtual void Transfer(
787787
.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(newSchema));
788788
}
789789

790-
protected override void ForeignKeyAction(ReferentialAction referentialAction, MigrationCommandListBuilder builder)
791-
{
792-
Check.NotNull(builder, nameof(builder));
793-
794-
if (referentialAction == ReferentialAction.Restrict)
795-
{
796-
builder.Append("NO ACTION");
797-
}
798-
else
799-
{
800-
base.ForeignKeyAction(referentialAction, builder);
801-
}
802-
}
803-
804790
#endregion Utilities
805791

806792
#region System column utilities

src/EFCore.PG/NpgsqlDbFunctionsExtensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static bool ILike(
2020
[CanBeNull] this DbFunctions _,
2121
[CanBeNull] string matchExpression,
2222
[CanBeNull] string pattern)
23-
=> LikeCore(matchExpression, pattern, escapeCharacter: null);
23+
=> ILikeCore(matchExpression, pattern, escapeCharacter: null);
2424

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

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

59-
private static bool LikeCore(string matchExpression, string pattern, string escapeCharacter)
59+
private static bool ILikeCore(string matchExpression, string pattern, string escapeCharacter)
6060
{
6161
//TODO: this fixes https://github.com/aspnet/EntityFramework/issues/8656 by insisting that
6262
// the "escape character" is a string but just using the first character of that string,
@@ -133,7 +133,7 @@ var regexPattern
133133
return Regex.IsMatch(
134134
matchExpression,
135135
@"\A" + regexPattern + @"\s*\z",
136-
RegexOptions.Singleline,
136+
RegexOptions.IgnoreCase | RegexOptions.Singleline,
137137
_regexTimeout);
138138
}
139139
}

src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlObjectToStringTranslator.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@ public virtual Expression Translate(MethodCallExpression methodCallExpression)
3434
=> methodCallExpression.Method.Name == nameof(ToString) &&
3535
methodCallExpression.Arguments.Count == 0 &&
3636
methodCallExpression.Object != null &&
37-
SupportedTypes.Contains(methodCallExpression.Object.Type.UnwrapNullableType().UnwrapEnumType())
37+
SupportedTypes.Contains(
38+
AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue9894", out var enabled)
39+
&& enabled
40+
? methodCallExpression.Object.Type.UnwrapNullableType().UnwrapEnumType()
41+
: methodCallExpression.Object.Type.UnwrapNullableType()
42+
)
3843
? new ExplicitCastExpression(methodCallExpression.Object, typeof(string))
3944
: null;
4045
}

src/EFCore.PG/Query/ExpressionVisitors/NpgsqlSqlTranslatingExpressionVisitor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ protected override Expression VisitSubQuery(SubQueryExpression expression)
4040
if (properties.Count == 0)
4141
return null;
4242
var lastPropertyType = properties[properties.Count - 1].ClrType;
43-
if (lastPropertyType.IsArray && lastPropertyType.GetArrayRank() == 1)
43+
if (lastPropertyType.IsArray && lastPropertyType.GetArrayRank() == 1 && subQueryModel.ResultOperators.Count > 0)
4444
{
4545
// Translate someArray.Length
4646
if (subQueryModel.ResultOperators.First() is CountResultOperator)

src/EFCore.PG/Scaffolding/Internal/NpgsqlDatabaseModelFactory.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ void GetTables()
163163

164164
const string GetColumnsQuery = @"
165165
SELECT
166-
nspname, relname, attisdropped, attname, typ.typname, atttypmod, description,
166+
nspname, relname, attisdropped, attname, typ.typname, atttypmod, description, basetyp.typname AS domtypname,
167167
CASE WHEN pg_proc.proname='array_recv' THEN 'a' ELSE typ.typtype END AS typtype,
168168
CASE
169169
WHEN pg_proc.proname='array_recv' THEN elemtyp.typname
@@ -177,6 +177,7 @@ FROM pg_class AS cls
177177
LEFT OUTER JOIN pg_type AS typ ON attr.atttypid = typ.oid
178178
LEFT OUTER JOIN pg_proc ON pg_proc.oid = typ.typreceive
179179
LEFT OUTER JOIN pg_type AS elemtyp ON (elemtyp.oid = typ.typelem)
180+
LEFT OUTER JOIN pg_type AS basetyp ON (basetyp.oid = typ.typbasetype)
180181
LEFT OUTER JOIN pg_description AS des ON des.objoid = cls.oid AND des.objsubid = attnum
181182
WHERE
182183
relkind = 'r' AND
@@ -261,6 +262,9 @@ void GetColumns()
261262
case 'e':
262263
column[NpgsqlAnnotationNames.PostgresTypeType] = PostgresTypeType.Enum;
263264
break;
265+
case 'd':
266+
column.StoreType = GetStoreType(reader.GetValueOrDefault<string>("domtypname"), typeModifier);
267+
break;
264268
default:
265269
Logger.Logger.LogWarning($"Can't scaffold column '{columnName}' of type '{dataType}': unknown type char '{typeChar}'");
266270
continue;
@@ -535,7 +539,10 @@ void GetSequences()
535539
Debug.Assert(sequence.MinValue.HasValue);
536540
defaultStart = sequence.MinValue.Value;
537541
} else {
538-
defaultMin = long.MinValue + 1;
542+
// PostgreSQL 10 changed the default minvalue for a descending sequence, see #264
543+
defaultMin = _connection.PostgreSqlVersion >= new Version(10,0)
544+
? long.MinValue
545+
: long.MinValue + 1;
539546
defaultMax = -1;
540547
Debug.Assert(sequence.MaxValue.HasValue);
541548
defaultStart = sequence.MaxValue.Value;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System.Data;
2+
using JetBrains.Annotations;
3+
4+
namespace Microsoft.EntityFrameworkCore.Storage.Internal
5+
{
6+
public class NpgsqlDateTimeOffsetTypeMapping : DateTimeOffsetTypeMapping
7+
{
8+
private const string DateTimeOffsetFormatConst = "{0:yyyy-MM-ddTHH:mm:ss.fffzzz}";
9+
10+
public NpgsqlDateTimeOffsetTypeMapping(
11+
[NotNull] string storeType,
12+
[NotNull] DbType? dbType = System.Data.DbType.DateTimeOffset)
13+
: base(storeType, dbType: dbType)
14+
{
15+
}
16+
17+
public override RelationalTypeMapping Clone(string storeType, int? size)
18+
=> new NpgsqlDateTimeOffsetTypeMapping(storeType, DbType);
19+
20+
protected override string SqlLiteralFormatString => $"'{DateTimeOffsetFormatConst}'";
21+
}
22+
}

0 commit comments

Comments
 (0)