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

Fix escape #87

Merged
merged 2 commits into from
Aug 30, 2018
Merged

Fix escape #87

merged 2 commits into from
Aug 30, 2018

Conversation

simPod
Copy link
Contributor

@simPod simPod commented Aug 22, 2018

Follows #86

@2ur1st
Copy link
Contributor

2ur1st commented Aug 22, 2018

I think use preg_replace() it`s very bad, its very slow function for simple replacement

@simPod
Copy link
Contributor Author

simPod commented Aug 22, 2018

As I read the code a bit, replacing the quotes is not the proper way as I think it might accidentally replace quotes you wish to have in your string. preg_replace does the work here, the logic doesn't change. I only leveraged what was already there.

And also, talking the speed this class deserves refactoring.

@simPod simPod force-pushed the fix-escape branch 3 times, most recently from e3b4272 to b0178fe Compare August 22, 2018 14:51
@simPod
Copy link
Contributor Author

simPod commented Aug 22, 2018

@isublimity CS won't pass for missing return type hints that are unsupported in 7.0 and therefore we cannot add them.

@@ -2,6 +2,10 @@
namespace ClickHouseDB\Quote;

use ClickHouseDB\Exception\QueryException;
use function array_map;
use function is_string;
use function preg_replace;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think this is clear code ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course. Either you can use \array_map in your code or import it. Importing it is cleaner so your actual code is not polluted with \s

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@isublimity what do you think about that ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simPod you are not right
2018-08-22 23 34 21

Copy link
Contributor Author

@simPod simPod Aug 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm. It is part of the code style to reference it via use statement instead of prepending \. What is the issue you see there?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simPod you said "you can use \array_map in your code or import it.", I show you errors about use \ in function name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant that it both have the same effect but only one is compliant with doctrine cs and that's by importing it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simPod - please write me if need merge, i'm lost discussion(
sorry(

Copy link
Contributor Author

@simPod simPod Aug 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@isublimity I think this PR is ready. I have leveraged the code used for encoding strings https://github.com/smi2/phpClickHouse/pull/87/files#diff-c29b9c40206dcbba3b525b3b3d284effL82 and reapplied it for arrays as well.

The test written by @2ur1st doesn't pass before this change so I suppose it's fixed now as it passes.

@isublimity isublimity merged commit 5de32b0 into smi2:master Aug 30, 2018
@simPod simPod deleted the fix-escape branch August 30, 2018 08:17
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

Successfully merging this pull request may close these issues.

3 participants