Skip to content

WHERE values come up as @p0, @p1 etc. in every query (in Unity) #416

@MaxwellDexter

Description

@MaxwellDexter

Hi I'm using SqlKata v2.2.0 (no execution package) in Unity 2019.3.14f1 on a Mac. I have the 'Api Compatibility Level' configured at .NET 4.x.
Whenever I try and compile a query with a WHERE statement it doesn't inject the values into the query when I retrieve it as an SQL string.
Using the same(ish) code from the default playground scenario:

MySqlCompiler compiler = new MySqlCompiler();
var query = new Query("Users")
        .Where("Name", "Sami")
        .Where(q =>
            q.Where("Country", "Lebanon")
            .OrWhere("Country", "France")
        );
print(compiler.Compile(query).Sql);

I get the result:
SELECT * FROM "Users" WHERE "Name" = @p0 AND ("Country" = @p1 OR "Country" = @p2)

I'm using the SQLite compiler but it also happens for the others:
SQLServer: SELECT * FROM [Users] WHERE [Name] = @p0 AND ([Country] = @p1 OR [Country] = @p2)
MySQL: SELECT * FROM 'Users' WHERE 'Name' = @p0 AND ('Country' = @p1 OR 'Country' = @p2)

I've tried this on other queries and get a similar result:
SELECT * FROM "ConsumableData" INNER JOIN "ItemData" ON "ConsumableData"."ID" = "ItemData"."ID" WHERE "ConsumableData"."ID" = @p0

RawSql works, all of the @pXs come up as ?. I'd rather be able to use the package like it's intended however.
Any thoughts on this?

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