Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PK constraint on bigserial ID columns on postgres adapter #10455

Merged

Conversation

patricksrobertson
Copy link
Contributor

In #10410 it was noted that you can no longer create PK's with the
type of bigserial in PostgreSQL in 4.0.0.rc1. This is mostly
because the newer adapter is checking for column type with the
id column instead of just letting it pass through like it did
before.

Side effects:
You may just create a PK column of a type that you really don't
want to be your PK. As far as I can tell this was allowed in 3.2.X
and perhaps an exception should be raised if you try and do
something extremely dumb.

In rails#10410 it was noted that you can no longer create PK's with the
type of bigserial in PostgreSQL in 4.0.0.rc1. This is mostly
because the newer adapter is checking for column type with the
id column instead of just letting it pass through like it did
before.

Side effects:
You may just create a PK column of a type that you really don't
want to be your PK. As far as I can tell this was allowed in 3.2.X
and perhaps an exception should be raised if you try and do
something extremely dumb.
@patricksrobertson
Copy link
Contributor Author

@tenderlove this might be ready for your review now.

tenderlove added a commit that referenced this pull request May 7, 2013
…ntifying_pk

Add PK constraint on bigserial ID columns on postgres adapter
@tenderlove tenderlove merged commit 3043d45 into rails:master May 7, 2013
tenderlove added a commit that referenced this pull request May 7, 2013
…ntifying_pk

Add PK constraint on bigserial ID columns on postgres adapter
@patricksrobertson patricksrobertson deleted the bigserial_id_not_identifying_pk branch May 7, 2013 17:15
@@ -359,8 +359,12 @@ class TableDefinition < ActiveRecord::ConnectionAdapters::TableDefinition
# a record (as primary keys cannot be +nil+). This might be done via the
# +SecureRandom.uuid+ method and a +before_save+ callback, for instance.
def primary_key(name, type = :primary_key, options = {})
return super unless type == :uuid
options[:default] = options.fetch(:default, 'uuid_generate_v4()')
return super unless type = :primary_key
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line seems wrong. Can you run the pg tests and resend a pull request?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That line is indeed very wrong. Will correct it in a sec.

@tenderlove
Copy link
Member

Sorry, I should have reviewed more closely, but this PR seems wrong. I'm reverting the merge commit. Can you check the pg tests and resubmit? Specifically we're getting a failure on: PostgresqlUUIDTestNilDefault#test_id_allows_default_override_via_nil

tenderlove added a commit that referenced this pull request May 7, 2013
…_not_identifying_pk"

This reverts commit 3043d45, reversing
changes made to ca0275d.
tenderlove added a commit that referenced this pull request May 7, 2013
…_not_identifying_pk"

This reverts commit 3043d45, reversing
changes made to ca0275d.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants