File tree 1 file changed +22
-2
lines changed
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 {
68
68
} else if ( tables . length === 0 ) {
69
69
tableClause = ''
70
70
} 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 ( ',' ) } `
72
82
}
73
83
74
84
let publishOps = [ ]
@@ -138,7 +148,17 @@ CREATE PUBLICATION ${ident(name)} ${tableClause}
138
148
} else if ( old ! . tables === null ) {
139
149
throw new Error ( 'Tables cannot be added to or dropped from FOR ALL TABLES publications' )
140
150
} 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 ( ',' ) } ;`
142
162
} else if ( old ! . tables . length === 0 ) {
143
163
tableSql = ''
144
164
} else {
You can’t perform that action at this time.
0 commit comments