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

Save index order :desc to schema.rb (sqlite). Fixes #30902 #30970

Merged
merged 2 commits into from Oct 25, 2017

Conversation

@rohitpaulk
Copy link
Contributor

@rohitpaulk rohitpaulk commented Oct 24, 2017

Summary

Fixes #30902.

Although the sqlite adapter supports index sort orders, they weren't being written to db/schema.rb.

This uses index_xinfo instead of index_info (which was used previously), as the latter doesn't contain information about the sort order.

@rails-bot
Copy link

@rails-bot rails-bot commented Oct 24, 2017

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @rafaelfranca (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review.

Please see the contribution instructions for more information.

Although the sqlite adapter supports index sort orders, they
weren't being written to db/schema.rb.
@rohitpaulk rohitpaulk force-pushed the fix-sqlite-3-index-order-dump branch from c7ed9da to 82ae836 Oct 24, 2017
@rohitpaulk
Copy link
Contributor Author

@rohitpaulk rohitpaulk commented Oct 24, 2017

There are test failures, I'm looking into them.

@rohitpaulk
Copy link
Contributor Author

@rohitpaulk rohitpaulk commented Oct 24, 2017

Looks like PRAGMA index_xinfo was only added in sqlite 3.8.9, and the current version on Travis is 3.8.2.

@rafaelfranca
Copy link
Member

@rafaelfranca rafaelfranca commented Oct 24, 2017

We can add a method to check if it is supported and conditionally use index_xinfo

@rohitpaulk rohitpaulk force-pushed the fix-sqlite-3-index-order-dump branch from da71b0d to ab8c7a5 Oct 25, 2017
@rohitpaulk
Copy link
Contributor Author

@rohitpaulk rohitpaulk commented Oct 25, 2017

I ended up extracting ordered columns from the sql query itself, like the postgres adapter does.

@rafaelfranca rafaelfranca merged commit 08df10a into rails:master Oct 25, 2017
2 checks passed
@rohitpaulk rohitpaulk deleted the fix-sqlite-3-index-order-dump branch Oct 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants