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

6) Update ci and cs #71

Merged
merged 63 commits into from
Nov 12, 2018
Merged

6) Update ci and cs #71

merged 63 commits into from
Nov 12, 2018

Conversation

pivnicek
Copy link
Contributor

No description provided.

@pivnicek pivnicek changed the title Update ci and cs 6) Update ci and cs Sep 27, 2018
@@ -7,23 +10,29 @@

require_once $basedir . '/vendor/autoload.php';

$client = new \Aws\S3\S3Client([
$client = new \Aws\S3\S3Client(
Copy link
Contributor

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

Copy link
Contributor

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.

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'm quite sure that those were created by phpbcf, but I can revert it.

Copy link
Contributor

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!

Copy link
Contributor Author

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');
Copy link
Contributor

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) {
Copy link
Contributor

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 ;)

src/Keboola/DbExtractor/Extractor/Snowflake.php Outdated Show resolved Hide resolved
@@ -265,12 +294,12 @@ private function generateCopyCommand($stageTmpPath, $query)
}

/**
* @param $copyCommand
* @param int $maxTries
* @param $copyCommand
Copy link
Contributor

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 . "'";
Copy link
Contributor

Choose a reason for hiding this comment

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

why not quoteIdentifier?

Copy link
Contributor Author

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

Copy link
Contributor

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".

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 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

Copy link
Contributor

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

Copy link
Contributor Author

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.

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'll change it when I fix this: #72

* @return \SplFileInfo
*/
private function crateSnowSqlConfig($dbParams)
private function crateSnowSqlConfig(array $dbParams): \SplFileInfo
Copy link
Contributor

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

still not fixed

@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

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

something fishy :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Also missing |null

Copy link
Contributor

Choose a reason for hiding this comment

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

still not resolved

@@ -241,10 +253,10 @@ protected function createTextTable(CsvFile $file, $tableName = null, $schemaName
/**
* Count records in CSV (with headers)
*
* @param CsvFile $file
* @param CsvFile $file
Copy link
Contributor

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"
Copy link
Contributor

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

Copy link
Contributor

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

.travis.yml Show resolved Hide resolved
docker-compose.yml Show resolved Hide resolved

return $outputTable;
return [
Copy link
Contributor

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 :)

Copy link
Contributor Author

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.

@@ -7,23 +10,29 @@

require_once $basedir . '/vendor/autoload.php';

$client = new \Aws\S3\S3Client([
$client = new \Aws\S3\S3Client(
Copy link
Contributor

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(
Copy link
Contributor

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 :(

Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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 . "'";
Copy link
Contributor

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
Copy link
Contributor

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;
Copy link
Contributor

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');
Copy link
Contributor

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

@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

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

still not resolved

@pivnicek
Copy link
Contributor Author

pivnicek commented Nov 7, 2018

Thanks @tomasfejfar ! I'll get right on it.

@pivnicek
Copy link
Contributor Author

pivnicek commented Nov 7, 2018

ok @tomasfejfar , apart from the cherry-picking this should be good now I think?

@@ -480,6 +478,13 @@ function ($tableName): string {
return array_values($tableDefs);
}

private function shouldTableBeSkipped(array $table): bool
Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@tomasfejfar tomasfejfar left a 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.

src/Keboola/DbExtractor/Extractor/Snowflake.php Outdated Show resolved Hide resolved
@@ -226,26 +241,33 @@ private function exportAndDownload(array $table): int

file_put_contents(
$outputDataDir . '.manifest',
Yaml::dump($this->createTableManifest($table, array_map(
Copy link
Contributor

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)
Copy link
Contributor

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.

$process->setTimeout(300);
$process->run();

$this->assertEquals(0, $process->getExitCode(), sprintf('error output: ', $process->getErrorOutput()));
var_export($process->getOutput());
Copy link
Contributor

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?

Copy link
Contributor

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?

Copy link
Contributor Author

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(
Copy link
Contributor

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
Copy link
Contributor

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!

@pivnicek pivnicek mentioned this pull request Nov 8, 2018
@pivnicek pivnicek merged commit 4013ee4 into master Nov 12, 2018
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