On Monday, June 18, 2018 at 2:30:46 AM UTC-7, Ian Murray wrote:
>
> I tried the same situation in a Postgres, and the error seems slightly 
> different, depending on the command:
>
> testdb=> insert into table values ('lorem ipsum');
> ERROR:  cannot execute INSERT in a read-only transaction
> testdb=> update table set name = 'lorem ipsum';
> ERROR:  cannot execute UPDATE in a read-only transaction
> testdb=> delete from table;
> ERROR:  cannot execute DELETE in a read-only transaction
>
> Hopefully it's simple to consider this scenario as well in the postgres 
> adapter.
>

Unfortunately not.  On PostgreSQL, you can have read only transactions 
without the connection being read only, and those shouldn't be treated as a 
disconnect error:

  DB.transaction(:read_only=>true){DB[:bar].insert}

You can use a local patch for that:

  def DB.disconnect_error?(e, opts)
    super || e.message =~ /cannot execute (INSERT|UPDATE|DELETE) in a 
read-only transaction/
  end

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to