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

Column needs to be part of select list if it is used in order by #7748

Closed
GuptaManan100 opened this issue Mar 25, 2021 · 3 comments
Closed

Comments

@GuptaManan100
Copy link
Member

Overview of the Issue

In response to a command like User.order(:created_at).take(6) Rails issues query like

 SELECT users.* FROM users ORDER BY users.created_at ASC LIMIT 6

This thows an error on vitess

unsupported: in scatter query: order by must reference a column in the select list: users.created_at asc

Reproduction Steps

Steps to reproduce this issue, example:

  1. On vttestserver image in sharded mode create a user table with the following schema
create_table "users", force: :cascade do |t|
    t.string "name"
    t.string "email"
    t.datetime "created_at", precision: 6, null: false
    t.datetime "updated_at", precision: 6, null: false
    t.string "password_digest"
    t.string "remember_digest"
    t.boolean "admin", default: false
    t.string "activation_digest"
    t.boolean "activated", default: false
    t.datetime "activated_at"
    t.string "reset_digest"
    t.datetime "reset_sent_at"
    t.index ["email"], name: "index_users_on_email", unique: true
  end
  1. Run a schema command
alter vschema on test.users add vindex `binary_md5`(created_at) using `binary_md5`
  1. Then issue the rails command User.order(:created_at).take(6) to see the error
@harshit-gangal
Copy link
Member

Even the below query fails with same error

SELECT col FROM users ORDER BY created_at ASC LIMIT 6

@harshit-gangal
Copy link
Member

Even the below query fails with same error

SELECT col FROM users ORDER BY created_at ASC LIMIT 6

PR #8070 fixes this type of query which does have * column selection in it.

@harshit-gangal
Copy link
Member

This is resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants