SQL 文 のリテラルとしてエスケープできることが自明 irb(main):001> User.find_by(name: "' OR 1 --") User Load (0.8ms) SELECT "users".* FROM "users" WHERE "users"."name" = $1 LIMIT $2 [["name", "' OR 1 --"], ["LIMIT", 1]] postgresql irb(main):001> User.find_by(name: "' OR 1 --") User Load (1.6ms) SELECT `users`.* FROM `users` WHERE `users`.`name` = '\' OR 1 --' LIMIT 1 mysql2 irb(main):013> User.where("name = ?", "' OR 1 --") User Load (2.4ms) SELECT "users".* FROM "users" WHERE (name = ''' OR 1 --') /* loading for pp */ LIMIT $1 [["LIMIT", 11]] postgresql