-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gin_trgm_ops fails if used for multiple columns #3259
Comments
Sorry it took so long to answer this. When opening an issue, it's a good idea to at least include the exact error you're getting, as well as the CREATE INDEX you're expecting from SQL - though ideally please always include a minimal, runnable repro. I tried to reproduce the problem with the below code; the migration generated is the same as what you've posted above, and the error I got was:
This is because .HasOperators("gin_trgm_ops", "gin_trgm_ops", "gin_trgm_ops"); ... everything works. I'll go ahead and close this as it was probably the usage error above (and some time has passed). But if I've misunderstood the question, please post back with a repro and I'll reopen. Code used: await using var context = new BlogContext();
await context.Database.EnsureDeletedAsync();
await context.Database.EnsureCreatedAsync();
public class BlogContext : DbContext
{
public DbSet<Blog> Blogs { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder
// .UseSqlServer("Server=localhost;Database=test;User=SA;Password=Abcd5678;Connect Timeout=60;ConnectRetryCount=0;Encrypt=false")
.UseNpgsql("Host=localhost;Username=test;Password=test")
.LogTo(Console.WriteLine, LogLevel.Information)
.EnableSensitiveDataLogging();
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.HasPostgresExtension("pg_trgm");
modelBuilder.Entity<Blog>().HasIndex(e => new { e.Number, e.Title, e.ShortDescription })
.HasMethod("GIN")
.HasOperators("gin_trgm_ops");
}
}
public class Blog
{
public int Id { get; set; }
public string Name { get; set; }
public string Number { get; set; }
public string Title { get; set; }
public string ShortDescription { get; set; }
} |
I have 3 columns which I want to create a GIN index using gin_trgm_ops
The EF Core configuration is:
However when is applied it generates an invalid syntax:
CREATE INDEX "IX_Table_Column1_Column2_ShortDescription" ON public."Table" USING GIN ("Column1" gin_trgm_ops, "Column2", "ShortDescription");
The command fails since it is not valid Postgres.
I am using the the 8.0.4 with 8.0.7 EF Core
Fix fix is simple to manually create index using SQL, but still let this issue here
The text was updated successfully, but these errors were encountered: