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

Further clarification to custom expressions in index #618

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/ecto/migration.ex
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,11 @@ defmodule Ecto.Migration do
# Create a tsvector GIN index on PostgreSQL
create index("products", ["(to_tsvector('english', name))"],
name: :products_name_vector, using: "GIN")

If the expression is a column name, it will not be quoted. This may cause issues
when the column is named after a reserved word. Consider using an atom instead.
Comment on lines +924 to +925

Choose a reason for hiding this comment

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

Perhaps add a quick example below for the offset problem that was stumbled on?

greg-rychlewski marked this conversation as resolved.
Show resolved Hide resolved
For example, the name `offset` is reserved in many databases so the following
could produce an error: `create index("products", ["offset"])`.
"""
def index(table, columns, opts \\ [])

Expand Down
Loading