go-mocket icon indicating copy to clipboard operation
go-mocket copied to clipboard

Ensure proper replacement

Open ping-localhost opened this issue 2 years ago • 0 comments

Any LIKE %%-statement with another Where-statement is currently not properly checked. This PR resolves that.

Example:

query = s.db.Table("accounts").
    Where("accounts.firstName LIKE ?", "%John%").
    Where("accounts.lastName = ?", "Doe")

Creates the fake query:

SELECT * FROM "accounts"  WHERE "accounts"."deleted_at" IS NULL AND ((accounts.firstName LIKE %!J(string=Doe)ohn%!)(MISSING) AND (accounts.lastName = %!v(MISSING)))

With this change it generates it properly:

SELECT * FROM "accounts"  WHERE "accounts"."deleted_at" IS NULL AND ((accounts.firstName LIKE %John%) AND (accounts.lastName = Doe))

ping-localhost avatar Aug 03 '22 12:08 ping-localhost