Skip to content

Npgsql.EntityFrameworkCore.PostgreSQL generates unsupported sql for old postgresql server #478

@neyromant

Description

@neyromant

Hi
I'm using PostgreSQL 9.3.5 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4), 64-bit "

After switching to the version of Npgsql.EntityFrameworkCore.PostgreSQL 2.1.0, I got errors on some queries. "Npgsql.PostgresException" "42703: column " mins \ "does not exist".

I did a little investigation:
For the following code

public class Foo
{
        [Key]
        public int Id { get; set; }
        public DateTime Date { get; set; }
}

public class ApplicationDbContext : DbContext
{
     public DbSet<Foo> Foos { get; set; }
     public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { 
     }
}

...

var res = db.Foos.Select(x => new
{
    Date = x.Date.AddMinutes(60)
}).ToList();
...

Npgsql.EntityFrameworkCore.PostgreSQL generates the following Sql:

SELECT (x."Date" + MAKE_INTERVAL(mins => 60)) AS "Date" FROM "Foos" AS x

But version 2.0.0 of Npgsql.EntityFrameworkCore.PostgreSQL generated the following sql:

SELECT "x"."Date" FROM "Foos" AS "x"

The problem is that MAKE_INTERVAL function is not supported by PostgreSQL 9.3.

Question. Is it a bug, or is Npgsql.EntityFrameworkCore.PostgreSQL 2.1.0 just not going to support the old PostgreSql server?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions