Selvatico / go-mocket

Go GORM & SQL mocking library
MIT License
220 stars 36 forks source link

Ensure proper replacement #31

Closed ping-localhost closed 1 year ago

ping-localhost commented 2 years ago

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 commented 1 year ago

If anyone still wants this change, let me know and I will open a new MR.