File tree Expand file tree Collapse file tree 2 files changed +6
-9
lines changed Expand file tree Collapse file tree 2 files changed +6
-9
lines changed Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ export default class PostgresMetaColumns {
8989 is_primary_key = false ,
9090 is_unique = false ,
9191 comment,
92- constraint ,
92+ check ,
9393 } : {
9494 table_id : number
9595 name : string
@@ -102,7 +102,7 @@ export default class PostgresMetaColumns {
102102 is_primary_key ?: boolean
103103 is_unique ?: boolean
104104 comment ?: string
105- constraint ?: string
105+ check ?: string
106106 } ) : Promise < PostgresMetaResult < PostgresColumn > > {
107107 const { data, error } = await this . metaTables . retrieve ( { id : table_id } )
108108 if ( error ) {
@@ -122,10 +122,7 @@ export default class PostgresMetaColumns {
122122 const isNullableClause = is_nullable ? 'NULL' : 'NOT NULL'
123123 const isPrimaryKeyClause = is_primary_key ? 'PRIMARY KEY' : ''
124124 const isUniqueClause = is_unique ? 'UNIQUE' : ''
125- const constraintSql =
126- constraint === undefined
127- ? ''
128- : constraint
125+ const checkSql = check === undefined ? '' : `CHECK (${ check } )`
129126 const commentSql =
130127 comment === undefined
131128 ? ''
@@ -139,7 +136,7 @@ BEGIN;
139136 ${ isNullableClause }
140137 ${ isPrimaryKeyClause }
141138 ${ isUniqueClause }
142- ${ constraintSql } ;
139+ ${ checkSql } ;
143140 ${ commentSql } ;
144141COMMIT;`
145142 {
Original file line number Diff line number Diff line change @@ -416,11 +416,11 @@ describe('/tables', async () => {
416416 } )
417417 it ( 'POST /columns with constraint definition' , async ( ) => {
418418 const { data : newTable } = await axios . post ( `${ URL } /tables` , { name : 'a' } )
419- const { error } = await axios . post ( `${ URL } /columns` , {
419+ await axios . post ( `${ URL } /columns` , {
420420 table_id : newTable . id ,
421421 name : 'description' ,
422422 type : 'text' ,
423- constraint : "CHECK ( description <> '') " ,
423+ check : "description <> ''" ,
424424 } )
425425
426426 const { data : constraints } = await axios . post (
You can’t perform that action at this time.
0 commit comments