I'm sorry for the rudimentary question, but ...
Suppose I want to execute the following query on rails console.
At this time, the SQL that is spit out on the log has the following format.
SELECT "users". * FROM "users" WHERE "users". "Id" =? LIMIT? [["Id", 1], ["LIMIT", 1]]
However, when I actually write the above SQL by myself, I usually think that it will be in the following form.
(Conversely, if the statement output in the above log is executed directly as SQL on the db console etc.
Error: near "[[" id ", 1]": syntax errorIt cannot be executed next to it. .. )
SELECT * FROM "users" WHERE "id" = 1 LIMIT 1;
Why is the actual writing format and the log format different here?
Even if you try to check the SQL issued from the log, it is often different from the pure SQL as described above. ..
Can anyone please teach me the above reasons and "references for reading (converting?) SQL output to the log"?
Answer # 1
Reasons for the above and "References for reading (converting?) SQL output to the log"
It's called a placeholder.
Even if you try to check the SQL issued from the log, it is often different from pure SQL as described above.
It's a SQL injection measure.
If you want SQL that can be executed by copy and paste, SQL trace may not be via bind variables, so why not check it?
- ruby on rails - format created_at in js file
- solution for json format errors in ruby on rails
- ruby on rails - [rails] i'm implementing a search function using form_with, but i'm having trouble with the search results not b
- ruby on rails - i would like to add an automatic address input function to the new registration screen
- ruby - [rails] i want to find the date difference using the model created_at
- ruby on rails - i want to resolve rails wrong number of arguments
- ruby on rails - questions about routes
- ruby - [rails] i want to create an image link using the url of the image output using active storage
- ruby - rails causes activerecord :: recordnotfound and routing error at the same time
- ruby on rails - after installing devise on rails6, routing error occurs, so i want to eliminate it
- ruby - the last db setting doesn't work when deploying rails app on aws
- ruby on rails - i can't update rubygems
- ruby - about "activemodel :: unknownattributeerror" of rails
- ruby on rails 6 - rails6 activerecord :: recordinvalid in userscontroller # update
- ruby - [rails] i want to change the argument of link_to using conditional branching
- ruby on rails 6 - i changed the project name of rails, but it became inaccessible
- ruby on rails - i want to jump to the action of another controller with render
- ruby on rails - heroku: how to check the database_url used for regular backup
- ruby on rails 5 - i want to update the received parameters with nil
- python - you may need to restart the kernel to use updated packages error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- sh - 'apt-get' is not recognized as an internal or external command, operable program or batch file
- i want to call a child component method from a parent in vuejs
- python 3x - typeerror: 'method' object is not subscriptable