Skip to content

UUID's as Primary KeysΒ #480

@crimson-knight

Description

@crimson-knight

When you have a model that you want to use a UUID as the primary key with the column id you'll get an error that an overload does not exist:

Error: expected argument #2 to 'Granite::Type.from_rs' to be (Array(Bool) | Nil).class, (Array(Float32) | Nil).class, (Array(Float64) | Nil).class, (Array(Int16) | Nil).class, (Array(Int32) | Nil).class, (Array(Int64) | Nil).class, (Array(Int8) | Nil).class, (Array(String) | Nil).class, (Array(UInt16) | Nil).class, (Array(UInt32) | Nil).class, (Array(UInt64) | Nil).class, (Array(UInt8) | Nil).class, (Bool | Nil).class, (Float32 | Nil).class, (Float64 | Nil).class, (Int16 | Nil).class, (Int32 | Nil).class, (Int64 | Nil).class, (Int8 | Nil).class, (String | Nil).class, (Time | Nil).class, (UInt16 | Nil).class, (UInt32 | Nil).class, (UInt64 | Nil).class, (UInt8 | Nil).class, Array(Bool).class, Array(Float32).class, Array(Float64).class, Array(Int16).class, Array(Int32).class, Array(Int64).class, Array(Int8).class, Array(String).class, Array(UInt16).class, Array(UInt32).class, Array(UInt64).class, Array(UInt8).class, Bool.class, Float32.class, Float64.class, Int16.class, Int32.class, Int64.class, Int8.class, String.class, Time.class, UInt16.class, UInt32.class, UInt64.class or UInt8.class, not UUID.class

Note the not UUID.class at the end.

Following all of the documentation and trying:

column id : UUID, primary: true
# OR
column uuid : UUID, primary: true

Both produce the same error. So somewhere along the line we lost support for UUID's as primary keys.

  1. Let's re-enable this feature
  2. Let's add test coverage to ensure UUID's as primary keys will be stable going forward (supported by MySQL, PG and SQLite3)

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