@@ -11,7 +11,7 @@ const removeViewNameSuffix = name => name.slice(0, -VIEW_SUFFIX.length);
1111const setViewSuffix = name => `${ name } ${ VIEW_SUFFIX } ` ;
1212
1313const generateCreateViewScript = ( viewName , viewData , viewDefinitionFallback = { } ) => {
14- const selectStatement = _ . trim ( viewData . view_definition || viewDefinitionFallback . definition || '' ) ;
14+ const selectStatement = _ . trim ( viewData ? .view_definition || viewDefinitionFallback . definition || '' ) ;
1515
1616 if ( ! selectStatement ) {
1717 return '' ;
@@ -20,13 +20,13 @@ const generateCreateViewScript = (viewName, viewData, viewDefinitionFallback = {
2020 return `CREATE VIEW ${ wrapInQuotes ( viewName ) } AS ${ selectStatement } ` ;
2121} ;
2222
23- const prepareViewData = ( viewData , viewOptions , triggers , tableToastOptions ) => {
23+ const prepareViewData = ( { viewData, viewOptions, triggers, tableToastOptions, isRecursive } ) => {
2424 const data = {
25- withCheckOption : viewData . check_option !== 'NONE' || _ . isNil ( viewData . check_option ) ,
26- checkTestingScope : getCheckTestingScope ( viewData . check_option ) ,
25+ withCheckOption : viewData ? .check_option !== 'NONE' || _ . isNil ( viewData ? .check_option ) ,
26+ checkTestingScope : getCheckTestingScope ( viewData ? .check_option ) ,
2727 viewOptions : _ . fromPairs ( _ . map ( viewOptions ?. view_options , splitByEqualitySymbol ) ) ,
2828 temporary : viewOptions ?. persistence === 't' ,
29- recursive : isViewRecursive ( viewData ) ,
29+ recursive : isRecursive ,
3030 description : viewOptions ?. description ,
3131 triggers,
3232 ...prepareMaterializedViewData ( { viewData, viewOptions, tableToastOptions } ) ,
@@ -36,9 +36,9 @@ const prepareViewData = (viewData, viewOptions, triggers, tableToastOptions) =>
3636
3737const prepareMaterializedViewData = ( { viewData, viewOptions, tableToastOptions } ) => {
3838 return {
39- ...( viewData . table_type && { materialized : viewData . table_type === TABLE_TYPE . materializedView } ) ,
40- ...( viewData . view_tablespace_name && { view_tablespace_name : viewData . view_tablespace_name } ) ,
41- ...( viewData . is_populated && { withDataOption : viewData . is_populated } ) ,
39+ ...( viewData ? .table_type && { materialized : viewData . table_type === TABLE_TYPE . materializedView } ) ,
40+ ...( viewData ? .view_tablespace_name && { view_tablespace_name : viewData . view_tablespace_name } ) ,
41+ ...( viewData ? .is_populated && { withDataOption : viewData . is_populated } ) ,
4242 ...( viewOptions ?. view_options && {
4343 storage_parameter : prepareStorageParameters ( viewOptions . view_options , tableToastOptions ) ,
4444 } ) ,
@@ -53,8 +53,8 @@ const getCheckTestingScope = check_option => {
5353 return check_option ;
5454} ;
5555
56- const isViewRecursive = viewData => {
57- return _ . startsWith ( _ . trim ( viewData . view_definition ) , 'WITH RECURSIVE' ) ;
56+ const isViewRecursive = viewDefinition => {
57+ return _ . startsWith ( _ . trim ( viewDefinition ) , 'WITH RECURSIVE' ) ;
5858} ;
5959
6060const splitByEqualitySymbol = item => _ . split ( item , '=' ) ;
@@ -66,4 +66,5 @@ module.exports = {
6666 generateCreateViewScript,
6767 setViewSuffix,
6868 prepareViewData,
69+ isViewRecursive,
6970} ;
0 commit comments