This project is archived and is in readonly mode.
ActiveRecord no longer populates uuid ids that were generated in the database
-
Neeraj Singh
- Importance changed from to Low
Can you post your migration, model and the operation of creating the object.
-
Jeff Dean
Migration
class CreatePosts < ActiveRecord::Migration def self.up execute <<-SQL CREATE FUNCTION uuid_generate_v1() RETURNS uuid LANGUAGE c STRICT AS '$libdir/uuid-ossp', 'uuid_generate_v1'; CREATE TABLE posts ( id character varying(36) DEFAULT uuid_generate_v1() NOT NULL, title character varying ); SQL end def self.down drop_table :posts end endModel
class Post < ActiveRecord::Base endTest
require 'test_helper' class PostTest < ActiveSupport::TestCase test "save should be true" do # passes post = Post.new :title => "Foo" assert post.save, "Post save should be true" end test "save! should be true" do # passes post = Post.new :title => "Foo" assert post.save!, "Post save should be true" end test "save! should change the number of records" do # passes assert_difference('Post.count', 1) do Post.create! :title => "Foo" end end test "save assigns the id" do # fails! post = Post.create! :title => "Foo" assert post.id.present?, "Post should have an id" end endGemfile
source 'http://rubygems.org' gem 'rails', '3.0.0.rc' gem 'pg'I've also attached a zip file of the app that might be easier to use to reproduce. I haven't taken the time to see whether this is broken in other adapters.
I've confirmed that on a brand-new rails 2.3.8 app with an identical migration all tests pass. I've also included a zip file with that example.
-
Santiago Pastorino
- State changed from new to open
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.
Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.
-
Santiago Pastorino
- State changed from open to stale
