-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
Add refreshMaterializedView command #332
base: master
Are you sure you want to change the base?
Conversation
aaff285
to
08b86eb
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #332 +/- ##
=============================================
- Coverage 100.00% 99.85% -0.15%
- Complexity 241 252 +11
=============================================
Files 16 16
Lines 694 714 +20
=============================================
+ Hits 694 713 +19
- Misses 0 1 +1 ☔ View full report in Codecov by Sentry. |
08b86eb
to
5a3d4e9
Compare
5a3d4e9
to
f07182c
Compare
@@ -20,4 +24,56 @@ public function showDatabases(): array | |||
|
|||
return $this->setSql($sql)->queryColumn(); | |||
} | |||
|
|||
/** | |||
* @see {https://www.postgresql.org/docs/current/sql-refreshmaterializedview.html} |
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.
* @see {https://www.postgresql.org/docs/current/sql-refreshmaterializedview.html} | |
* @see https://www.postgresql.org/docs/current/sql-refreshmaterializedview.html |
$tableSchema = $this->db->getTableSchema($viewName); | ||
|
||
if ($tableSchema) { | ||
$hasUnique = count($this->db->getSchema()->findUniqueIndexes($tableSchema)) > 0; |
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.
$hasUnique = count($this->db->getSchema()->findUniqueIndexes($tableSchema)) > 0; | |
$hasUnique = !empty($this->db->getSchema()->findUniqueIndexes($tableSchema)); |
*/ | ||
public function refreshMaterializedView(string $viewName, ?bool $concurrently = null, ?bool $withData = null): bool | ||
{ | ||
if ($concurrently || ($concurrently === null || $withData === 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.
if ($concurrently || ($concurrently === null || $withData === null)) { | |
if ($concurrently !== false) { |
); | ||
} | ||
|
||
if ($concurrently && !$hasUnique) { |
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 ($concurrently && !$hasUnique) { | |
if ($concurrently === true && !$hasUnique) { |
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.
Good idea.
-
This method should be added in base
yii-db
package and should be consistent with other DBMS. -
The part of generating SQL query shold be in
DDLQueryBuilder
I create this PR and i think they must be merged first |
Add new command to refresh PgSql materialized views. I think it can be added in
CommandInterface