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

fail on errors #14

Open
hampsterx opened this issue Dec 22, 2022 · 0 comments
Open

fail on errors #14

hampsterx opened this issue Dec 22, 2022 · 0 comments

Comments

@hampsterx
Copy link

hampsterx commented Dec 22, 2022

hi @nickschuch

`CREATE TABLE `user` (
  `email` varchar(255) NOT NULL,
  `name` varchar(60) NOT NULL,
  UNIQUE KEY `email` (`email`)
);


insert into user (email, name) values ("a","a");
insert into user (email, name) values ("b","b");
insert into user (email, name) values ("c","c");
---
rewrite:
  user:
    email: "bah"
    name: '"foo"'
./bin/mtk-dump -h localhost -u root -padmin --config="mtk-local.yml" temp1
SET NAMES utf8;
SET FOREIGN_KEY_CHECKS = 0;
Getting table list...
Dumping structure for table user

--
-- Structure for table `user`
--

DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
  `email` varchar(255) NOT NULL,
  `name` varchar(60) NOT NULL,
  UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Data for table `user` -- 3 rows
--

LOCK TABLES `user` WRITE;
Dumping data for table user

UNLOCK TABLES;
SET FOREIGN_KEY_CHECKS = 1;

The rewrite rule is discarded because it create invalid SQL (ie unique key constraint).

Ideal would be to exit(1) with errors because I dont want to try and sanitize if its not going to fully sanitize.

Currently we use this rule for example

rewrite:
  user:
    # append ".local" to email domain
    email: concat(email, ".local")
    doemail: 0

It should be safe because the email is just concat but I am quite sure over the past year or so there have been numerous times where the rewrites weren't done and we had to manually run an update command afterwards. This is risky cause it also didn't update the other fields also (eg doemail=0).

Interestingly in my test above when it fails it seems to exclude the table data but again I dont think this is the behaviour I have seen when it fails above.

Thanks, this tool is fantastic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant