Philip Hallstrom wrote: >> From a migration. I want to initialize a new column called "ident" >> with >> a string equal to "prec-#{id}" - where id is meant to be the id column >> of the relevant row. This works: >> >> Precinct.update_all("ident = 'prec-' || id ") >> >> I am confused about whether that bit of SQL is being parsed by Rails >> code, or whether it's given to Sqlite, in which case I am writing a >> database-dependent bit of code. > > I believe it's going to the database, but I haven't verified it.
It would have to be going to the DB, or else || wouldn't have its SQL sense of concatenation. To the OP: if this column is just going to be the id with a constant prefix, then you don't need it in the DB! > > Follow the source though to make sure... > > first line of update_all is: > sql = "UPDATE #{quoted_table_name} SET > #{sanitize_sql_for_assignment(updates)} " > So, worth looking at sanatize_sql_for_assignment to see what it might > be doing. > > -philip Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@marnen.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.