Skip to content

Commit e42f6c1

Browse files
committed
fix
1 parent b5a7c1c commit e42f6c1

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/ts_generator/information_schema.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,16 +240,17 @@ impl DBSchema {
240240
let name: String = row.get(1)?;
241241
let type_name: String = row.get(2)?;
242242
let notnull: bool = row.get(3)?;
243-
Ok((name, type_name, notnull, table_name.clone()))
243+
let pk: i32 = row.get(5)?;
244+
Ok((name, type_name, notnull, pk, table_name.clone()))
244245
}) {
245246
Ok(rows) => rows,
246247
Err(_) => continue,
247248
};
248249

249-
for (field_name, field_type, notnull, tbl_name) in rows.flatten() {
250+
for (field_name, field_type, notnull, pk, tbl_name) in rows.flatten() {
250251
let field = Field {
251252
field_type: TsFieldType::get_ts_field_type_from_sqlite_field_type(field_type, tbl_name, field_name.clone()),
252-
is_nullable: !notnull,
253+
is_nullable: !notnull && pk == 0,
253254
};
254255
all_fields.insert(field_name, field);
255256
}

0 commit comments

Comments
 (0)