TablePlus-Windows icon indicating copy to clipboard operation
TablePlus-Windows copied to clipboard

SQL error when updating columns with ENUMs type and a default value

Open brodenbrett opened this issue 3 years ago • 4 comments

Please answer the questions below, it helps us to track the issue.

  1. Which driver are you using and version of it (Ex: PostgreSQL 10.0): MariaDB 10.4.1

  2. Which TablePlus build number are you using (the number on the welcome screen, Ex: build 81): 186

  3. The steps to reproduce this issue: Add or remove an option from an ENUM with a default value. The generated query does not wrap the default value in quotes and causes an error.

Example: The query generated when adding 'newvalue' to the enum of a field looks like:

ALTER TABLE `database`.`table` 
CHANGE `enum_field` `enum_field` enum('a','b','c','newvalue') NOT NULL DEFAULT a COMMENT '';
-- You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'a COMMENT ''' at line 2

DEFAULT a should be DEFAULT 'a'

brodenbrett avatar Feb 02 '22 21:02 brodenbrett

Hi @brodenbrett, sorry for late response. I could not reproduce this issue because it worked perfectly on my PC. Could you please me a piece of your data? It might help us easy to find out the problem. Thank you for you feedback.

sonswift avatar Feb 08 '22 09:02 sonswift

@son11592 Sorry for the late reply haha. Here's a step by step with screenshots of what I see on my PC:

Step 1: I created a table with an enum column and inserted some data: image

Step 2: I'm going into the structure tab of this table and changing the enum's 'type' column image

Step 3: Error on save image

Notice how the generated ALTER TABLE statement has not wrapped the default value in quotes: image

brodenbrett avatar Feb 14 '22 16:02 brodenbrett

Hi @brodenbrett, that's so weird! I still could not reproduce with your steps. I will investigate more into this issue. If any update, I will let you know as soon as possible. Thank you so much for your support.

sonswift avatar Feb 15 '22 04:02 sonswift

Experienced the same issue. When I edit an ENUM column, the alter code that's ran is missing single quotes around the default value.

image

jscruz27 avatar Apr 11 '22 16:04 jscruz27