[Rails] Re: Sql update_all with string concatenate

2010-02-10 Thread Marnen Laibow-Koser
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

[Rails] Re: Sql update_all with string concatenate

2010-02-10 Thread Pito Salas
Marnen Laibow-Koser wrote: 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! It's initializing existing records in a migration. Over time the match will not be present. To the other point about || meaning concatenation. Thats what

Re: [Rails] Re: Sql update_all with string concatenate

2010-02-10 Thread Philip Hallstrom
On Feb 10, 2010, at 4:31 PM, Pito Salas wrote: Marnen Laibow-Koser wrote: 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! It's initializing existing records in a migration. Over time the match will not be present. To the other