Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for createViewOrReplace and its support for sqlite3 (#4856)
Co-authored-by: Marek "foxie" Brenčič <marek@brencic.sk> Co-authored-by: Olivier Cavadenti <olivier.cavadenti@gmail.com>
- Loading branch information
1 parent
b42bc46
commit 3f0ec9f
Showing
10 changed files
with
262 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,5 @@ test/coverage/* | |
#VsCode workspace | ||
.vscode | ||
/coverage/ | ||
|
||
test/integration/migrate/migration/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,40 @@ | ||
/* eslint max-len: 0 */ | ||
|
||
const ViewCompiler = require('../../../schema/viewcompiler.js'); | ||
const { | ||
columnize: columnize_, | ||
} = require('../../../formatter/wrappingFormatter'); | ||
|
||
class ViewCompiler_PG extends ViewCompiler { | ||
class ViewCompiler_SQLite3 extends ViewCompiler { | ||
constructor(client, viewCompiler) { | ||
super(client, viewCompiler); | ||
} | ||
createOrReplace() { | ||
const columns = this.columns; | ||
const selectQuery = this.selectQuery.toString(); | ||
const viewName = this.viewName(); | ||
|
||
const columnList = columns | ||
? ' (' + | ||
columnize_( | ||
columns, | ||
this.viewBuilder, | ||
this.client, | ||
this.bindingsHolder | ||
) + | ||
')' | ||
: ''; | ||
|
||
const dropSql = `drop view if exists ${viewName}`; | ||
const createSql = `create view ${viewName}${columnList} as ${selectQuery}`; | ||
|
||
this.pushQuery({ | ||
sql: dropSql, | ||
}); | ||
this.pushQuery({ | ||
sql: createSql, | ||
}); | ||
} | ||
} | ||
|
||
module.exports = ViewCompiler_PG; | ||
module.exports = ViewCompiler_SQLite3; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters