0

When updating column in postgresql we can reset it value to DEFAULT

UPDATE table SET column = DEFAULT

Is there analogue in DBIx::Class? Just like this:

$schame->result_set( 'table' )->update({ column => DEFAULT })
Eugen Konkov
  • 22,193
  • 17
  • 108
  • 158

1 Answers1

0

Thank you to ilmari. I need ref to use literal SQL:

$schame->result_set( 'table' )->update({ column => \'DEFAULT' })
simbabque
  • 53,749
  • 8
  • 73
  • 136
Eugen Konkov
  • 22,193
  • 17
  • 108
  • 158
  • Note that this is now engine specific. You will not be able to port it to say SQLite. – simbabque Oct 05 '17 at 15:48
  • @simbabque: Is there non engine specific way? – Eugen Konkov Oct 05 '17 at 18:42
  • I don't think so. If a maintainer doesn't know then probably not. I don't think sqlite or MySQL can even do that. Oracle maybe. – simbabque Oct 05 '17 at 18:52
  • If you use DBIx::Class consistently, you should have that default in the column_info. In which case you can update to that. – bytepusher Oct 05 '17 at 20:15
  • @bytepusher: If you mean `default_value` that is different thing. and `->update({ column => undef })` will not work if `is_nullable => 0` – Eugen Konkov Oct 06 '17 at 06:22
  • 1
    @EugenKonkov: That is what I was referring to. And that is non engine- specific information stored in the model. If it's not in the model, you need to use an engine-specific way of getting it out. – bytepusher Oct 06 '17 at 19:58