sqlkata / querybuilder

SQL query builder, written in c#, helps you build complex queries easily, supports SqlServer, MySql, PostgreSql, Oracle, Sqlite and Firebird
https://sqlkata.com
MIT License
3.08k stars 498 forks source link

Wrong binding OrderByRaw with type of array #634

Open kenzouno1 opened 1 year ago

kenzouno1 commented 1 year ago

I'm try this query with playground. Array variable only get first index and variables after it use value of array.

Query

using SqlKata.Extensions;

var test1 = "test1";
var test2 = "test2";
var test3 = new int[]{1,2,3};

var query = new Query("Test")
.Select("test")
.OrderByRaw("Id = ? and test3 in (?) and test2=?",test1,test3,test2)
.Select("Id", "Name", "Url");

Result

SELECT * FROM "Test" ORDER BY Id = 'test1' and test3 in (1) and test2=2
Cricle commented 1 year ago

I think it's because the array becomes flat

https://github.com/sqlkata/querybuilder/blob/d9d0441a8a1a27735e962d11fafd4bc4fc396ab4/QueryBuilder/Helper.cs#L27-L49

kenzouno1 commented 1 year ago

I think it's because the array becomes flat

https://github.com/sqlkata/querybuilder/blob/d9d0441a8a1a27735e962d11fafd4bc4fc396ab4/QueryBuilder/Helper.cs#L27-L49

I think so, too. Now I'm Join array to string split by , but I think this is also a bug need to fix