fmt: keep selective struct import when used in orm block (#10124)

pull/10134/head
Lukas Neubert 2021-05-18 11:45:42 +02:00 committed by GitHub
parent f1174daabd
commit 9a7acd244d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -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 {

View File

@ -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
}
}