File tree Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -68,7 +68,17 @@ export default class PostgresMetaPublications {
6868 } else if ( tables . length === 0 ) {
6969 tableClause = ''
7070 } else {
71- tableClause = `FOR TABLE ${ tables . join ( ',' ) } `
71+ tableClause = `FOR TABLE ${ tables
72+ . map ( ( t ) => {
73+ if ( ! t . includes ( '.' ) ) {
74+ return ident ( t )
75+ }
76+
77+ const [ schema , ...rest ] = t . split ( '.' )
78+ const table = rest . join ( '.' )
79+ return `${ ident ( schema ) } .${ ident ( table ) } `
80+ } )
81+ . join ( ',' ) } `
7282 }
7383
7484 let publishOps = [ ]
@@ -138,7 +148,17 @@ CREATE PUBLICATION ${ident(name)} ${tableClause}
138148 } else if ( old ! . tables === null ) {
139149 throw new Error ( 'Tables cannot be added to or dropped from FOR ALL TABLES publications' )
140150 } else if ( tables . length > 0 ) {
141- tableSql = `ALTER PUBLICATION ${ ident ( old ! . name ) } SET TABLE ${ tables . join ( ',' ) } ;`
151+ tableSql = `ALTER PUBLICATION ${ ident ( old ! . name ) } SET TABLE ${ tables
152+ . map ( ( t ) => {
153+ if ( ! t . includes ( '.' ) ) {
154+ return ident ( t )
155+ }
156+
157+ const [ schema , ...rest ] = t . split ( '.' )
158+ const table = rest . join ( '.' )
159+ return `${ ident ( schema ) } .${ ident ( table ) } `
160+ } )
161+ . join ( ',' ) } ;`
142162 } else if ( old ! . tables . length === 0 ) {
143163 tableSql = ''
144164 } else {
You can’t perform that action at this time.
0 commit comments