@@ -64,6 +64,15 @@ describe('postgresql connector', function() {
64
64
loc : 'GeoPoint' ,
65
65
created : Date ,
66
66
approved : Boolean ,
67
+ tags : {
68
+ type : [ 'string' ] ,
69
+ } ,
70
+ categories : {
71
+ type : [ 'string' ] ,
72
+ postgresql : {
73
+ dataType : 'varchar[]' ,
74
+ } ,
75
+ } ,
67
76
} ) ;
68
77
created = new Date ( ) ;
69
78
} ) ;
@@ -201,6 +210,50 @@ describe('postgresql connector', function() {
201
210
} ) ;
202
211
} ) ;
203
212
213
+ it ( 'should support creating and updating arrays with default dataType' , function ( done ) {
214
+ let postId ;
215
+ Post . create ( { title : 'Updating Arrays' , content : 'Content' , tags : [ 'AA' , 'AB' ] } )
216
+ . then ( ( post ) => {
217
+ postId = post . id ;
218
+ post . should . have . property ( 'tags' ) ;
219
+ post . tags [ 1 ] . should . eql ( 'AB' ) ;
220
+ return Post . updateAll ( { where : { id : postId } } , { tags : [ 'AA' , 'AC' ] } ) ;
221
+ } )
222
+ . then ( ( wooot ) => {
223
+ return Post . findOne ( { where : { id : postId } } ) ;
224
+ } )
225
+ . then ( ( post ) => {
226
+ post . should . have . property ( 'tags' ) ;
227
+ post . tags [ 1 ] . should . eql ( 'AC' ) ;
228
+ done ( ) ;
229
+ } )
230
+ . catch ( ( error ) => {
231
+ done ( error ) ;
232
+ } ) ;
233
+ } ) ;
234
+
235
+ it ( 'should support creating and updating arrays with "varchar[]" dataType' , function ( done ) {
236
+ let postId ;
237
+ Post . create ( { title : 'Updating Arrays' , content : 'Content' , categories : [ 'AA' , 'AB' ] } )
238
+ . then ( ( post ) => {
239
+ postId = post . id ;
240
+ post . should . have . property ( 'categories' ) ;
241
+ post . categories [ 1 ] . should . eql ( 'AB' ) ;
242
+ return Post . updateAll ( { where : { id : postId } } , { categories : [ 'AA' , 'AC' ] } ) ;
243
+ } )
244
+ . then ( ( wooot ) => {
245
+ return Post . findOne ( { where : { id : postId } } ) ;
246
+ } )
247
+ . then ( ( post ) => {
248
+ post . should . have . property ( 'categories' ) ;
249
+ post . categories [ 1 ] . should . eql ( 'AC' ) ;
250
+ done ( ) ;
251
+ } )
252
+ . catch ( ( error ) => {
253
+ done ( error ) ;
254
+ } ) ;
255
+ } ) ;
256
+
204
257
it ( 'should support boolean types with false value' , function ( done ) {
205
258
Post . create (
206
259
{ title : 'T2' , content : 'C2' , approved : false , created : created } ,
0 commit comments