Rake Unit Testing : “False” being used for column “no” #8612

Closed
nishantmodak opened this Issue Dec 26, 2012 · 5 comments

Comments

Projects
None yet
3 participants
@nishantmodak
Contributor

nishantmodak commented Dec 26, 2012

Post :: Model

class Post < ActiveRecord::Base
attr_accessible :body, :name, :no, :num
end

Posts.yml under (test/fixtures/)
one:
name: MyString
body: MyString
no: 1
num: 2

On running, rake test:units, the following stack trace is generated

    test_Post_for_correct_attributes(PostTest):
    ActiveRecord::StatementInvalid: SQLite3::SQLException: table posts has no column named false:         INSERT INTO "posts" ("name", "body", "false", "num", "created_at", "updated_at", "id") VALUES ('MyString', 'MyString', 1, 2, '2012-12-26 10:24:36', '2012-12-26 10:24:36', 980190962)

Now, here - the table field 'no' has been converted to 'false'. (which seems to be a problem since its being interpreted as FALSE and not as a object variable)
A bug with how it is converting the variables from yaml to object?
Rails version Rails 3.2.9 and Ruby ruby 1.9.3p194

http://stackoverflow.com/questions/14039477/rake-unit-testing-false-being-used-for-column-no

@nishantmodak

This comment has been minimized.

Show comment Hide comment
@nishantmodak

nishantmodak Dec 26, 2012

Contributor

To be able to run it , one needs to escape no with quotation marks as below

"no" : 1
Contributor

nishantmodak commented Dec 26, 2012

To be able to run it , one needs to escape no with quotation marks as below

"no" : 1
@senny

This comment has been minimized.

Show comment Hide comment
@senny

senny Dec 26, 2012

Member

Thanks for your report. The word no is a reserved YAML keyword. It is a textual representation of false as described in the specification. This is the expected behavior and is not related to the rails source code.

I'm closing this one because it's not a bug in rails and the YAML spec describes that yes/no will be converted to booleans and need to be escaped otherwise.

Member

senny commented Dec 26, 2012

Thanks for your report. The word no is a reserved YAML keyword. It is a textual representation of false as described in the specification. This is the expected behavior and is not related to the rails source code.

I'm closing this one because it's not a bug in rails and the YAML spec describes that yes/no will be converted to booleans and need to be escaped otherwise.

@senny senny closed this Dec 26, 2012

@nishantmodak

This comment has been minimized.

Show comment Hide comment
@nishantmodak

nishantmodak Dec 26, 2012

Contributor

@senny But, the Posts.yml is an auto-generated file through rails scaffolding.

Shouldn't the generation look for such anomaly and warn about it or at-least escape them itself?

Contributor

nishantmodak commented Dec 26, 2012

@senny But, the Posts.yml is an auto-generated file through rails scaffolding.

Shouldn't the generation look for such anomaly and warn about it or at-least escape them itself?

@senny senny reopened this Dec 26, 2012

@senny

This comment has been minimized.

Show comment Hide comment
@senny

senny Dec 26, 2012

Member

@nishantmodak thanks for the heads-up. It did not come to my mind, that the file was generated 😓. I'll have a look at it.

Member

senny commented Dec 26, 2012

@nishantmodak thanks for the heads-up. It did not come to my mind, that the file was generated 😓. I'll have a look at it.

@senny

This comment has been minimized.

Show comment Hide comment
@senny

senny Dec 26, 2012

Member

@nishantmodak I submitted a PR to fix the issue. Once it's merged I'll try to backport it back to 3-2-stable.

Member

senny commented Dec 26, 2012

@nishantmodak I submitted a PR to fix the issue. Once it's merged I'll try to backport it back to 3-2-stable.

sgerrand pushed a commit to sgerrand/rails that referenced this issue Nov 2, 2013

Update documentation for yml usage
Update documentation for yml usage against rails#8612
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment