Skip to content
This repository was archived by the owner on May 9, 2020. It is now read-only.

Broken SQL queryies for Dialect1 #36

Description

@marcobusemann

The issue

First of all thanks for your great work!
Using your latest Version2.1 branch we got a problem with broken statements generated fromFbQuerySqlGenerator. The problem occurs due to the VisitTable() implementation (We are using Dialect1).

We have a simple setup like this:

context.Addresses.FirstOrDefault(address=> address.Id == 1);

The generated sql looks like this:

SELECT address.ID
FROM ADDRESSES b
WHERE b.ID = 1

Obviously the alias used for the id field does not match the one for the table. If we comment out your VisitTable() implementation we get:

SELECT address.ID
FROM ADDRESSES address
WHERE address.ID = 1

In my opinion VisitTable() is not the correct place to fix the alias. At the time of VisitTable()the columns have already been appended to the sql. I am wondering how this works for your clients? What do you thing?

Steps to reproduce

    public class Address
    {
        public int Id { get; set; }
    }

    public partial class AddressContext : DbContext
    {
        public virtual DbSet<Address> Addresses { get; set; }

        public AddressContext(DbContextOptions<AddressContext> options) : base(options)
        {
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Address>(entity =>
            {
                entity.ToTable("ADDRESSES");
                entity.Property(e => e.Id).HasColumnName("ID");
            });
        }
    }

    [Route("api/[controller]")]
    public class DummyController : Controller
    {
        private readonly AddressContext context;

        public DummyController(AddressContext context)
        {
            this.context = context;
        }

        [HttpGet]
        public IActionResult Index()
        {
            return Ok(context.Addresses.FirstOrDefault(address => address.Id == 1));
        }
    }

Further technical details

Firebird version: 2.5
EntityFrameworkCore.FirebirdSql version: 2.1

Other details about my project setup:
Dialect1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions