go-mocket
go-mocket copied to clipboard
Ensure proper replacement
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))