Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

POSTing to directus_fields fails #17

Closed
rijkvanzanten opened this issue Mar 26, 2018 · 8 comments
Closed

POSTing to directus_fields fails #17

rijkvanzanten opened this issue Mar 26, 2018 · 8 comments
Labels
bug Something isn't working

Comments

@rijkvanzanten
Copy link
Member

Posting a new item to /_/fields/<collection> results in

{
    "error": {
        "code": "42000",
        "message": "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 '' at line 2",
        "class": "PDOException",
        "file": "/var/www/directus-demo-api/vendor/zendframework/zend-db/src/Adapter/Driver/Pdo/Connection.php",
        "line": 379,
Full error
{
    "error": {
        "code": "42000",
        "message": "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 '' at line 2",
        "class": "PDOException",
        "file": "/var/www/directus-demo-api/vendor/zendframework/zend-db/src/Adapter/Driver/Pdo/Connection.php",
        "line": 379,
        "trace": [
            {
                "file": "/var/www/directus-demo-api/vendor/zendframework/zend-db/src/Adapter/Driver/Pdo/Connection.php",
                "line": 379,
                "function": "query",
                "class": "PDO",
                "type": "->",
                "args": [
                    "ALTER TABLE `projects`\n ADD COLUMN `testing` VARCHAR"
                ]
            },
            {
                "file": "/var/www/directus-demo-api/vendor/zendframework/zend-db/src/Adapter/Adapter.php",
                "line": 205,
                "function": "execute",
                "class": "Zend\\Db\\Adapter\\Driver\\Pdo\\Connection",
                "type": "->",
                "args": [
                    "ALTER TABLE `projects`\n ADD COLUMN `testing` VARCHAR"
                ]
            },
            {
                "file": "/var/www/directus-demo-api/src/core/Directus/Database/Schema/SchemaFactory.php",
                "line": 179,
                "function": "query",
                "class": "Zend\\Db\\Adapter\\Adapter",
                "type": "->",
                "args": [
                    "ALTER TABLE `projects`\n ADD COLUMN `testing` VARCHAR",
                    "execute"
                ]
            },
            {
                "file": "/var/www/directus-demo-api/src/core/Directus/Services/TablesService.php",
                "line": 733,
                "function": "buildTable",
                "class": "Directus\\Database\\Schema\\SchemaFactory",
                "type": "->",
                "args": [
                    {}
                ]
            },
            {
                "file": "/var/www/directus-demo-api/src/core/Directus/Services/TablesService.php",
                "line": 367,
                "function": "updateTableSchema",
                "class": "Directus\\Services\\TablesService",
                "type": "->",
                "args": [
                    "projects",
                    {
                        "fields": [
                            {
                                "type": "TINYINT",
                                "interface": "toggle",
                                "field": "testing",
                                "collection": "projects"
                            }
                        ]
                    }
                ]
            },
            {
                "file": "/var/www/directus-demo-api/src/endpoints/Fields.php",
                "line": 56,
                "function": "addColumn",
                "class": "Directus\\Services\\TablesService",
                "type": "->",
                "args": [
                    "projects",
                    "testing",
                    {
                        "type": "TINYINT",
                        "interface": "toggle"
                    },
                    []
                ]
            },
            {
                "function": "create",
                "class": "Directus\\Api\\Routes\\Fields",
                "type": "->",
                "args": [
                    {},
                    {},
                    {
                        "env": "_",
                        "collection": "projects"
                    }
                ]
            },
            {
                "file": "/var/www/directus-demo-api/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php",
                "line": 41,
                "function": "call_user_func",
                "args": [
                    [
                        {},
                        "create"
                    ],
                    {},
                    {},
                    {
                        "env": "_",
                        "collection": "projects"
                    }
                ]
            },
            {
                "file": "/var/www/directus-demo-api/vendor/slim/slim/Slim/Route.php",
                "line": 335,
                "function": "__invoke",
                "class": "Slim\\Handlers\\Strategies\\RequestResponse",
                "type": "->",
                "args": [
                    [
                        {},
                        "create"
                    ],
                    {},
                    {},
                    {
                        "env": "_",
                        "collection": "projects"
                    }
                ]
            },
            {
                "file": "/var/www/directus-demo-api/vendor/slim/slim/Slim/MiddlewareAwareTrait.php",
                "line": 117,
                "function": "__invoke",
                "class": "Slim\\Route",
                "type": "->",
                "args": [
                    {},
                    {}
                ]
            },
            {
                "file": "/var/www/directus-demo-api/vendor/slim/slim/Slim/Route.php",
                "line": 313,
                "function": "callMiddlewareStack",
                "class": "Slim\\Route",
                "type": "->",
                "args": [
                    {},
                    {}
                ]
            },
            {
                "file": "/var/www/directus-demo-api/vendor/slim/slim/Slim/App.php",
                "line": 495,
                "function": "run",
                "class": "Slim\\Route",
                "type": "->",
                "args": [
                    {},
                    {}
                ]
            },
            {
                "file": "/var/www/directus-demo-api/vendor/akrabat/rka-ip-address-middleware/src/IpAddress.php",
                "line": 93,
                "function": "__invoke",
                "class": "Slim\\App",
                "type": "->",
                "args": [
                    {},
                    {}
                ]
            },
            {
                "function": "__invoke",
                "class": "RKA\\Middleware\\IpAddress",
                "type": "->",
                "args": [
                    {},
                    {},
                    {}
                ]
            },
            {
                "file": "/var/www/directus-demo-api/vendor/slim/slim/Slim/DeferredCallable.php",
                "line": 43,
                "function": "call_user_func_array",
                "args": [
                    {},
                    [
                        {},
                        {},
                        {}
                    ]
                ]
            },
            {
                "function": "__invoke",
                "class": "Slim\\DeferredCallable",
                "type": "->",
                "args": [
                    {},
                    {},
                    {}
                ]
            },
            {
                "file": "/var/www/directus-demo-api/vendor/slim/slim/Slim/MiddlewareAwareTrait.php",
                "line": 70,
                "function": "call_user_func",
                "args": [
                    {},
                    {},
                    {},
                    {}
                ]
            },
            {
                "file": "/var/www/directus-demo-api/src/core/Directus/Application/Http/Middlewares/AuthenticationMiddleware.php",
                "line": 113,
                "function": "Slim\\{closure}",
                "class": "Slim\\App",
                "type": "->",
                "args": [
                    {},
                    {}
                ]
            },
            {
                "function": "__invoke",
                "class": "Directus\\Application\\Http\\Middlewares\\AuthenticationMiddleware",
                "type": "->",
                "args": [
                    {},
                    {},
                    {}
                ]
            },
            {
                "file": "/var/www/directus-demo-api/vendor/slim/slim/Slim/DeferredCallable.php",
                "line": 43,
                "function": "call_user_func_array",
                "args": [
                    {},
                    [
                        {},
                        {},
                        {}
                    ]
                ]
            },
            {
                "function": "__invoke",
                "class": "Slim\\DeferredCallable",
                "type": "->",
                "args": [
                    {},
                    {},
                    {}
                ]
            },
            {
                "file": "/var/www/directus-demo-api/vendor/slim/slim/Slim/MiddlewareAwareTrait.php",
                "line": 70,
                "function": "call_user_func",
                "args": [
                    {},
                    {},
                    {},
                    {}
                ]
            },
            {
                "file": "/var/www/directus-demo-api/src/core/Directus/Application/Http/Middlewares/CorsMiddleware.php",
                "line": 20,
                "function": "Slim\\{closure}",
                "class": "Slim\\App",
                "type": "->",
                "args": [
                    {},
                    {}
                ]
            },
            {
                "function": "__invoke",
                "class": "Directus\\Application\\Http\\Middlewares\\CorsMiddleware",
                "type": "->",
                "args": [
                    {},
                    {},
                    {}
                ]
            },
            {
                "file": "/var/www/directus-demo-api/vendor/slim/slim/Slim/DeferredCallable.php",
                "line": 43,
                "function": "call_user_func_array",
                "args": [
                    {},
                    [
                        {},
                        {},
                        {}
                    ]
                ]
            },
            {
                "function": "__invoke",
                "class": "Slim\\DeferredCallable",
                "type": "->",
                "args": [
                    {},
                    {},
                    {}
                ]
            },
            {
                "file": "/var/www/directus-demo-api/vendor/slim/slim/Slim/MiddlewareAwareTrait.php",
                "line": 70,
                "function": "call_user_func",
                "args": [
                    {},
                    {},
                    {},
                    {}
                ]
            },
            {
                "file": "/var/www/directus-demo-api/vendor/slim/slim/Slim/MiddlewareAwareTrait.php",
                "line": 117,
                "function": "Slim\\{closure}",
                "class": "Slim\\App",
                "type": "->",
                "args": [
                    {},
                    {}
                ]
            },
            {
                "file": "/var/www/directus-demo-api/vendor/slim/slim/Slim/App.php",
                "line": 388,
                "function": "callMiddlewareStack",
                "class": "Slim\\App",
                "type": "->",
                "args": [
                    {},
                    {}
                ]
            },
            {
                "file": "/var/www/directus-demo-api/vendor/slim/slim/Slim/App.php",
                "line": 296,
                "function": "process",
                "class": "Slim\\App",
                "type": "->",
                "args": [
                    {},
                    {}
                ]
            },
            {
                "file": "/var/www/directus-demo-api/src/core/Directus/Application/Application.php",
                "line": 142,
                "function": "run",
                "class": "Slim\\App",
                "type": "->",
                "args": [
                    false
                ]
            },
            {
                "file": "/var/www/directus-demo-api/public/index.php",
                "line": 5,
                "function": "run",
                "class": "Directus\\Application\\Application",
                "type": "->",
                "args": []
            }
        ]
    }
}
@rijkvanzanten rijkvanzanten added the bug Something isn't working label Mar 26, 2018
@wellingguzman
Copy link
Contributor

Hey @rijkvanzanten what's the request data?

@rijkvanzanten
Copy link
Member Author

{
    "field": "testing",
    "type": "TINYINT",
    "interface": "toggle"
}

Tried with type = Boolean and with collection: projects field but no luck

@adamjgrant
Copy link

I'm getting this error when setting a field to "required" from admin settings.

@adamjgrant
Copy link

screen shot 2019-02-03 at 1 13 17 pm

@wellingguzman
Copy link
Contributor

Hey @adamjgrant, are you using the development version from master?

There's a bug updating fields at the moment that was fixed recently, but has not been released yet.

Can you try using the master branch and tells us if it still happens?

@adamjgrant
Copy link

Looks like I'm on the master branch.

$ git branch
* master
$ git pull
Already up to date.
$ cat .git/config 
[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
[remote "origin"]
	url = https://github.com/directus/directus.git
	fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
	remote = origin
	merge = refs/heads/master

@wellingguzman
Copy link
Contributor

You are using the master from the directus/directus repository (which is the released build version), this was fixed in master from the directus/api repository.

Please test it using the directus/api master branch and see if it still happens. If it still happening on the master branch, can you open a new ticket explaining how we can reproduce it?

This fix hasn't been released yet on directus/directus.

@adamjgrant
Copy link

Ok thanks. I admit I don’t remember where I originally saw this issue but I’ll update from the api repo and will make a note here if I see it come back

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants