rorecek / laravel-ulid

Laravel package for ULID (Universally Unique Lexicographically Sortable Identifier)
MIT License
52 stars 15 forks source link

Key Type needs to be defined for "many" relationships #5

Closed richardnbanks closed 4 years ago

richardnbanks commented 4 years ago

When using "many" relationships error like the following is produced:

SQLSTATE[42883]: Undefined function: 7 ERROR:  operator does not exist: character = integer
LINE 1: select * from "files" where "files"."fileable_id" in (1, 1, ...

HINT:  No operator matches the given name and argument types. You might need to add explicit type casts. (SQL: select * from "files" where "files"."fileable_id" in (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) and "files"."fileable_type" = App\\Contract and "files"."deleted_at" is null)

This can be fixed by adding the getKeyType function to the trait and setting it to string.