-
Notifications
You must be signed in to change notification settings - Fork 1
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
6) Update ci and cs #71
Conversation
driver/downloadDriver.php
Outdated
@@ -7,23 +10,29 @@ | |||
|
|||
require_once $basedir . '/vendor/autoload.php'; | |||
|
|||
$client = new \Aws\S3\S3Client([ | |||
$client = new \Aws\S3\S3Client( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is broken :) Either should stay on the same line or contents of array should be indented
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a lot of useless diffs just putting arrays on newlines. I think those should be removed. They are not part of CS and add no value whatsoever.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm quite sure that those were created by phpbcf
, but I can revert it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh! That would be a bug in phpcbf (or the sniff) then!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the sniff is fine with it, so I guess it must have been me:). anyhow, it's reverted.
run.php
Outdated
true | ||
); | ||
} else { | ||
throw new UserException('Invalid configuration file type'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invalid? More like missing, don't you think?
}); | ||
$objectColumns = array_filter( | ||
$columnInfo, | ||
function ($column) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
closures can be typehinted too ;)
@@ -265,12 +294,12 @@ private function generateCopyCommand($stageTmpPath, $query) | |||
} | |||
|
|||
/** | |||
* @param $copyCommand | |||
* @param int $maxTries | |||
* @param $copyCommand |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does not seem right...
', ', | ||
array_map( | ||
function ($tableName) { | ||
return "'" . $tableName . "'"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not quoteIdentifier?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not an identifier in this case, but a value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, but anyway... isn't there a proper quoting function? This is not quoting, this is "wrapping in quotes".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there is a "proper" one, but there is a private method in this class that should be used here, https://github.com/keboola/db-extractor-snowflake/blob/master/src/Keboola/DbExtractor/Extractor/Snowflake.php#L538
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is nothing better...
The addslashes() is sometimes incorrectly used to try to prevent SQL Injection. Instead, database-specific escaping functions and/or prepared statements should be used.
-- http://php.net/manual/en/function.addslashes.php
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, that's a completely valid point, I'll change it to statement. thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll change it when I fix this: #72
* @return \SplFileInfo | ||
*/ | ||
private function crateSnowSqlConfig($dbParams) | ||
private function crateSnowSqlConfig(array $dbParams): \SplFileInfo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create or is it a crate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still not fixed
tests/AbstractSnowflakeTest.php
Outdated
@@ -186,10 +191,10 @@ private function generateCreateCommand($tableName, CsvFile $csv, $fileInfo) | |||
* Create table from csv file with text columns | |||
* | |||
* @param CsvFile $file | |||
* @param string $tableName - optional name override (default uses filename) | |||
* @param string $schemaName - optional schema in which to create the table | |||
* @param string $tableName - optional name override (default uses filename) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something fishy :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also missing |null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still not resolved
tests/AbstractSnowflakeTest.php
Outdated
@@ -241,10 +253,10 @@ protected function createTextTable(CsvFile $file, $tableName = null, $schemaName | |||
/** | |||
* Count records in CSV (with headers) | |||
* | |||
* @param CsvFile $file | |||
* @param CsvFile $file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems you need to disable attribute alignment in you phpstorm code style settings... let me know if you couldn't find it.
composer.json
Outdated
"keboola/storage-api-client": "^4.14", | ||
"keboola/php-csv-db-import": "~2.3.0" | ||
"phpstan/phpstan": "^0.8" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0.10.3 is latest afaik
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as you are adding a new dependency you should set it to latest available IMHO... even though it will install correctly latest version even with this version constraint
|
||
return $outputTable; | ||
return [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is logic change hidden inside "ci&cs" PR. Please don't do this.
I understand that it's caused be upstream change in db-ex-common, but this could have been separated in it's own PR, not in +1000/-600 beast :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, this should be in #69, I'll cherry-pick it if possible.
driver/downloadDriver.php
Outdated
@@ -7,23 +10,29 @@ | |||
|
|||
require_once $basedir . '/vendor/autoload.php'; | |||
|
|||
$client = new \Aws\S3\S3Client([ | |||
$client = new \Aws\S3\S3Client( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a lot of useless diffs just putting arrays on newlines. I think those should be removed. They are not part of CS and add no value whatsoever.
@@ -226,26 +241,33 @@ private function exportAndDownload(array $table): int | |||
|
|||
file_put_contents( | |||
$outputDataDir . '.manifest', | |||
Yaml::dump($this->createTableManifest($table, array_map( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
functional change inside CI&CS PR :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should have been part of the PR that introduced a change that requires this or it's own separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it should be part of #67
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what's the plan for this? I see in git graph that you did not cherry pick it. There is a simple way to do this with interactive checkout. I can show you if you want. I wanted to try it in CLI for some time anyway (although I've been using it for a long time in GitExtensions)
', ', | ||
array_map( | ||
function ($tableName) { | ||
return "'" . $tableName . "'"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, but anyway... isn't there a proper quoting function? This is not quoting, this is "wrapping in quotes".
* @return \SplFileInfo | ||
*/ | ||
private function crateSnowSqlConfig($dbParams) | ||
private function crateSnowSqlConfig(array $dbParams): \SplFileInfo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still not fixed
|
||
declare(strict_types=1); | ||
|
||
namespace Keboola\DbExtractor\Tests; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests do not need to be moved to subdirectory. It would be enough to set:
"autoload-dev": {
"psr-4": {
"Keboola\\DbExtractor\\Tests\\": "tests/"
}
},
Also, ideally the namespace should also be different (e.g. Keboola\DbExtractor\SnowflakeExtractor
), but I think that it's hardcoded in the common extractor... so that's fine. The note about test paths still stands though.
$fileSystem->remove(__DIR__ . '/data/runAction/out'); | ||
$fileSystem->remove(__DIR__ . '/data/connectionAction/config.yml'); | ||
$fileSystem->remove(__DIR__ . '/tests/data/connectionAction/out'); | ||
$fileSystem->remove($this->dataDir . '/out'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be part of #67
tests/AbstractSnowflakeTest.php
Outdated
@@ -186,10 +191,10 @@ private function generateCreateCommand($tableName, CsvFile $csv, $fileInfo) | |||
* Create table from csv file with text columns | |||
* | |||
* @param CsvFile $file | |||
* @param string $tableName - optional name override (default uses filename) | |||
* @param string $schemaName - optional schema in which to create the table | |||
* @param string $tableName - optional name override (default uses filename) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still not resolved
Thanks @tomasfejfar ! I'll get right on it. |
ok @tomasfejfar , apart from the cherry-picking this should be good now I think? |
45e8526
to
8c4b2c0
Compare
8c4b2c0
to
56b21b7
Compare
@@ -480,6 +478,13 @@ function ($tableName): string { | |||
return array_values($tableDefs); | |||
} | |||
|
|||
private function shouldTableBeSkipped(array $table): bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed the remainder of useless diffs. Only thing missing is cherrypicking the changes into appropriate branches and then rebase that will squash all my fixup commits.
@@ -226,26 +241,33 @@ private function exportAndDownload(array $table): int | |||
|
|||
file_put_contents( | |||
$outputDataDir . '.manifest', | |||
Yaml::dump($this->createTableManifest($table, array_map( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what's the plan for this? I see in git graph that you did not cherry pick it. There is a simple way to do this with interactive checkout. I can show you if you want. I wanted to try it in CLI for some time anyway (although I've been using it for a long time in GitExtensions)
@@ -393,7 +411,9 @@ public function getTables(?array $tables = null): array | |||
$tableNameArray = []; | |||
$tableDefs = []; | |||
foreach ($arr as $table) { | |||
if (($this->schema && $table['schema_name'] !== $this->schema) || $table['schema_name'] === 'INFORMATION_SCHEMA') { | |||
if (($this->schema && $table['schema_name'] !== $this->schema) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sucks :/ I fixed it with a method.
tests/SnowflakeEntrypointTest.php
Outdated
$process->setTimeout(300); | ||
$process->run(); | ||
|
||
$this->assertEquals(0, $process->getExitCode(), sprintf('error output: ', $process->getErrorOutput())); | ||
var_export($process->getOutput()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should there really be var_export here? Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why var_export and not var_dump or echo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, sorry, I should remove that. It was a part of my debugging my local issue.
"obj" OBJECT, | ||
"arr" ARRAY | ||
)'); | ||
$this->connection->query( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one makes sense to be reformated.
@@ -215,12 +223,11 @@ protected function createTextTable(CsvFile $file, $tableName = null, $schemaName | |||
$q = '"'; | |||
return ($q . str_replace("$q", "$q$q", $column) . $q) . ' VARCHAR(200) NOT NULL'; | |||
}, $file->getHeader()) | |||
), | |||
$tableName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notice how the fixed diff revealed a change in the code!
No description provided.