Description:
Field_name has one more space when setting sql_mode=ignore_space.
How to repeat:
➜ ~ mysql -uroot --column-type-info
mysql> set sql_mode='ignore_space';
mysql> select current_timestamp from dual;
Field 1: `current_timestamp ` <--one more whitespace
Catalog: `def`
Database: ``
Table: ``
Org_table: ``
Type: DATETIME
Collation: binary (63)
Length: 19
Max_length: 19
Decimals: 0
Flags: NOT_NULL BINARY
+---------------------+
| current_timestamp |
+---------------------+
| 2024-03-12 17:00:36 |
+---------------------+
1 row in set (0.00 sec)
mysql> set sql_mode='STRICT_TRANS_TABLES';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> select current_timestamp from dual;
Field 1: `current_timestamp` <-- no whitespace
Catalog: `def`
Database: ``
Table: ``
Org_table: ``
Type: DATETIME
Collation: binary (63)
Length: 19
Max_length: 19
Decimals: 0
Flags: NOT_NULL BINARY
+---------------------+
| current_timestamp |
+---------------------+
| 2024-03-12 17:02:05 |
+---------------------+
1 row in set (0.00 sec)
Suggested fix:
I have read the mysql refernece manual section about ignore_space: 'Permit spaces between a function name and the ( character. '.The above phenomenon is inconsistent with this description and will lead to error when getting value by actual field_name.
FIX: right trim whitespace if no spectified alias