Skip to content

Support for string foreign keys #5

Description

@donut

I have a table with a primary key that is of type VARCHAR and is referenced by another table, but it looks like Sequoia only supports. At least, when I try to compile I get this:

Error: This expression has type
         string Alias.Field.t = (Alias.Field.table, string) Sequoia_field.t
       but an expression was expected of type
         (Alias.Field.table, int) Sequoia_mysql.M.Field.t =
           (Alias.Field.table, int) Sequoia_field.t
       Type string is not compatible with type int

Example:

open Sequoia_mysql

module URL = struct
  include (val table "url")
  let id = Field.int "id"
  (* ... *)
end

module Alias = struct
  include (val table "alias")
  let name = Field.string "name"
  let url = Field.foreign_key "url" ~references:URL.id
  (* ... *)
end

module Use = struct
  include (val table "use")
  let id = Field.int "id"
  let alias = Field.foreign_key "alias" ~references:Alias.name (* <- error *)
  let url = Field.foreign_key "url" ~references:URL.id
  (* ... *)
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions