File tree 2 files changed +34
-2
lines changed
2 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -132,12 +132,18 @@ var PgDriver = Base.extend({
132
132
'Ignore database option, not available with postgres. Use schema instead!'
133
133
) ;
134
134
this . runSql (
135
- util . format ( 'SET search_path TO `%s`' , options . database ) ,
135
+ util . format ( 'SET search_path TO %s' , options . database ) ,
136
+ callback
137
+ ) ;
138
+ } else if ( typeof options . schema === 'string' ) {
139
+ this . schema = options . schema
140
+ this . runSql (
141
+ util . format ( 'SET search_path TO %s' , options . schema ) ,
136
142
callback
137
143
) ;
138
144
}
139
145
} else if ( typeof options === 'string' ) {
140
- this . runSql ( util . format ( 'SET search_path TO `%s` ' , options ) , callback ) ;
146
+ this . runSql ( util . format ( 'SET search_path TO %s ' , options ) , callback ) ;
141
147
} else callback ( null ) ;
142
148
} ,
143
149
Original file line number Diff line number Diff line change @@ -1157,6 +1157,32 @@ vows
1157
1157
}
1158
1158
}
1159
1159
} )
1160
+ . addBatch ( {
1161
+ switchDatabase : {
1162
+ topic : function ( ) {
1163
+ db . switchDatabase ( { schema : 'test_schema2' } , this . callback ) ;
1164
+ } ,
1165
+
1166
+ 'has search path' : {
1167
+ topic : function ( ) {
1168
+ db . runSql ( 'SHOW search_path' , this . callback ) ;
1169
+ } ,
1170
+
1171
+ 'containing the new schema' : function ( err , result ) {
1172
+ assert . isNull ( err ) ;
1173
+ var rows = result . rows ;
1174
+ assert . isNotNull ( rows ) ;
1175
+ assert . strictEqual ( rows . length , 1 ) ;
1176
+ var row = rows [ 0 ] ;
1177
+ assert . strictEqual ( row . search_path , 'test_schema2' ) ;
1178
+ }
1179
+ } ,
1180
+
1181
+ teardown : function ( ) {
1182
+ db . switchDatabase ( { schema : config . schema } , this . callback ) ;
1183
+ }
1184
+ }
1185
+ } )
1160
1186
. export ( module ) ;
1161
1187
1162
1188
function findByName ( columns , name ) {
You can’t perform that action at this time.
0 commit comments