cloudcreativity / laravel-json-api

JSON API (jsonapi.org) package for Laravel applications.
http://laravel-json-api.readthedocs.io/en/latest/
Apache License 2.0
778 stars 109 forks source link

Multiple primary keys - Mysql Error #628

Open mikoop79 opened 2 years ago

mikoop79 commented 2 years ago

When I have a model with multiple primary keys I get a SQL error.


SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as `` asc limit 5 offset 0' at line 1 at /var/www/v2/laravel/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:79)
[stacktrace]
lindyhopchris commented 2 years ago

The package expects models to have a single primary key. You'd need to implement this yourself, as there isn't really a good generic way for the package to know how to handle multiple primary keys. That's because the JSON:API spec defines a single id field for the key of a resource - so knowing how to map that single id value to multiple primary keys isn't really something this package can do.