mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fmt: fix striping modules prefix in orm (#15005)
This commit is contained in:
parent
806c39d46e
commit
fef26a0b19
@ -1262,7 +1262,12 @@ 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.sym(node.table_expr.typ).name)
|
||||
sym := f.table.sym(node.table_expr.typ)
|
||||
mut table_name := sym.name
|
||||
if !table_name.starts_with('C.') && !table_name.starts_with('JS.') {
|
||||
table_name = f.no_cur_mod(f.short_module(sym.name)) // TODO f.type_to_str?
|
||||
}
|
||||
|
||||
f.mark_types_import_as_used(node.table_expr.typ)
|
||||
f.write('\t')
|
||||
match node.kind {
|
||||
@ -2530,7 +2535,11 @@ pub fn (mut f Fmt) sql_expr(node ast.SqlExpr) {
|
||||
f.expr(node.db_expr)
|
||||
f.writeln(' {')
|
||||
f.write('\tselect ')
|
||||
table_name := util.strip_mod_name(f.table.sym(node.table_expr.typ).name)
|
||||
sym := f.table.sym(node.table_expr.typ)
|
||||
mut table_name := sym.name
|
||||
if !table_name.starts_with('C.') && !table_name.starts_with('JS.') {
|
||||
table_name = f.no_cur_mod(f.short_module(sym.name)) // TODO f.type_to_str?
|
||||
}
|
||||
if node.is_count {
|
||||
f.write('count ')
|
||||
} else {
|
||||
|
9
vlib/v/fmt/tests/orm_prefix_keep.vv
Normal file
9
vlib/v/fmt/tests/orm_prefix_keep.vv
Normal file
@ -0,0 +1,9 @@
|
||||
// somefile.v
|
||||
import orm
|
||||
import models
|
||||
|
||||
fn init_db(db orm.Connection) {
|
||||
sql db {
|
||||
create table models.User
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user