-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Fix for broken regex at SQLBind::parseSQL #6
Conversation
parseSQL have ``$sqlAlter = preg_replace("~'.*?'~", "", $sql);`` which destroys $sql query.
Hello, thank you for your PR. I created some unit tests to validate the scenario you described in the So, I digged into the RegEx and I could fix it in the PR #7 in the line 43:
If you just run I'll merge your PR to have you as code contributor, however, I can't maintain your changes in the code because the And again, I really appreciate the heads up and your time contributing to the project. Thank you 👍 |
@byjg Just wanted to say, it still dont work. Again needed to fix it by my changes. |
I truncated the code, cause its too long, but there is a sample, where it fails: |
I am having difficulty creating a test for this particular scenario. The code you send to me is written from right to left, and when I try to paste it into the Workbench, I am getting syntax errors. Do you mind sending me a file with a reduced version of this code and is working in the MySQL Workbench? |
https://regex101.com/r/lHf0Ps/1 |
I believe I won't be able to fix it. So instead, I am accepting your solution with some modifications. I started a new branch here. Adding this parameter, I can control when I do not want to use the parseSql. You can do something like this: $uri = Uri::getInstanceFromUri("mysql://root:password@localhost")
->withQueryKeyValue(DbPdoDriver::DONT_BIND_PARAM , ""); Some tests are failing, but MySQL is working. To use this code, you can change your composer file with:
OR, you can force temporarily in your composer.json the version Please, please let me know if it worked for you. |
PR #12 Fix this Issue.
It will be available on release |
In project byjq/migrate I just want to migrate plain queries extracted from MySQL general log.
Where data contains ' symbols. And it dont realy match with "
'.*?'" regex from SQLBInd::parseSQL function.And it destroys sql's.
There is example sql
INSERT INTO
wp_posts(
post_author,
post_date,
post_date_gmt,
post_content,
post_excerpt,
comment_status,
post_title,
post_name,
post_modified,
post_modified_gmt,
guid,
post_type,
to_ping,
pinged,
post_content_filtered) VALUES (1, '2020-12-31 01:41:02', '2020-12-31 01:41:02', '<!-- wp:paragraph -->\n<p>This is an example page. It\'s different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:</p>\n<!-- /wp:paragraph -->\n\n<!-- wp:quote -->\n<blockquote class=\"wp-block-quote\"><p>Hi there! I\'m a bike messenger by day, aspiring actor by night, and this is my website. I live in Los Angeles, have a great dog named Jack, and I like piña coladas. (And gettin\' caught in the rain.)</p></blockquote>\n<!-- /wp:quote -->\n\n<!-- wp:paragraph -->\n<p>...or something like this:</p>\n<!-- /wp:paragraph -->\n\n<!-- wp:quote -->\n<blockquote class=\"wp-block-quote\"><p>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</p></blockquote>\n<!-- /wp:quote -->\n\n<!-- wp:paragraph -->\n<p>As a new WordPress user, you should go to <a href=\"http://home.home.lcl/wordpress/wp-admin/\">your dashboard</a> to delete this page and create new pages for your content. Have fun!</p>\n<!-- /wp:paragraph -->', '', 'closed', 'Sample Page', 'sample-page', '2020-12-31 01:41:02', '2020-12-31 01:41:02', 'http://xxx.lcl/wordpress/?page_id=2', 'page', '', '', '');