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

Make view columns optional in create view like #4827 #4829

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 7 additions & 5 deletions lib/schema/viewcompiler.js
Expand Up @@ -54,14 +54,16 @@ class ViewCompiler {
(materialized ? 'materialized ' : '') +
'view ' +
(replace ? 'or replace ' : '');
const formatColumns = [];
for (const c of columns) {
formatColumns.push(
const formatColumnsArr = [];
OlivierCavadenti marked this conversation as resolved.
Show resolved Hide resolved
for (const c of columns || []) {
formatColumnsArr.push(
columnize_(c, this.viewBuilder, this.client, this.bindingsHolder)
);
}
let sql =
createStatement + this.viewName() + ' (' + formatColumns.join(', ') + ')';
const formatColumns = formatColumnsArr.length
? ' (' + formatColumnsArr.join(', ') + ')'
: '';
let sql = createStatement + this.viewName() + formatColumns;
sql += ' as ';
sql += selectQuery.toString();
switch (this.single.checkOption) {
Expand Down