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

:null => false, and MYSQL 5.0.x #10

Closed
Porta opened this issue Nov 12, 2010 · 5 comments
Closed

:null => false, and MYSQL 5.0.x #10

Porta opened this issue Nov 12, 2010 · 5 comments

Comments

@Porta
Copy link

Porta commented Nov 12, 2010

I discovered that (though I cannot confirm 100%) that under mysql 5.0.x, if in the migration I set :null => false for the :state field, BUT don't provide a :default value on the migration, transitions doesn't set the initial state for the Model and it fails to be created.
This didn't happened on mysql 5.1.x.
I wrote a test here:
git://github.com/Porta/test_null_without_default.git
In case you'd like to test it.
Let me know if I can do anything else.

@qoobaa
Copy link
Collaborator

qoobaa commented Nov 16, 2010

Thanks for reporting the issue. I'll try to find some time to look at it (but it may not be easy to reproduce).

@Porta
Copy link
Author

Porta commented Nov 18, 2010

No problem. Let me know if I can help in any way.

@onknows
Copy link

onknows commented Jan 22, 2011

Same here. I'm on MySQL 5.1 but I doubt that MySQL version is the problem. The problem is that the initial state is not set. The way it should work is that the first state should be used as initial state. At least that is what I understand from the documentation. Workaround is to specify the initial state in migration as the default value.

@qoobaa
Copy link
Collaborator

qoobaa commented Jan 27, 2011

I don't use MySQL in my recent projects. Any volunteer to check/fix it?

@troessner
Copy link
Owner

@Porta , @ostraaten I can't reproduce this.
I set up a sample repo so that we can talk about the same thing: https://github.com/troessner/transitions_intial_state_bug

There is one migration with null: false : https://github.com/troessner/transitions_intial_state_bug/blob/master/db/migrate/20120526121122_create_orders.rb
with a very simple model here: https://github.com/troessner/transitions_intial_state_bug/blob/master/app/models/order.rb

In this project the initial state is set:

>> o = Order.new
=> #<Order id: nil, state: "fresh", created_at: nil, updated_at: nil>
>> o.state
=> "fresh"

you can easily see what I mean by:

git clone https://github.com/troessner/transitions_intial_state_bug
cd transitions_intial_state_bug
bundle install
bundle exec db:create db:migrate
rails c

and then do a

Order.new.state

I assume this issue has been fixed with unrelated commits.
I am closing this issue for now until somebody claims that this is still an issue for him and can give me clean instructions on how to reproduce that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants