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

[bug] delete/update got error as column name without quote if the column name is a keyword. #560

Closed
hustjieke opened this issue Jan 3, 2020 · 2 comments
Assignees
Labels
type: bug Something isn't working

Comments

@hustjieke
Copy link
Contributor

when shift from mysql to mysql, when we do update/delete action, we'll get error as the column name we send is without quote if che column name is a keyword.

e.g.:

mysql> create table normal(`char` int, b int);
Query OK, 0 rows affected (0.02 sec)

mysql> insert into normal values(1,1),(2,3);
Query OK, 2 rows affected (0.01 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> delete from normal where char = 1;
ERROR 1064 (42000): 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 '= 1' at line 1
mysql> delete from normal where `char` = 1;
Query OK, 1 row affected (0.02 sec)

mysql> select * from normal;
+------+------+
| char | b    |
+------+------+
|    2 |    3 |
+------+------+
1 row in set (0.00 sec)
@hustjieke hustjieke added the type: bug Something isn't working label Jan 3, 2020
@hustjieke hustjieke self-assigned this Jan 3, 2020
@BohuTANG
Copy link
Contributor

BohuTANG commented Jan 6, 2020

ACK

@hustjieke
Copy link
Contributor Author

checksum table without quote, if table has "-", we'll meet SQL syntax error:

mysql> create table `a-b_tbl`(a int);
Query OK, 0 rows affected (0.03 sec)

mysql> checksum table a-b_tbl;
ERROR 1064 (42000): 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 '-b_tbl' at line 1
mysql> checksum table `a-b_tbl`;
+------------+----------+
| Table      | Checksum |
+------------+----------+
| db.a-b_tbl |        0 |
+------------+----------+
1 row in set (0.01 sec)

hustjieke added a commit to hustjieke/radon that referenced this issue Jan 10, 2020
[summary]
1. db or table name may include "-", like "a-b_db" or "a-b_tbl"
2. column name may be a keyword, like "char", "key"...
They should be quoted when send delete/update sql to backend.
[test case]
vendor/github.com/radondb/shift/shift_test
[patch codecov]
vendor/github.com/radondb/shift/shift   coverage: 76.1% of statements
hustjieke added a commit to hustjieke/radon that referenced this issue Jan 10, 2020
[summary]
1. db or table name may include "-", like "a-b_db" or "a-b_tbl"
2. column name may be a keyword, like "char", "key"...
They should be quoted when send delete/update sql to backend.
[test case]
vendor/github.com/radondb/shift/shift_test
[patch codecov]
vendor/github.com/radondb/shift/shift   coverage: 76.1% of statements
hustjieke added a commit to hustjieke/radon that referenced this issue Jan 10, 2020
[summary]
1. db or table name may include "-", like "a-b_db" or "a-b_tbl"
2. column name may be a keyword, like "char", "key"...
They should be quoted when send delete/update sql to backend.
[test case]
vendor/github.com/radondb/shift/shift_test
[patch codecov]
vendor/github.com/radondb/shift/shift   coverage: 76.1% of statements
BohuTANG pushed a commit that referenced this issue Jan 17, 2020
[summary]
1. db or table name may include "-", like "a-b_db" or "a-b_tbl"
2. column name may be a keyword, like "char", "key"...
They should be quoted when send delete/update sql to backend.
[test case]
vendor/github.com/radondb/shift/shift_test
[patch codecov]
vendor/github.com/radondb/shift/shift   coverage: 76.1% of statements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants