directus / v8-archive

Directus Database API — Wraps Custom SQL Databases with a REST/GraphQL API
https://docs.directus.io/api/reference.html
507 stars 203 forks source link

Unable to update translations after creation #1970

Open chrkaatz opened 4 years ago

chrkaatz commented 4 years ago

• Version of Directus: 8.8.0 • Server, OS & Database Details: Docker/Localhost, MacOS, Mysql 5.7 • Error Messages: Failed generating the SQL query. and error Code 9 • Steps to Reproduce Follow the instructions to create a translated article: https://docs.directus.io/guides/relationships.html#translations, then add an article. Initial creation works with all translations, but leaving one out initially and adding that later, fails. Also Updating already created translations seem to fail.

• Relevant Info, Screenshots, Schema & Logs

Screenshot 2020-08-05 at 10 34 38

Here you can see my Collections

Screenshot 2020-08-05 at 10 35 47 Screenshot 2020-08-05 at 10 35 56 Screenshot 2020-08-05 at 10 36 05 Screenshot 2020-08-05 at 10 36 20

`172.19.0.1 - - [05/Aug/2020:08:39:25 +0000] "GET /_/items/articletranslations?filter[article][eq]=2 HTTP/1.1" 200 849 "http://localhost:8080/admin/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Firefox/78.0" 172.19.0.1 - - [05/Aug/2020:08:39:25 +0000] "GET //activity?filter[collection][eq]=articles&filter[item][eq]=2&fields=id%2Caction%2Caction_on%2Ccomment%2Caction_by.id%2Caction_by.first_name%2Caction_by.last_name&sort=-actionon HTTP/1.1" 200 583 "http://localhost:8080/admin/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Firefox/78.0" 172.19.0.1 - - [05/Aug/2020:08:39:26 +0000] "GET /server/ping HTTP/1.1" 200 444 "http://localhost:8080/admin/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Firefox/78.0" 172.19.0.1 - - [05/Aug/2020:08:39:35 +0000] "GET //users/1?fields[0]=avatar.data.thumbnails&fields[1]=first_name&fields[2]=lastname&fields[3]=title&fields[4]=company&fields[5]=role.name HTTP/1.1" 200 559 "http://localhost:8080/admin/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Firefox/78.0" [2020-08-05 08:39:36] api[].ERROR: Directus\Database\Exception\InvalidQueryException: Failed generating the SQL query. in /var/directus/src/core/Directus/Database/TableGateway/BaseTableGateway.php:840 Stack trace:

0 /var/directus/vendor/zendframework/zend-db/src/TableGateway/AbstractTableGateway.php(361): Directus\Database\TableGateway\BaseTableGateway->executeUpdate

1 /var/directus/src/core/Directus/Database/TableGateway/BaseTableGateway.php(434): Zend\Db\TableGateway\AbstractTableGateway->updateWith

2 /var/directus/src/core/Directus/Database/TableGateway/BaseTableGateway.php(363): Directus\Database\TableGateway\BaseTableGateway->updateRecordByArray

3 /var/directus/src/core/Directus/Database/TableGateway/RelationalTableGateway.php(199): Directus\Database\TableGateway\BaseTableGateway->addOrUpdateRecordByArray

4 /var/directus/src/core/Directus/Database/TableGateway/RelationalTableGateway.php(706): Directus\Database\TableGateway\RelationalTableGateway->manageRecordUpdate

5 /var/directus/src/core/Directus/Database/TableGateway/RelationalTableGateway.php(522): Directus\Database\TableGateway\RelationalTableGateway->addOrUpdateToManyRelationships

6 /var/directus/src/core/Directus/Services/ItemsService.php(364): Directus\Database\TableGateway\RelationalTableGateway->updateRecord

7 /var/directus/src/endpoints/Items.php(121): Directus\Services\ItemsService->update

8 [internal function]: Directus\Api\Routes\Items->update

9 /var/directus/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php(40): call_user_func

10 /var/directus/vendor/slim/slim/Slim/Route.php(281): Slim\Handlers\Strategies\RequestResponse->__invoke

11 /var/directus/src/core/Directus/Application/Http/Middleware/AbstractRateLimitMiddleware.php(34): Slim\Route->__invoke

12 [internal function]: Directus\Application\Http\Middleware\AbstractRateLimitMiddleware->__invoke

13 /var/directus/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array

14 [internal function]: Slim\DeferredCallable->__invoke

15 /var/directus/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func

16 /var/directus/src/core/Directus/Application/Http/Middleware/AuthenticationMiddleware.php(124): Slim\Route->Slim{closure}

17 [internal function]: Directus\Application\Http\Middleware\AuthenticationMiddleware->__invoke

18 /var/directus/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array

19 [internal function]: Slim\DeferredCallable->__invoke

20 /var/directus/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func

21 /var/directus/src/core/Directus/Application/Http/Middleware/TableGatewayMiddleware.php(25): Slim\Route->Slim{closure}

22 [internal function]: Directus\Application\Http\Middleware\TableGatewayMiddleware->__invoke

23 /var/directus/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array

24 [internal function]: Slim\DeferredCallable->__invoke

25 /var/directus/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func

26 /var/directus/src/core/Directus/Application/Http/Middleware/DatabaseMigrationMiddleware.php(15): Slim\Route->Slim{closure}

27 [internal function]: Directus\Application\Http\Middleware\DatabaseMigrationMiddleware->__invoke

28 /var/directus/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array

29 [internal function]: Slim\DeferredCallable->__invoke

30 /var/directus/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func

31 /var/directus/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(117): Slim\Route->Slim{closure}

32 /var/directus/vendor/slim/slim/Slim/Route.php(268): Slim\Route->callMiddlewareStack

33 /var/directus/vendor/slim/slim/Slim/App.php(503): Slim\Route->run

34 /var/directus/src/core/Directus/Application/Http/Middleware/AbstractRateLimitMiddleware.php(34): Slim\App->__invoke

35 [internal function]: Directus\Application\Http\Middleware\AbstractRateLimitMiddleware->__invoke

36 /var/directus/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array

37 [internal function]: Slim\DeferredCallable->__invoke

38 /var/directus/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func

39 /var/directus/vendor/directus/proxy-detection/src/ProxyDetectionMiddleware.php(30): Slim\App->Slim{closure}

40 /var/directus/src/core/Directus/Application/Http/Middleware/ProxyMiddleware.php(18): RKA\Middleware\ProxyDetectionMiddleware->__invoke

41 [internal function]: Directus\Application\Http\Middleware\ProxyMiddleware->__invoke

42 /var/directus/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array

43 [internal function]: Slim\DeferredCallable->__invoke

44 /var/directus/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func

45 /var/directus/vendor/akrabat/ip-address-middleware/src/IpAddress.php(113): Slim\App->Slim{closure}

46 [internal function]: RKA\Middleware\IpAddress->__invoke

47 /var/directus/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array

48 [internal function]: Slim\DeferredCallable->__invoke

49 /var/directus/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func

50 /var/directus/src/core/Directus/Application/Http/Middleware/CorsMiddleware.php(71): Slim\App->Slim{closure}

51 [internal function]: Directus\Application\Http\Middleware\CorsMiddleware->__invoke

52 /var/directus/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array

53 [internal function]: Slim\DeferredCallable->__invoke

54 /var/directus/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func

55 /var/directus/src/core/Directus/Application/Http/Middleware/ResponseCacheMiddleware.php(63): Slim\App->Slim{closure}

56 [internal function]: Directus\Application\Http\Middleware\ResponseCacheMiddleware->__invoke

57 /var/directus/vendor/slim/slim/Slim/DeferredCallable.php(57): call_user_func_array

58 [internal function]: Slim\DeferredCallable->__invoke

59 /var/directus/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func

60 /var/directus/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(117): Slim\App->Slim{closure}

61 /var/directus/vendor/slim/slim/Slim/App.php(392): Slim\App->callMiddlewareStack

62 /var/directus/vendor/slim/slim/Slim/App.php(297): Slim\App->process

63 /var/directus/src/core/Directus/Application/Application.php(161): Slim\App->run

64 /var/directus/public/index.php(5): Directus\Application\Application->run [] []`

chrkaatz commented 4 years ago

@rijkvanzanten any Idea what could be the issue?

rijkvanzanten commented 4 years ago

No.. Somewhere in the API it's converting the nested JSON structure into SQL queries wrong. I'll check to make sure this doesn't occur in v9.

chrkaatz commented 4 years ago

@rijkvanzanten How stable is v9 at this point?

rijkvanzanten commented 4 years ago

The features that have been implemented are fairly stable at this point. There's still a couple pieces missing though, so depending on what features you rely on, it might not be ready for "real" use yet

jojomillennium commented 4 years ago

Same issue here with same directus version (8.8) I implemented the translation feature as per the documentation. When I create a new entry in my "Article" collection, I fill in the name, and the content in the translated field (as per @chrkaatz screenshot) => save successful on new entry creation. But If I open my entry and want to edit a translated text => "Failed generating the SQL entry".

Any progress on this? I saw @rijkvanzanten comments on v9, seems to also happen there.

jojomillennium commented 4 years ago

FYI, there is a work around to delete the field "created_on" from the parent and child table.