File tree Expand file tree Collapse file tree 2 files changed +22
-7
lines changed Expand file tree Collapse file tree 2 files changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -146,7 +146,7 @@ const addColumnSqlize = ({
146146
147147 return format (
148148 `
149- ALTER TABLE %I.%I ADD COLUMN %I %I
149+ ALTER TABLE %I.%I ADD COLUMN %I ${ type }
150150 ${ defaultValueSql }
151151 ${ isIdentitySql }
152152 ${ isNullableSql }
@@ -155,8 +155,7 @@ ALTER TABLE %I.%I ADD COLUMN %I %I
155155${ commentSql } `,
156156 schema ,
157157 table ,
158- name ,
159- type
158+ name
160159 )
161160}
162161const getColumnSqlize = ( tableId : number , name : string ) => {
@@ -198,13 +197,11 @@ const alterColumnSqlize = (
198197 type === undefined
199198 ? ''
200199 : format (
201- ' ALTER TABLE %I.%I ALTER COLUMN %I SET DATA TYPE %I USING %I::%I;' ,
200+ ` ALTER TABLE %I.%I ALTER COLUMN %I SET DATA TYPE ${ type } USING %I::${ type } ;` ,
202201 old . schema ,
203202 old . table ,
204203 old . name ,
205- type ,
206- old . name ,
207- type
204+ old . name
208205 )
209206 let defaultValueSql : string
210207 if ( drop_default ) {
Original file line number Diff line number Diff line change @@ -323,6 +323,24 @@ describe('/tables', async () => {
323323 await axios . delete ( `${ URL } /columns/${ newTable . id } .1` )
324324 await axios . delete ( `${ URL } /tables/${ newTable . id } ` )
325325 } )
326+ it ( 'POST /columns array type' , async ( ) => {
327+ const { data : newTable } = await axios . post ( `${ URL } /tables` , { name : 'a' } )
328+ await axios . post ( `${ URL } /columns` , {
329+ table_id : newTable . id ,
330+ name : 'b' ,
331+ type : 'int2[]' ,
332+ } )
333+
334+ const { data : columns } = await axios . get ( `${ URL } /columns` )
335+ const newColumn = columns . find (
336+ ( column ) =>
337+ column . id === `${ newTable . id } .1` && column . name === 'b' && column . format === '_int2'
338+ )
339+ assert . equal ( newColumn . name , 'b' )
340+
341+ await axios . delete ( `${ URL } /columns/${ newTable . id } .1` )
342+ await axios . delete ( `${ URL } /tables/${ newTable . id } ` )
343+ } )
326344 it ( '/columns default_value with expressions' , async ( ) => {
327345 const { data : newTable } = await axios . post ( `${ URL } /tables` , { name : 'a' } )
328346 const { data : newColumn } = await axios . post ( `${ URL } /columns` , {
You can’t perform that action at this time.
0 commit comments