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

Whitespace and sort order for Dumper Middleware #3

Merged
merged 1 commit into from
Jan 16, 2016

Conversation

pik
Copy link
Contributor

@pik pik commented Dec 28, 2015

Currently the schema_plus_enum dumper will dump in the following format:

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

  # These are extensions that must be enabled in order to support this database
  enable_extension "plpgsql"


create_enum "color", "cyan", "magenta", "yellow", "black", :schema => "cmyk"
create_enum "aaaa", "1", "2", "3"
create_enum "bar", "1", "2", "3"
create_enum "color", "cyan", "magenta", "yellow", "black"
create_enum "foo", "foo", "FOO", "bar"
  create_table "test", force: :cascade do |t|
    t.integer "col1"
  end

end

Correctly I think this should look like so, where schema being visually represented as a secondary key should perhaps also be first ordered by enum_name as a they key - (not sure about this one).

Will update and add some additional specs if this looks sensible.

params = [name.inspect]
params << values.map(&:inspect).join(', ')
params << ":schema => #{schema.inspect}" if schema != 'public'

env.initial << "create_enum #{params.join(', ')}"
env.initial << " create_enum #{params.join(', ')}"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if we would ever have more than one level of nesting on Initial and whether this should be evaluated to account for that possibility?

Copy link
Member

Choose a reason for hiding this comment

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

I haven't worried about that so far :)

@ronen
Copy link
Member

ronen commented Jan 11, 2016

Looks good, thanks. What do you think about the its suggestion?

ronen added a commit that referenced this pull request Jan 16, 2016
Whitespace and sort order for Dumper Middleware
@ronen ronen merged commit ba14327 into SchemaPlus:master Jan 16, 2016
@ronen
Copy link
Member

ronen commented Jan 16, 2016

I've gone ahead and merged this, then added my cleanup and also added a spec to verify the sort order.

I've pushed release v0.1.1 with this in it.

Thanks again

@pik
Copy link
Contributor Author

pik commented Jan 16, 2016

Thanks, apologies for not keeping up during the week. When you have sometime do you think you could update the discussion here: #2 (comment)

I'm still hoping there might be a way to do this given the existing ActiveRecord code - but if you don't see a way of doing so it might make sense to open a discussion on the rails mailing list.

@ronen
Copy link
Member

ronen commented Jan 18, 2016

When you have sometime do you think you could update the discussion here: #2 (comment)

yep, done.

... open a discussion on the rails mailing list.

I don't think that's necessary for this case.

That said, as a general statement of principle I'd be completely happy for anything and everything added by the schema_plus family to be supported natively in AR. In my ideal world, schema_plus would have no need to exist! :)

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.

2 participants