Deferrable constraints in Migrations DSL

We can’t accept a feature without know what are the impacts in the codebase.

This is valid for everyone, either the core members.

I can say that I want this feature and accept it, but nothing stops the core members to revert it. And don’t expect me to defend your feature, since you should be the interested.

Would be more wast of time if we accept it now and, when you come up with the code, we rejected it because it add more complexity in the framework that we want.

Also, what is the difference of writing 10 huge emails and get the feature reject? I think is the same. With working code you have more chances. And, as I said in my last email, either if we don’t accept, you will have working code that solves your problem.

If you don’t want to scratch your itch and provide a patch, I’m sorry, but don’t expect we to accept.

And, just for record, I don’t like Cucumber :wink:

I won't ever

write a patch before getting it accepted first. I’ve done it once after some previous discussion and after the issue became totally abandoned with no feedback I decided that I wouldn’t ever do it again. Too much effort to code to get it rejected or ignored later.

You could gist an idea or provide a testless spike with minimum viable changes. In that other thread I started ( https://groups.google.com/forum/?fromgroups=#!topic/rubyonrails-core/WW9Zl5QC-vI ), what I was getting at was to try to semi-accomplish some way of determining when you could use foreigner or execute to add constraints in a db agnostic way by at least allowing a way to check that from the migration without looking at adapter_name. Version could be important for determining what to execute also.

From what I can tell it isn’t that they don’t want people to contribute, or anything elitist like that. Sure some have reps to maintain to be on the talk circuit and get books sold, but mostly I think they just don’t want something added that makes it harder to maintain, because resources are already limited for the amount of work that needs to be done. And also it is a little disconcerting to hear people that have left Rails badmouth it (head over to the ruby forum for that) and to see (from various sources: indeed.com graphs, google trends, open source code contribution graphs) that ruby/rails have somewhat stagnated, I think that ruby has a lot going for it and rails still provides a hell of a lot, so it would be nice if enough people got interested to help to get the adoption curve moving up again. I hope I’m not getting in the way of that. I’ll be the first to admit that I make a lot of mistakes and if you look through my github account there is a lot of crap in there, but getting to be involved in any way is still pretty cool.

And, just for record, I don’t like Cucumber :wink:

I didn’t like it either, but these guys make it look easy, at least to me :slight_smile: : https://github.com/gregbell/active_admin/tree/master/features

I think it depends on what it is being used for. I’d rather be writing rspecs though. When is Rails going to give up and just use rspec? :slight_smile:

Gary, I’d say never, most of the core prefer not to :slight_smile:

No one claims anything other than that. I just don't understand why code must be written before discussion.

  We can't accept a feature without know what are the

impacts in the codebase.

In the application I maintain I don't need code to understand the

impact of some feature. I don’t understand why that would be different for Rails maintainers.

This is valid for everyone, either the core members.

      I can say that I want this feature and accept it, but

nothing stops the core members to revert it. And don’t expect me to defend your feature, since you should be the interested.

My perception is that although this list is called rails-core it

seems core members don’t actually read it. Otherwise it would be easy to achieve a consensus about approving this feature or not before implementing it.

It seems to me that you're suggesting that Rails development is much

more like an anarchy. Listening to Aaron in some podcasts also seems to indicate that this is the case as well. This is how I’m understanding development happen on Rails core:

- a core member wants a feature

- he writes the change, commit it and push it

- another core member don't like the change and revert the commit

- some other core member liked the change and revert the commit that

has been reverted

How is that sane? In what point prior discussion became invaluable?

This is not how I manage my teams/softwares and I’m pretty sure this is not how most projects out there work.

      Would be more waste of time if we accept it now and, when

you come up with the code, we rejected it because it add more complexity in the framework that we want.

You should be able to understand the impact in complexity that such

a simple feature like that would have in the code base beforehand. If it happens that you don’t like my change, I’d expect you to show me how you think such feature should be implemented instead. But it wouldn’t be rejected. At some point the implementation would conform to what the core-team expect it to look like.

        Also, what is the difference of writing 10 huge emails

and get the feature reject?

Getting the feature rejected is not the issue. Spending time on

developing the feature that got rejected is. I don’t consider my e-mails huge (they are not small) but I see that for today’s standards where people got used to Twitter (I can’t use it) my messages may seem huge. But I don’t spend much time writing messages as I would spend to start contributing to any big open-source code. See, last time I contributed to Rails was several years ago, much has changed since then and I’d need to read tons of instructions and code before I started to contribute again. Additionally, AR is inside Rails repository. That means that I can’t just point to AR master in my Gemfile for instance, but this is a separate issue, let me get back to the subject.

In the end I just don't mind discussing features, but I do mind

writing code that won’t ever see the light of the day just because people can’t discuss them up-front. This is similar to the Refinements discussion in the Ruby-core list. It started with code, that code has been merged to trunk even before the discussion started. I’m pretty sure Charles Nutter was able to tell the performance impacts and had more insights about that feature just looking at the proposed feature description without starting coding it. If this discussion had started before the feature being implemented the first implementation would probably be much more aligned to the final specs and with less effort.

        I think is the same. With working code you have more

chances. And, as I said in my last email, either if we don’t accept, you will have working code that solves your problem.

No, I won't. First, I don't have a problem. I use PG and I have no

plans to support other DB vendor. But it crossed my mind the idea that maybe some open-source software could benefit from a common API to add support for deferrable unique constraints because some very common use cases (ordered tree/list) would require that and just asked here if there was such an interest in that feature.

But if I were to support that in some OSS project and I knew

beforehand that this feature isn’t going to be accepted in AR I wouldn’t use all code that I wrote to make a patch to Rails. I would rather use a much simpler approach:

module ARExtensions

  def add_deferrable_unique_index(table_name, columns, options={})

     (add_index table_name, columns, options.merge(unique: true);

return) unless db_supports_deferrable_constraint?

     name = options[:name] || ['idx', table_name, columns,

‘unique’].flatten.join(‘_’)

     execute "alter table #{table_name} add constraint #{name}

unique (#{columns.join ', '}) deferrable"

  end

 

  private

  def db_supports_deferrable_constraint?

     # TODO:  code to detect database and version here -  would

return true for PG and false for MySQL

  end

end

Then just include that module in your migration classes when you

need add_deferrable_unique_index. Much simpler to write than writing a patch to AR with docs and tests.

        If you don't want to scratch your itch and provide a

patch, I’m sorry, but don’t expect we to accept.

Ok, I get the message, just don't expect me to contribute to Rails

if I have to submit the code before discussing it.

And, just for record, I don’t like Cucumber :wink:

Me neither :) But I had to try to convince you, maybe you were a

Cucumber fan, who knows? :wink:

An example why it is not that fast to start contributing to Rails:

just tried running bundle from master branch:

Bundler could not find compatible versions for gem "multi_json":
  In snapshot (Gemfile.lock):
    multi_json (1.2.0)

  In Gemfile:
    rails (>= 0) ruby depends on
      multi_json (~> 1.3) ruby

Running `bundle update` will rebuild your snapshot from scratch,

using only the gems in your Gemfile, which may resolve the conflict.

I don't mind spending time contributing to code when I have some

free time if the code won’t be just rejected. But assuming that I would be able to start contributing with code faster than writing “huge” messages is wrong.

Weird, I just fixed it by running bundle update multi_json but git diff doesn’t report any changes to Gemfile.lock, go figure it out…

My perception is that although this list is called rails-core it seems core members don’t actually read it. Otherwise it would be easy to achieve a consensus about approving this feature or not before implementing it.

  • a core member wants a feature
  • he writes the change, commit it and push it
  • another core member don’t like the change and revert the commit
  • some other core member liked the change and revert the commit that has been reverted

How is that sane? In what point prior discussion became invaluable? This is not how I manage my teams/softwares and I’m pretty sure this is not how most projects out there work. If it happens that you don’t like my change, I’d expect you to show me how you think such feature should be implemented instead. But it wouldn’t be rejected. At some point the implementation would conform to what the core-team expect it to look like. No, I won’t. First, I don’t have a problem. I use PG and I have no plans to support other DB vendor. But it crossed my mind the idea that maybe some open-source software could benefit from a common API to add support for deferrable unique constraints because some very common use cases (ordered tree/list) would require that and just asked here if there was such an interest in that feature.

Rails is not a set of guessing features. We try to extract features from real applications that we think is a good fit for the framework.

And to close this thread, I’m really sorry if the contribution experience was not good for you in the past, but you can be sure that there are a lot of people trying to make it better now.

Please, send a patch if you want, you may be surprised. :wink:

    My

perception is that although this list is called rails-core it seems core members don’t actually read it. Otherwise it would be easy to achieve a consensus about approving this feature or not before implementing it.

You're one core member. Where are the other ones?
    -

a core member wants a feature

    - he writes the change, commit it and push it

    - another core member don't like the change and revert the

commit

    - some other core member liked the change and revert the commit

that has been reverted

    How is that sane? In what point prior discussion became

invaluable? This is not how I manage my teams/softwares and I’m pretty sure this is not how most projects out there work.

I have seen lots of projects working out there in some companies

without even using any kind of SCM. All projects work. It doesn’t mean that they do everything the best possible way.

    If

it happens that you don’t like my change, I’d expect you to show me how you think such feature should be implemented instead. But it wouldn’t be rejected. At some point the implementation would conform to what the core-team expect it to look like. No, I won’t. First, I don’t have a problem. I use PG and I have no plans to support other DB vendor. But it crossed my mind the idea that maybe some open-source software could benefit from a common API to add support for deferrable unique constraints because some very common use cases (ordered tree/list) would require that and just asked here if there was such an interest in that feature.

    Rails is not a set of guessing features. We try to extract

features from real applications that we think is a good fit for the framework.

    And to close this thread, I'm really sorry if the

contribution experience was not good for you in the past, but you can be sure that there are a lot of people trying to make it better now.

Please, send a patch if you want, you may be surprised. :wink:

Ok, I'll give it a try, but it will take some time before I can

start working on that. I’m under pressure right now and I don’t think things will get better in my job until next year. I just tried to git pull my rails clone and run the tests after following this:

http://edgeguides.rubyonrails.org/development_dependencies_install.html

But it seems the test suite don't pass when the falcon patch is

applied to Ruby, which is my case:

https://github.com/rails/rails/issues/8384

So, it is not that quick either to get started contributing to Rails

(it may require an hour or two just to get the tests passing).

So, I'll post-pone this patch as it seems to be a simple one and I

guess people are not opposing against it. But it is likely that I won’t try to contribute to Rails for many more years if the patch isn’t accepted after some feedback to get it in conformance with core’s taste.

Cheers,

Rodrigo.
So, it is not that quick either to get started contributing to Rails

(it may require an hour or two just to get the tests passing).

Rodrigo, did you try the VM method? https://github.com/rails/rails-dev-box

Also, you could just even setup a new RVM gemset, modify Rails in that gemset itself, and if that works (not adding any tests), just patch rails and do a pull request noting in the pull request that you will add tests, etc. if people are interested, then it may be closed or rejected, but then you could redo the request or ask that it be reopened after adding tests and making requested changes. I know some might not like this, but even just a direct untested pull request as a “take a look at this” could be a way to get started at the bare minimum (hopefully at least run ruby -wc path/to/file on the files you edit for syntax check :slight_smile: ), and a gist wouldn’t even involve a fork (could just copy and paste from a file in rails).

I totally understand about the time thing, though. It is good that there is a VM now available, but even that still takes time to setup.

At first it seems overwhelming as a whole just like any (somewhat) large project. But if you just find in files, or grep -r something *, or find . -name “something.rb”, or find . -name “something.rb” -exec grep -H something_else {} ; through the code, ~90% of the time (maybe that is too high) it is readable enough to find what is going on even without a backtrace or tracing, at least in pieces, without having to go that deep. And then slowly as you add something (maybe in an initializer in your app, or in a gem you write) to extend it, you can get more knowledgeable in that part. I think the core team just wants to see people have enough momentum that they only have to course-correct new features; I don’t think they are trying to stop anyone, but I know it is frustrating when in other projects you can just say “I’d like X” and they start working on it for you or tell you what files to change or give you some tips up front or spend time discussing it even if they don’t know whether anyone would be able to code what they are talking about. Good luck! Would be cool if you could spend time on what you are talking about, because I think the project I’m working on would benefit from your additions to Rails.

Understand your past experience, but to limit the chance of rejection you might want to read up on the list and elsewhere on past arguments about why constraints weren’t added and try to come up with something that would address those concerns. The problem you are trying to solve seems like it will be more politically (for lack of a better adverb) tough than it is to actually implement the code in the adapters, etc. Maybe think of maintainability first, backwards compatibility second, and flexibility third, and then place your priorities at the bottom of that stack of priorities. (That probably sounds ridiculous, but I’d bet it is correct.)

França,

I don’t know why we need to see the code to discuss if the feature makes sense or not.

Note that agreeing with the feature will be valuable to the framework does not mean the first implementation will be merged.

After all this thread I don’t actually know if foreign keys will be accepted or not.

The question is: Will be foreign keys accepted on rails?

If yes, we need to discuss how we will achieve that.

The rails development can work in this way today, but is this the best way?

The community complained about that before and we are complaining about it again.

Returning to the topic, can we receive a green light like “yes, foreign keys makes sense to rails” and them work in how we’ll be achieve that?

If we receive “no, foreign keys does not makes sense to rails” we won’t spent time on it :slight_smile:

Like I said before, I didn’t get if it can make sense or not.

Thanks for the pointer, Gary but I avoided it on purpose. 8GB is not enough anymore for my dev machine with so many processes running here (Grails + Rails + GlassFish with Java app + Solr + Redis + PG 9.1 + PG 9.2 + MySql + VirtualBox to test IE + Amarok, etc) I really want to avoid yet another VM :slight_smile:

But it seems one problem is that I was using the falcon patch to

Ruby and the other problem is that I had a few options in ~/.railsrc that prevented the railties tests to pass. All of them have already been fixed and I can now go green with Rails tests. So, next time I find some free time I’ll be able to give it a try:

https://github.com/rails/rails/issues/8384 https://github.com/rails/rails/issues/8386

Thanks to Carlos, Rafael and Steve for helping me out in the process

:slight_smile:

Man, those tests in railties are painfully slow! :( Luckily I won't

need to change railties but only activerecord I hope :slight_smile:

So that I can focus on the changes themselves, what is the

recommended way of manually testing my changes while pointing my project to use AR under my Rails clone?

gem 'activerecord', path: '~/rails-clone/activerecord' # should this

be enough? - recall that I don’t use Rails for this database management project, only standalone_migrations gem.

Cheers,

Rodrigo.

By the way, before I start implementing this first patch, I’ll keep it really short because I won’t create more complex patches depending on how this pull request progress…

I'll only add an additional boolean option to add_index called

:deferrable. This option will be ignored by non-supporting databases and when unique is false (or should it raise an exception when unique is false?).

Then it will use "alter database add constraint" on PG databases

instead of “create index” for such cases.

Please let me know in advance before I implement if the behavior

described above is not desired.

So that I can focus on the changes themselves, what is the recommended way of manually testing my changes while pointing my project to use AR under my Rails clone?

Bundler 1.2 has a feature that helps here:

$ bundle config local.activerecord ~/rails-clone/activerecord

This should override the Gemfile entry with your local copy. For more: http://gembundler.com/v1.2/whats_new.html

Thanks!