Skip to content

Commit

Permalink
backport from v7
Browse files Browse the repository at this point in the history
  • Loading branch information
MaceWindu committed May 18, 2023
1 parent 51a8955 commit 6391f65
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 40 deletions.
18 changes: 9 additions & 9 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project>
<ItemGroup>
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.3.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.4.2" />
<PackageVersion Include="NUnit" Version="3.13.3" />
<PackageVersion Include="FluentAssertions" Version="6.10.0" />
<PackageVersion Include="FluentAssertions" Version="6.11.0" />

<PackageVersion Include="linq2db" Version="5.1.0" />
<PackageVersion Include="linq2db.Tools" Version="5.1.0" />
<PackageVersion Include="linq2db" Version="5.2.1" />
<PackageVersion Include="linq2db.Tools" Version="5.2.1" />

<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />

Expand All @@ -17,11 +17,11 @@
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />

<PackageVersion Include="Pomelo.EntityFrameworkCore.MySql" Version="6.0.2" />
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.8" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.14" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.14" />
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime" Version="6.0.8" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.16" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.16" />

<PackageVersion Include="EntityFrameworkCore.FSharp" Version="6.0.7" />
<PackageVersion Include="FSharp.Core" Version="7.0.200" />
<PackageVersion Include="FSharp.Core" Version="7.0.300" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ TransformInfo LocalTransform(Expression e)
break;
}

if (typeof(IQueryable<>).IsSameOrParentOf(methodCall.Type))
if (typeof(IQueryable<>).IsSameOrParentOf(methodCall.Type) && methodCall.Type.Assembly != typeof(LinqExtensions).Assembly)
{
if (null == methodCall.Find(nonEvaluatableParameters,
(c, t) => t.NodeType == ExpressionType.Parameter && c.Contains(t)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@

<ItemGroup>
<PackageReference Include="FluentAssertions" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,19 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
entity.UseXminAsConcurrencyToken();
});

modelBuilder.Entity<TimeStampEntity>(e =>
{
e.Property(e => e.Timestamp1).HasColumnType("timestamp");
e.Property(e => e.Timestamp2).HasColumnType("timestamp");
e.Property(e => e.TimestampTZ1).HasColumnType("timestamp with time zone");
e.Property(e => e.TimestampTZ2).HasColumnType("timestamp with time zone");
e.Property(e => e.TimestampTZ3).HasColumnType("timestamp with time zone");
});
}

public virtual DbSet<Event> Events { get; set; } = null!;
public virtual DbSet<EntityWithArrays> EntityWithArrays { get; set; } = null!;
public virtual DbSet<EntityWithXmin> EntityWithXmin { get; set; } = null!;

public virtual DbSet<TimeStampEntity> TimeStamps { get; set; } = null!;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using NodaTime;

namespace LinqToDB.EntityFrameworkCore.PostgreSQL.Tests.Models.NpgSqlEntities
{
public class TimeStampEntity
{
public int Id { get; set; }
public DateTime Timestamp1 { get; set; }
public LocalDateTime Timestamp2 { get; set; }
public DateTime TimestampTZ1 { get; set; }
public DateTimeOffset TimestampTZ2 { get; set; }
public Instant TimestampTZ3 { get; set; }
}
}
25 changes: 21 additions & 4 deletions Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/NpgSqlTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using LinqToDB.EntityFrameworkCore.BaseTests;
using LinqToDB.EntityFrameworkCore.PostgreSQL.Tests.Models.NpgSqlEntities;
using Microsoft.EntityFrameworkCore;
using NodaTime;
using NUnit.Framework;

namespace LinqToDB.EntityFrameworkCore.PostgreSQL.Tests
Expand All @@ -23,10 +24,9 @@ static NpgSqlTests()
public NpgSqlTests()
{
var optionsBuilder = new DbContextOptionsBuilder<NpgSqlEnititesContext>();
//new SqlServerDbContextOptionsBuilder(optionsBuilder);

//optionsBuilder.UseNpgsql("Server=DBHost;Port=5432;Database=TestData;User Id=postgres;Password=TestPassword;Pooling=true;MinPoolSize=10;MaxPoolSize=100;");
optionsBuilder.UseNpgsql("Server=localhost;Port=5415;Database=TestData;User Id=postgres;Password=Password12!;Pooling=true;MinPoolSize=10;MaxPoolSize=100;");
//optionsBuilder.UseNpgsql("Server=DBHost;Port=5432;Database=TestData;User Id=postgres;Password=TestPassword;Pooling=true;MinPoolSize=10;MaxPoolSize=100;", o => o.UseNodaTime());
optionsBuilder.UseNpgsql("Server=localhost;Port=5415;Database=TestData;User Id=postgres;Password=Password12!;Pooling=true;MinPoolSize=10;MaxPoolSize=100;", o => o.UseNodaTime());
optionsBuilder.UseLoggerFactory(TestUtils.LoggerFactory);

_options = optionsBuilder.Options;
Expand Down Expand Up @@ -100,7 +100,6 @@ public void TestConcurrencyToken()
db.BulkCopy(toInsert);
}


