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

Remove extra space from schema dumper output #247

Conversation

sharipov-ru
Copy link
Contributor

Scenic dumps db/schema.rb with redundant space symbol before sql_definition parameter:

Example 1:

create_view "old_users",  sql_definition: <<-SQL
    SELECT users.id,
    users.name,
    users.age,
    users.created_at,
    users.updated_at
   FROM users
  WHERE (users.age > 100);
SQL

Example 2 with materialized view:

create_view "young_users", materialized: true,  sql_definition: <<-SQL
    SELECT users.id,
    users.name,
    users.age,
    users.created_at,
    users.updated_at
   FROM users
  WHERE (users.age < 100);
SQL

This PR fixes it, so that there are no extra spaces before sql_definition and linters like rubocop don't complain here anymore.

After:

Example 1:

create_view "old_users", sql_definition: <<-SQL
    SELECT users.id,
    users.name,
    users.age,
    users.created_at,
    users.updated_at
   FROM users
  WHERE (users.age > 100);
SQL

Example 2 with materialized view:

create_view "young_users", materialized: true, sql_definition: <<-SQL
    SELECT users.id,
    users.name,
    users.age,
    users.created_at,
    users.updated_at
   FROM users
  WHERE (users.age < 100);
SQL


output = stream.string

expect(output).to include 'create_view "searches", materialized: true, sql_definition: <<-SQL'

Choose a reason for hiding this comment

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

Metrics/LineLength: Line is too long. [98/80]

@@ -25,6 +26,19 @@ class SearchInAHaystack < ActiveRecord::Base
expect(Search.first.haystack).to eq "needle"
end

it "dumps a create_view for a materialized view in the database" do
view_definition = "SELECT 'needle'::text AS haystack"
Search.connection.create_view :searches, materialized: true, sql_definition: view_definition

Choose a reason for hiding this comment

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

Metrics/LineLength: Line is too long. [96/80]

@sharipov-ru sharipov-ru force-pushed the fix-extra-spaces-in-schema-dumper-output branch from 013dc58 to 07b1580 Compare July 16, 2018 11:37
@calebhearth
Copy link
Contributor

Thanks!

@calebhearth calebhearth merged commit 8071d5e into scenic-views:master Jul 16, 2018
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.

3 participants