diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index 42f23efb92..411e20bba9 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -1253,6 +1253,7 @@ pub fn (mut f Fmt) sql_stmt(node ast.SqlStmt) { pub fn (mut f Fmt) sql_stmt_line(node ast.SqlStmtLine) { table_name := util.strip_mod_name(f.table.get_type_symbol(node.table_expr.typ).name) + f.mark_types_import_as_used(node.table_expr.typ) f.write('\t') match node.kind { .insert { diff --git a/vlib/v/fmt/tests/orm_keep.vv b/vlib/v/fmt/tests/orm_keep.vv index be3683057e..26513bde6a 100644 --- a/vlib/v/fmt/tests/orm_keep.vv +++ b/vlib/v/fmt/tests/orm_keep.vv @@ -1,4 +1,5 @@ import sqlite +import mymodule { ModDbStruct } struct Customer { id int @@ -56,4 +57,11 @@ fn main() { update Customer set name = 'Queen Elizabeth II', age = 150, nr_orders = 42, country = 'Great Britain' where id == 5 } + // DB is a selective import + sql db { + delete from ModDbStruct where id == 1 + } + _ := sql db { + select from ModDbStruct + } }