[Test]
public void TestUnnest()
{
Expand All @@ -119,5 +118,23 @@ where Sql.Ext.PostgreSQL().Overlaps(m.Guids, guids)
query.Invoking(q => q.ToArray()).Should().NotThrow();
}

[Test]
public void TestDateTimeKind([Values] DateTimeKind kind)
{
using var db = CreateNpgSqlEntitiesContext();
using var dc = db.CreateLinqToDBConnection();

var dt = new DateTime(DateTime.Now.Ticks, kind);
var dto = DateTimeOffset.Now;
var ins = Instant.FromDateTimeOffset(dto);
var ldt = LocalDateTime.FromDateTime(DateTime.Now);

db.TimeStamps.Where(e => e.Timestamp1 == dt).ToLinqToDB().ToArray();
db.TimeStamps.Where(e => e.Timestamp2 == ldt).ToLinqToDB().ToArray();
db.TimeStamps.Where(e => e.TimestampTZ1 == dt).ToLinqToDB().ToArray();
db.TimeStamps.Where(e => e.TimestampTZ2 == dto).ToLinqToDB().ToArray();
db.TimeStamps.Where(e => e.TimestampTZ3 == ins).ToLinqToDB().ToArray();
}

}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using FluentAssertions;
using LinqToDB.DataProvider.SqlServer;
using LinqToDB.EntityFrameworkCore.BaseTests;
using LinqToDB.EntityFrameworkCore.SqlServer.Tests.Models.IssueModel;
using Microsoft.EntityFrameworkCore;
Expand Down Expand Up @@ -81,5 +82,12 @@ from p in ctx.Patents.Include(p => p.Assessment)
Assert.That(db.LastQuery, Does.Not.Contain("INNER"));
}

[Test]
public void Issue321Test()
{
using var ctx = CreateContext();

var _ = ctx.Patents.AsSqlServer().ToLinqToDB().ToArray();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public override void Configure(EntityTypeBuilder<Category> builder)
.IsRequired()
.HasMaxLength(15);

builder.Property(e => e.Description).HasColumnType("ntext");
builder.Property(e => e.Description).HasColumnType("nvarchar(max)");

builder.Property(e => e.Picture).HasColumnType("image");
builder.Property(e => e.Picture).HasColumnType("varbinary(max)");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@

namespace LinqToDB.EntityFrameworkCore.SqlServer.Tests.Models.Northwind.Mapping
{
public class CustomerDemographicsMap : BaseEntityMap<CustomerDemographics>
{
public override void Configure(EntityTypeBuilder<CustomerDemographics> builder)
{
base.Configure(builder);
public class CustomerDemographicsMap : BaseEntityMap<CustomerDemographics>
{
public override void Configure(EntityTypeBuilder<CustomerDemographics> builder)
{
base.Configure(builder);

builder.HasKey(e => e.CustomerTypeId)
.IsClustered(false);
builder.HasKey(e => e.CustomerTypeId)
.IsClustered(false);

builder.Property(e => e.CustomerTypeId)
.HasColumnName("CustomerTypeID")
.HasMaxLength(10)
.ValueGeneratedNever();
builder.Property(e => e.CustomerTypeId)
.HasColumnName("CustomerTypeID")
.HasMaxLength(10)
.ValueGeneratedNever();

builder.Property(e => e.CustomerDesc).HasColumnType("ntext");
}
}
builder.Property(e => e.CustomerDesc).HasColumnType("nvarchar(max)");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public override void Configure(EntityTypeBuilder<Employee> builder)
.IsRequired()
.HasMaxLength(20);

builder.Property(e => e.Notes).HasColumnType("ntext");
builder.Property(e => e.Notes).HasColumnType("nvarchar(max)");

builder.Property(e => e.Photo).HasColumnType("image");
builder.Property(e => e.Photo).HasColumnType("varbinary(max)");

builder.Property(e => e.PhotoPath).HasMaxLength(255);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public override void Configure(EntityTypeBuilder<Supplier> builder)

builder.Property(e => e.Fax).HasMaxLength(24);

builder.Property(e => e.HomePage).HasColumnType("ntext");
builder.Property(e => e.HomePage).HasColumnType("nvarchar(max)");

builder.Property(e => e.Phone).HasMaxLength(24);

Expand Down
4 changes: 2 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
variables:
solution: 'linq2db.EFCore.sln'
build_configuration: 'Release'
assemblyVersion: 6.13.0
nugetVersion: 6.13.0
assemblyVersion: 6.14.0
nugetVersion: 6.14.0
artifact_nugets: 'nugets'

# build on commits to important branches (master + release branches):
Expand Down

0 comments on commit 6391f65

Please sign in to comment.