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

Refactor ColumnDumper to support consistent Virtual column with Rails #1185

Merged
merged 1 commit into from
Feb 17, 2017

Conversation

yahonda
Copy link
Collaborator

@yahonda yahonda commented Feb 17, 2017

This pull request addresses these 3 failures:

$ ARCONN=oracle bundle exec ruby -w -Itest test/cases/schema_dumper_test.rb -n /no_line_up/

... snip ...

Finished in 21.899343s, 0.0913 runs/s, 0.5480 assertions/s.

  1) Failure:
SchemaDumperTest#test_arguments_no_line_up [test/cases/schema_dumper_test.rb:100]:
Failed assertion, no message given.


  2) Failure:
SchemaDumperTest#test_types_no_line_up [test/cases/schema_dumper_test.rb:94]:
Failed assertion, no message given.

2 runs, 12 assertions, 2 failures, 0 errors, 0 skips
$ ARCONN=oracle bundle exec ruby -w -Itest test/cases/migration_test.rb -n test_deprecate_migration_keys

... snip ...



# Running:

F

Finished in 0.005173s, 193.2977 runs/s, 193.2977 assertions/s.

  1) Failure:
CopyMigrationsTest#test_deprecate_migration_keys [test/cases/migration_test.rb:1143]:
Expected a deprecation warning within the block but received none

1 runs, 1 assertions, 1 failures, 0 errors, 0 skips
$

Refer these changes at Rails:

This commit introduces Virtual column schema dumper format change. :type attribute shown next to column name.

Align changes has been introduced by rails/rails@df84e986721 .

  • Before this commit:
ActiveRecord::Schema.define(version: 0) do

  create_table "test_names", force: :cascade do |t|
    t.string  "first_name"
    t.string  "last_name"
    t.virtual "full_name",                limit: 512,                as: "\"FIRST_NAME\"||', '||\"LAST_NAME\"",                              type: :string
    t.virtual "short_name",               limit: 300,                as: "COALESCE(\"FIRST_NAME\",\"LAST_NAME\")",                           type: :string
    t.virtual "abbrev_name",              limit: 100,                as: "SUBSTR(\"FIRST_NAME\",1,50)||' '||SUBSTR(\"LAST_NAME\",1,1)||'.'", type: :string
    t.virtual "name_ratio",                                          as: "LENGTH(\"FIRST_NAME\")*10/LENGTH(\"LAST_NAME\")*10"
    t.virtual "full_name_length",                     precision: 38, as: "LENGTH(\"FIRST_NAME\"||', '||\"LAST_NAME\")",                      type: :integer
    t.virtual "field_with_leading_space", limit: 300,                as: "' '||\"FIRST_NAME\"||' '",                                         type: :string
  end

end
  • After this commit:
ActiveRecord::Schema.define(version: 0) do

  create_table "test_names", force: :cascade do |t|
    t.string "first_name"
    t.string "last_name"
    t.virtual "full_name", type: :string, limit: 512, as: "\"FIRST_NAME\"||', '||\"LAST_NAME\""
    t.virtual "short_name", type: :string, limit: 300, as: "COALESCE(\"FIRST_NAME\",\"LAST_NAME\")"
    t.virtual "abbrev_name", type: :string, limit: 100, as: "SUBSTR(\"FIRST_NAME\",1,50)||' '||SUBSTR(\"LAST_NAME\",1,1)||'.'"
    t.virtual "name_ratio", as: "LENGTH(\"FIRST_NAME\")*10/LENGTH(\"LAST_NAME\")*10"
    t.virtual "full_name_length", type: :integer, precision: 38, as: "LENGTH(\"FIRST_NAME\"||', '||\"LAST_NAME\")"
    t.virtual "field_with_leading_space", type: :string, limit: 300, as: "' '||\"FIRST_NAME\"||' '"
  end

end

Refer these changes at Rails:
  rails/rails#26756
  rails/rails#22589
  rails/rails@df84e986721
  rails/rails#27884

This commit introduces Virtual column schema dumper format change:
`:type` attribute shown next to column name.

Align changes has been introduced by rails/rails@df84e986721 .

* Before this commit:

```ruby
ActiveRecord::Schema.define(version: 0) do

  create_table "test_names", force: :cascade do |t|
    t.string  "first_name"
    t.string  "last_name"
    t.virtual "full_name",                limit: 512,                as: "\"FIRST_NAME\"||', '||\"LAST_NAME\"",                              type: :string
    t.virtual "short_name",               limit: 300,                as: "COALESCE(\"FIRST_NAME\",\"LAST_NAME\")",                           type: :string
    t.virtual "abbrev_name",              limit: 100,                as: "SUBSTR(\"FIRST_NAME\",1,50)||' '||SUBSTR(\"LAST_NAME\",1,1)||'.'", type: :string
    t.virtual "name_ratio",                                          as: "LENGTH(\"FIRST_NAME\")*10/LENGTH(\"LAST_NAME\")*10"
    t.virtual "full_name_length",                     precision: 38, as: "LENGTH(\"FIRST_NAME\"||', '||\"LAST_NAME\")",                      type: :integer
    t.virtual "field_with_leading_space", limit: 300,                as: "' '||\"FIRST_NAME\"||' '",                                         type: :string
  end

end
```

* After this commit:
```
ActiveRecord::Schema.define(version: 0) do

  create_table "test_names", force: :cascade do |t|
    t.string "first_name"
    t.string "last_name"
    t.virtual "full_name", type: :string, limit: 512, as: "\"FIRST_NAME\"||', '||\"LAST_NAME\""
    t.virtual "short_name", type: :string, limit: 300, as: "COALESCE(\"FIRST_NAME\",\"LAST_NAME\")"
    t.virtual "abbrev_name", type: :string, limit: 100, as: "SUBSTR(\"FIRST_NAME\",1,50)||' '||SUBSTR(\"LAST_NAME\",1,1)||'.'"
    t.virtual "name_ratio", as: "LENGTH(\"FIRST_NAME\")*10/LENGTH(\"LAST_NAME\")*10"
    t.virtual "full_name_length", type: :integer, precision: 38, as: "LENGTH(\"FIRST_NAME\"||', '||\"LAST_NAME\")"
    t.virtual "field_with_leading_space", type: :string, limit: 300, as: "' '||\"FIRST_NAME\"||' '"
  end

end
```
@yahonda yahonda merged commit a3c78cd into rsim:master Feb 17, 2017
@yahonda yahonda deleted the use_super_prepare_column_options branch February 18, 2017 14:39
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

Successfully merging this pull request may close these issues.

None yet

1 participant