postgresql - Rails changes postgres SELECT * to SELECT COUNT -
I am working with RailsCast on token input and am trying to clear a query method for Postgres . I got to make my query db-agnostic.
My method:
def self.tokens (query) t = language.arel_table languages = Language.where (t [: name]. March ("% # {Query}% ")) if in languages [{Id: "<< query}>
", name: "new: \" # {query} \ ""}] ending
returns
: 001 & gt;
But if language from "language" ("language" "name" ILIKE '% RU%'). I use language =
instead of return
, I get the right query:
This is probably something obvious, but I did not know why the first method should be chosen Because the 'languages' table is selecting count
instead of all the rows in the DB. I would really like to store the result of that query in a variable.
This is because where it has been solved as it might possibly be (unless it's absolutely Not required)
It's counting, the reason is that in your case it needs:
- Through counting it is decided that it is empty is.
Comments
Post a Comment