From 0c8bb613dbdec50c06f80ee0e4d9850602d8a71b Mon Sep 17 00:00:00 2001 From: Ibrahim BinAlshikh Date: Mon, 13 May 2024 11:50:43 +0300 Subject: [PATCH 1/4] fix: Fix to Running SQL Query from File --- .../cli/commands/RunSQLQueryCommand.php | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/webfiori/framework/cli/commands/RunSQLQueryCommand.php b/webfiori/framework/cli/commands/RunSQLQueryCommand.php index d1e2a669..09f6d6c8 100644 --- a/webfiori/framework/cli/commands/RunSQLQueryCommand.php +++ b/webfiori/framework/cli/commands/RunSQLQueryCommand.php @@ -122,7 +122,11 @@ private function connectionBased($dbConnections) : int { if ($file !== null) { $fileObj = new File(ROOT_PATH.DS.$file); - + + if (!$fileObj->isExist()) { + $fileObj = new File($file); + } + if ($fileObj->isExist()) { $fileObj->read(); $mime = $fileObj->getMIME(); @@ -135,7 +139,7 @@ private function connectionBased($dbConnections) : int { return -1; } } else { - $this->error('No such file: '.$file); + $this->error('No such file: '.$fileObj->getAbsolutePath()); return -1; } @@ -201,24 +205,29 @@ private function queryFromFile($schema) { while (!File::isFileExist($filePath)) { $filePath = $this->getInput('File path:'); - + $modified = ROOT_PATH.DS.$filePath; + + if (File::isFileExist($modified)) { + $filePath = $modified; + } + if (File::isFileExist($filePath)) { $file = new File($filePath); $file->read(); - if ($file->getMIME() == 'application/sql') { + if ($mime == 'application/sql' || $mime == 'application/x-sql') { break; } else { $this->error('Provided file is not SQL file!'); } } else { - $this->error('No such file!'); + $this->error('No such file: '.$filePath); } } return $this->runFileQuery($schema, $file); } - + private function queryOnSchema(DB $schema) { if ($this->isArgProvided('--create')) { $schema->createTables(); From b046fdf98768a63d882d102c1d20cc01b4f8a288 Mon Sep 17 00:00:00 2001 From: Ibrahim BinAlshikh Date: Mon, 13 May 2024 12:26:41 +0300 Subject: [PATCH 2/4] fix: Added Check for Empty File Path --- webfiori/framework/cli/commands/RunSQLQueryCommand.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/webfiori/framework/cli/commands/RunSQLQueryCommand.php b/webfiori/framework/cli/commands/RunSQLQueryCommand.php index 09f6d6c8..9cd87bae 100644 --- a/webfiori/framework/cli/commands/RunSQLQueryCommand.php +++ b/webfiori/framework/cli/commands/RunSQLQueryCommand.php @@ -139,7 +139,12 @@ private function connectionBased($dbConnections) : int { return -1; } } else { - $this->error('No such file: '.$fileObj->getAbsolutePath()); + $path = $fileObj->getAbsolutePath(); + + if (strlen($path) == 0) { + $path = $file; + } + $this->error('No such file: '.$path); return -1; } From 8b013ae6d622823f4abd935cbda45d0a718030a1 Mon Sep 17 00:00:00 2001 From: Ibrahim BinAlshikh Date: Mon, 13 May 2024 12:27:57 +0300 Subject: [PATCH 3/4] chore: Updated Framework Version --- webfiori/framework/App.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webfiori/framework/App.php b/webfiori/framework/App.php index 191f6ba8..49771f9e 100644 --- a/webfiori/framework/App.php +++ b/webfiori/framework/App.php @@ -542,7 +542,7 @@ private function initFrameworkVersionInfo() { * * @since 2.1 */ - define('WF_VERSION', '3.0.0-Beta.6'); + define('WF_VERSION', '3.0.0-Beta.7'); /** * A constant that tells the type of framework version. * @@ -558,7 +558,7 @@ private function initFrameworkVersionInfo() { * * @since 2.1 */ - define('WF_RELEASE_DATE', '2024-05-12'); + define('WF_RELEASE_DATE', '2024-05-13'); } /** From 905c3c7b8232a8f1ee6171fa309c2489b1bdd141 Mon Sep 17 00:00:00 2001 From: Ibrahim BinAlshikh Date: Mon, 13 May 2024 12:31:10 +0300 Subject: [PATCH 4/4] fix: Fix to Uninitialized Variable --- webfiori/framework/cli/commands/RunSQLQueryCommand.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webfiori/framework/cli/commands/RunSQLQueryCommand.php b/webfiori/framework/cli/commands/RunSQLQueryCommand.php index 9cd87bae..34810332 100644 --- a/webfiori/framework/cli/commands/RunSQLQueryCommand.php +++ b/webfiori/framework/cli/commands/RunSQLQueryCommand.php @@ -219,7 +219,8 @@ private function queryFromFile($schema) { if (File::isFileExist($filePath)) { $file = new File($filePath); $file->read(); - + $mime = $file->getMIME(); + if ($mime == 'application/sql' || $mime == 'application/x-sql') { break; } else {