This project is archived and is in readonly mode.

#861 ✓resolved
azimux

fix for a transaction problem with change_column on postgresql if bad arguments passed in

Reported by azimux | August 19th, 2008 @ 09:19 PM | in 2.x

If you do something like this:


SomeModel.transaction do
  <A:  some queries/statements that alter database>

  change_column :table, :column, :null => false

  <B:  some more queries/statements that alter database>
end

Then the statements in A will be rolled back but the statements in B will be committed, and this happens without any errors or warnings whatsoever, and causes some confusion.

Notice how I forgot to add the column type to the change_column call, causing change_column to build an invalid statement (it tries to use 'nullfalse' as the datatype), but this exception is gobbled up by change_column which then does some transactional work of it's own, giving the said undesired side effects.

This code is there to handle some problem with pg version 7.x. This patch reraises the exception if the postgresql_version is > 80000, which means the above code raises an exception as it should.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Attachments

Referenced by

Pages