querybuilder icon indicating copy to clipboard operation
querybuilder copied to clipboard

.Include and .IncludeMany does not work with Guid keys in Postgres databases

Open ldias91 opened this issue 4 years ago • 5 comments

Hi,

When i use include method in postgres database with primary keys as guid i get the following error:

operator does not exist: uuid = text

I think the problem is here https://github.com/sqlkata/querybuilder/blob/d098a4ea288819e06fc382ce54e47f335a6b78b9/SqlKata.Execution/QueryFactory.Extensions.Async.cs#L344

instead of .Select(x => x[include.LocalKey].ToString())

may be .Select(x => x[include.LocalKey]);

ldias91 avatar Oct 23 '19 11:10 ldias91

Do u have workaround for Include in Postgresql?

chrisgate avatar Feb 09 '21 15:02 chrisgate

Yes that's true, can you make a PR for it?

ahmad-moussawi avatar Feb 11 '21 15:02 ahmad-moussawi

Hi @ahmad-moussawi, I try to use Include feature, see example

db.Query("environment").Where("siteenvironmentid", UserEnvironmentId).IncludeMany("Organizations", db.Query("organization"), "environmentid", "siteenvironmentid");

it generates this sql statements SELECT * FROM "environment" WHERE "siteenvironmentid" = 1 SELECT * FROM "organization" WHERE "environmentid" IN ('1')

So it does not work because the second SELECT converts integers to strings Is it bug or I do something wrong? Thanks

bpasha7 avatar May 06 '21 04:05 bpasha7

there is a pr about that issue (see https://github.com/sqlkata/querybuilder/pull/494), why you don't merge this pr to solve this issue?

bsekin-jb avatar Dec 06 '22 10:12 bsekin-jb

Would love if this gets solved

andrewweitzer avatar Mar 07 '24 05:03 andrewweitzer