Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't create VARCHAR column via API #2172

Closed
beasteers opened this issue Jul 3, 2018 · 3 comments
Closed

Can't create VARCHAR column via API #2172

beasteers opened this issue Jul 3, 2018 · 3 comments

Comments

@beasteers
Copy link

Creating a VARCHAR column via the API reports a SQL error:

POST query to /api/1.1/tables/mytable/columns

Working query

request: {'column_name': 'number', 'data_type': 'INT'}
response: {'meta': {'type': 'item', 'table': 'directus_columns'}, 'data': {'id': 'number', 'name': 'number', 'column_name': 'number', 'type': 'INT', 'column_type': 'int(11)', 'length': 0, 'precision': 10, 'scale': 0, 'sort': 9999, 'default_value': None, 'nullable': True, 'key': '', 'extra': '', 'extra_options': [], 'options': [], 'table_name': 'nodes', 'required': False, 'system': False, 'ui': 'numeric', 'hidden_input': False, 'relationship': None, 'comment': "''", 'relationship_type': None, 'related_table': None, 'junction_table': None, 'junction_key_right': None, 'junction_key_left': None}}

The query with an error

request: {'column_name': 'words', 'data_type': 'VARCHAR'}
response: {'success': False, 'error': {'message': 'Statement could not be executed (42000 - 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 \'DEFAULT NULL COMMENT "\'\'"\' at line 1)'}, 'code': 0, 'class': 'Zend\\Db\\Adapter\\Exception\\InvalidQueryException', 'file': '/var/www/html/vendor/zendframework/zend-db/src/Adapter/Driver/Pdo/Statement.php', 'line': 244}

Version Info

  • Directus version and branch (Or commit hash): 6.4.9
  • PHP version: 7.1.17
  • MySQL version: Ver 14.14 Distrib 5.5.60, for debian-linux-gnu (x86_64) using readline 6.3
  • Web server: (Ex. Apache, nginx or IIS?)
  • OS name and version: Debian GNU/Linux 8 (jessie)

Steps to Reproduce

  1. create table
  2. make the two requests above
@beac0n
Copy link

beac0n commented Aug 21, 2018

It's sad, that this error still persists.
You have to provide a length property in your POST request, since VARCHAR needs a length.

This is NOT documented in https://api.getdirectus.com/1.1/#Create_Column
I only figured this out, because I reverse engineered the API, using the GUI

@benhaynes benhaynes added the v6 label Oct 12, 2018
@benhaynes
Copy link
Sponsor Member

My sincere apologies for this not being addressed sooner. Our Core staff has spent the past year working on the new version and we made the decision early on to stay focused on that rather than splitting time between both versions.

The new version is out and has 100% of our attention. We're working hard to get our docs perfect...

@benhaynes
Copy link
Sponsor Member

Kamino closed and cloned this issue to directus/directus-6-legacy

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants