Skip to content

PostgreSQL: Misconfigured 'Winter\Blog\Models\Post' featured_images relation? #16

@aausting

Description

@aausting

Hi, i figured out a possible misconfiguration of the 'Winter\Blog\Models\Post' featured_images relation. Postgresql reports the following error:

STATEMENT:  select * from "system_files" where "system_files"."attachment_id" in (1) and "system_files"."attachment_type" = $1 and "field" = $2 order by "sort_order" asc

The IN part of the query fails cause of incompatible types (string / integer).

Adding a cast expression seems to fix this error:

'featured_images' => ['System\Models\File', 
  'key' => 'CAST (attachment_id as integer)', 
  'order' => 'sort_order'
],

I did not check, if this query works in mysql.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions