Skip to content

Invalid postgres SQL with collate #755

Closed

Description

@lukaszsamson

Elixir version

any

Database and Version

postgres

Ecto Versions

3.14

Database Adapter and Versions (postgrex, myxql, etc)

postgrex

Current behavior

A valid migration:

modify :name, :text, collation: "C", null: false

generates invalid SQL:

ALTER TABLE "foo" ALTER COLUMN "name" TYPE text,
ALTER COLUMN "name" SET NOT NULL COLLATE "C"

PostgreSQL raises 42601: syntax error at or near "COLLATE".

The default case is subtler:

modify :name, :text, collation: "C", default: "x"
ALTER TABLE "foo" ALTER COLUMN "name" TYPE text,
ALTER COLUMN "name" SET DEFAULT 'x' COLLATE "C"

This succeeds, but COLLATE applies to the default expression

Expected behavior

Valid syntax according to https://www.postgresql.org/docs/current/sql-altertable.html

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions