[GH-ISSUE #120] PHP Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; #86

Open
opened 2026-02-25 21:33:13 +03:00 by kerem · 1 comment
Owner

Originally created by @Aquive on GitHub (Apr 12, 2021).
Original GitHub issue: https://github.com/DBDiff/DBDiff/issues/120

Hi, I get below error on --type=data or all. --type=schema works as expected. How can I solve it?

pp@6bb82a2c0270:~/DBDiff$ ./dbdiff server1.small:server2.stage-small --type=data
ℹ Now calculating data diff for table admin_rule
✖ Unexpected error: 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 '-small.admin_rule as a
LEFT JOIN kp-stage-small.admin_rule as b ON ' at line 1 (SQL: SELECT CONVERT(a.rule_idUSING utf8) asrule_id,CONVERT(a.role_idUSING utf8) asrole_id,CONVERT(a.resource_idUSING utf8) asresource_id,CONVERT(a.privilegesUSING utf8) asprivileges,CONVERT(a.assert_idUSING utf8) asassert_id,CONVERT(a.role_typeUSING utf8) asrole_type,CONVERT(a.permissionUSING utf8) aspermissionFROM kp-small.admin_rule as a LEFT JOIN kp-stage-small.admin_rule as b ONa.rule_id=b.rule_idWHEREb.rule_idIS NULL ) PHP Fatal error: Uncaught PDOException: 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 '-small.admin_rule as a LEFT JOIN kp-stage-small.admin_rule as b ON' at line 1 in /data/web/DBDiff/vendor/illuminate/database/Illuminate/Database/Connection.php:299
Stack trace:
#0 /data/web/DBDiff/vendor/illuminate/database/Illuminate/Database/Connection.php(299): PDO->prepare('SELECT CONVERT(...')
#1 /data/web/DBDiff/vendor/illuminate/database/Illuminate/Database/Connection.php(617): Illuminate\Database\Connection->Illuminate\Database{closure}(Object(Illuminate\Database\MySqlConnection), 'SELECT CONVERT(...', Array)
#2 /data/web/DBDiff/vendor/illuminate/database/Illuminate/Database/Connection.php(581): Illuminate\Database\Connection->runQueryCallback('SELECT CONVERT(...', Array, Object(Closure))
#3 /data/web/DBDiff/vendor/illuminate/database/Illuminate/Database/Connection.php(304): I in /data/web/DBDiff/vendor/illuminate/database/Illuminate/Database/Connection.php on line 625

Originally created by @Aquive on GitHub (Apr 12, 2021). Original GitHub issue: https://github.com/DBDiff/DBDiff/issues/120 Hi, I get below error on --type=data or all. --type=schema works as expected. How can I solve it? pp@6bb82a2c0270:~/DBDiff$ ./dbdiff server1.small:server2.stage-small --type=data ℹ Now calculating data diff for table `admin_rule` ✖ Unexpected error: 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 '-small.admin_rule as a LEFT JOIN kp-stage-small.admin_rule as b ON `' at line 1 (SQL: SELECT CONVERT(`a`.`rule_id` USING utf8) as `rule_id`,CONVERT(`a`.`role_id` USING utf8) as `role_id`,CONVERT(`a`.`resource_id` USING utf8) as `resource_id`,CONVERT(`a`.`privileges` USING utf8) as `privileges`,CONVERT(`a`.`assert_id` USING utf8) as `assert_id`,CONVERT(`a`.`role_type` USING utf8) as `role_type`,CONVERT(`a`.`permission` USING utf8) as `permission` FROM kp-small.admin_rule as a LEFT JOIN kp-stage-small.admin_rule as b ON `a`.`rule_id` = `b`.`rule_id` WHERE `b`.`rule_id` IS NULL ) PHP Fatal error: Uncaught PDOException: 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 '-small.admin_rule as a LEFT JOIN kp-stage-small.admin_rule as b ON `' at line 1 in /data/web/DBDiff/vendor/illuminate/database/Illuminate/Database/Connection.php:299 Stack trace: #0 /data/web/DBDiff/vendor/illuminate/database/Illuminate/Database/Connection.php(299): PDO->prepare('SELECT CONVERT(...') #1 /data/web/DBDiff/vendor/illuminate/database/Illuminate/Database/Connection.php(617): Illuminate\Database\Connection->Illuminate\Database\{closure}(Object(Illuminate\Database\MySqlConnection), 'SELECT CONVERT(...', Array) #2 /data/web/DBDiff/vendor/illuminate/database/Illuminate/Database/Connection.php(581): Illuminate\Database\Connection->runQueryCallback('SELECT CONVERT(...', Array, Object(Closure)) #3 /data/web/DBDiff/vendor/illuminate/database/Illuminate/Database/Connection.php(304): I in /data/web/DBDiff/vendor/illuminate/database/Illuminate/Database/Connection.php on line 625
Author
Owner

@rzroth commented on GitHub (Jun 10, 2022):

There is a flaw in DBDiff that doesn't account for tables with '-' in the name, because it tries to make a illegally named JOIN
Still working on my cases, I suspect you will need to rename the database
In my case, it is only tables with '-' in the name
I'm looking into the code to see how that might addresssed

<!-- gh-comment-id:1152714641 --> @rzroth commented on GitHub (Jun 10, 2022): There is a flaw in DBDiff that doesn't account for tables with '-' in the name, because it tries to make a illegally named JOIN Still working on my cases, I suspect you will need to rename the database In my case, it is only tables with '-' in the name I'm looking into the code to see how that might addresssed
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/DBDiff#86
No description provided.