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 {
89
89
is_primary_key = false ,
90
90
is_unique = false ,
91
91
comment,
92
- constraint ,
92
+ check ,
93
93
} : {
94
94
table_id : number
95
95
name : string
@@ -102,7 +102,7 @@ export default class PostgresMetaColumns {
102
102
is_primary_key ?: boolean
103
103
is_unique ?: boolean
104
104
comment ?: string
105
- constraint ?: string
105
+ check ?: string
106
106
} ) : Promise < PostgresMetaResult < PostgresColumn > > {
107
107
const { data, error } = await this . metaTables . retrieve ( { id : table_id } )
108
108
if ( error ) {
@@ -122,10 +122,7 @@ export default class PostgresMetaColumns {
122
122
const isNullableClause = is_nullable ? 'NULL' : 'NOT NULL'
123
123
const isPrimaryKeyClause = is_primary_key ? 'PRIMARY KEY' : ''
124
124
const isUniqueClause = is_unique ? 'UNIQUE' : ''
125
- const constraintSql =
126
- constraint === undefined
127
- ? ''
128
- : constraint
125
+ const checkSql = check === undefined ? '' : `CHECK (${ check } )`
129
126
const commentSql =
130
127
comment === undefined
131
128
? ''
@@ -139,7 +136,7 @@ BEGIN;
139
136
${ isNullableClause }
140
137
${ isPrimaryKeyClause }
141
138
${ isUniqueClause }
142
- ${ constraintSql } ;
139
+ ${ checkSql } ;
143
140
${ commentSql } ;
144
141
COMMIT;`
145
142
{
Original file line number Diff line number Diff line change @@ -416,11 +416,11 @@ describe('/tables', async () => {
416
416
} )
417
417
it ( 'POST /columns with constraint definition' , async ( ) => {
418
418
const { data : newTable } = await axios . post ( `${ URL } /tables` , { name : 'a' } )
419
- const { error } = await axios . post ( `${ URL } /columns` , {
419
+ await axios . post ( `${ URL } /columns` , {
420
420
table_id : newTable . id ,
421
421
name : 'description' ,
422
422
type : 'text' ,
423
- constraint : "CHECK ( description <> '') " ,
423
+ check : "description <> ''" ,
424
424
} )
425
425
426
426
const { data : constraints } = await axios . post (
You can’t perform that action at this time.
0 commit comments