Closed ruslan-ushakov closed 9 years ago
Hi
Yes, I was about to place the same bug here! What a coincidence!
Example:
/var/www/public/application/libraries/db-sync.phar user:pass@localhost:dbname user:pass@localhost:dbname_dest --tables='tag_to_tagfield' --execute
Executing
Table: tag_to_tagfield => tag_to_tagfield
Mismatch found in table: tag_to_tagfield => tag_to_tagfield Row: 1
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 'left, top, label, original_tag_id) VALUES ('1','1','67','41','askjf asdf sadf','' at line 2
QUERY: INSERT INTO tag_to_tagfield
(tag_id, tagfield_id, left, top, label, original_tag_id) VALUES (?,?,?,?,?,?),(?,?,?,?,?,?),(?,?,?,?,?,?),(?,?,?,?,?,?),(?,?,?,?,?,?),(?,?,?,?,?,?),(?,?,?,?,?,?),(?,?,?,?,?,?),(?,?,?,?,?,?),(?,?,?,?,?,?),(?,?,?,?,?,?),(?,?,?,?,?,?),(?,?,?,?,?,?),(?,?,?,?,?,?)
ON DUPLICATE KEY UPDATE tag_id = VALUES(tag_id), tagfield_id = VALUES(tagfield_id), left = VALUES(left), top = VALUES(top), label = VALUES(label), original_tag_id = VALUES(original_tag_id)
BIND: array (
0 => '1',
1 => '1',
2 => '67',
3 => '41',
4 => 'askjf asdf sadf',
5 => '9',
6 => '2',
7 => '1',
8 => '26',
9 => '65',
10 => 'asdfhelkrkjv',
11 => '10',
12 => '3',
13 => '1',
14 => '32',
15 => '57',
16 => 'asdfastaergsfdg',
17 => '4',
18 => '4',
19 => '1',
20 => '28',
21 => '3',
22 => 'asdfasfcx',
23 => '3',
24 => '5',
25 => '1',
26 => '15',
27 => '28',
28 => 'asdf',
29 => '6',
30 => '6',
31 => '1',
32 => '71',
33 => '35',
34 => 'jgk',
35 => '1',
36 => '7',
37 => '1',
38 => '26',
39 => '49',
40 => 'lkjlkj',
41 => '2',
42 => '8',
43 => '1',
44 => '68',
45 => '25',
46 => 'asdfesfgjzv',
47 => '8',
48 => '9',
49 => '1',
50 => '20',
51 => '73',
52 => 'sadgdhdfghrtgbrs',
53 => '7',
54 => '10',
55 => '2',
56 => '36',
57 => '18',
58 => 'asdf',
59 => '6',
60 => '11',
61 => '2',
62 => '52',
63 => '40',
64 => 'asdfesfgjzv',
65 => '8',
66 => '12',
67 => '3',
68 => '35',
69 => '57',
70 => 'asdfhelkrkjv',
71 => '10',
72 => '13',
73 => '3',
74 => '47',
75 => '21',
76 => 'asdfesfgjzv',
77 => '8',
78 => '14',
79 => '3',
80 => '8',
81 => '22',
82 => 'thefuck',
83 => '3',
)
I have a column name called left, which gives the error. Also, if I put backticks around the query (as a test) it gives errors with the ?'s -> they might need to be backticked as well?
After I backticked those as well, it hangs on the
BIND array(
part...
If there is anything I can do to help let me know.
Should be fixed in the latest commit on master:
https://github.com/mrjgreen/db-sync/commit/7664bc9917417e56ea19fa52d061e1233a705ef9
Give it a try and let me know if you have any problems.
Thanks guys!
Hi
I was using the .phar, and that one isn't updated yet. (Haven't build a .phar ever before so gonna try in a minute). There is another thing you might want to change; backticking the table names as well:
Line 231 in Connection.php
return $this->query($type . ' INTO ' . $table . ' (' . implode(',', $cols) . ') VALUES ' . $qs, $bind);
to
return $this->query($type . ' INTO `' . $table . '` (' . implode(',', $cols) . ') VALUES ' . $qs, $bind);
Because if the table name is a reserved word it would still throw errors I guess.
Apologies - thats done now. There is a script in build/createphar.php to create the archive.
I'll wait to update the tablenames - you are correct though. My intention is to give this a full overhaul and utilise something like doctrine or similar to manage the database work.
Hi guys
Just thought I'd let you know about a new version of db-sync I'm working on
https://github.com/mrjgreen/db-sync/tree/v3
Its still in development, but despite the warnings, it does work with and has some major advantages of the old version.
Currently missing features:
Feel free to check out the new version and see what you think - let me know what features you think you need. Please do not use it in production.
I will try to use the new version. We need to use different table names. For example:
db-sync.phar user:213@127.0.0.1:stat user:456@127.0.0.1:stat_new --tables="from_table => to_table, b_STAT => stat"
Okay you can now do that with the option --target.table
EG:
db-sync -u root -p mypass 127.0.0.1 111.222.3.44 web.customers --target.table web_backup.customers_2
Hello! There is a problem with the column names that contain reserved words. I get an error when I sync table contains a column called "return"