mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
parent
1a9dab29c6
commit
ebb3a8eb25
3 changed files with 40 additions and 1 deletions
|
@ -179,6 +179,7 @@ const skip_with_fsanitize_memory = [
|
||||||
'vlib/v/tests/sql_statement_inside_fn_call_test.v',
|
'vlib/v/tests/sql_statement_inside_fn_call_test.v',
|
||||||
'vlib/v/tests/orm_stmt_wrong_return_checking_test.v',
|
'vlib/v/tests/orm_stmt_wrong_return_checking_test.v',
|
||||||
'vlib/v/tests/orm_table_name_test.v',
|
'vlib/v/tests/orm_table_name_test.v',
|
||||||
|
'vlib/v/tests/orm_array_field_test.v',
|
||||||
'vlib/v/tests/orm_handle_error_for_select_from_not_created_table_test.v',
|
'vlib/v/tests/orm_handle_error_for_select_from_not_created_table_test.v',
|
||||||
'vlib/v/tests/orm_create_several_tables_test.v',
|
'vlib/v/tests/orm_create_several_tables_test.v',
|
||||||
'vlib/vweb/tests/vweb_test.v',
|
'vlib/vweb/tests/vweb_test.v',
|
||||||
|
@ -271,6 +272,7 @@ const skip_on_ubuntu_musl = [
|
||||||
'vlib/v/tests/orm_joined_tables_select_test.v',
|
'vlib/v/tests/orm_joined_tables_select_test.v',
|
||||||
'vlib/v/tests/orm_stmt_wrong_return_checking_test.v',
|
'vlib/v/tests/orm_stmt_wrong_return_checking_test.v',
|
||||||
'vlib/v/tests/orm_table_name_test.v',
|
'vlib/v/tests/orm_table_name_test.v',
|
||||||
|
'vlib/v/tests/orm_array_field_test.v',
|
||||||
'vlib/v/tests/orm_handle_error_for_select_from_not_created_table_test.v',
|
'vlib/v/tests/orm_handle_error_for_select_from_not_created_table_test.v',
|
||||||
'vlib/v/tests/orm_create_several_tables_test.v',
|
'vlib/v/tests/orm_create_several_tables_test.v',
|
||||||
'vlib/v/tests/sql_statement_inside_fn_call_test.v',
|
'vlib/v/tests/sql_statement_inside_fn_call_test.v',
|
||||||
|
|
|
@ -319,7 +319,9 @@ fn (mut g Gen) write_orm_insert_with_last_ids(node ast.SqlStmtLine, connection_v
|
||||||
if field.typ.has_flag(.option) {
|
if field.typ.has_flag(.option) {
|
||||||
opt_fields << arrs.len
|
opt_fields << arrs.len
|
||||||
}
|
}
|
||||||
arrs << unsafe { node.sub_structs[int(field.typ)] }
|
if node.sub_structs.len > 0 {
|
||||||
|
arrs << unsafe { node.sub_structs[int(field.typ)] }
|
||||||
|
}
|
||||||
field_names << field.name
|
field_names << field.name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
35
vlib/v/tests/orm_array_field_test.v
Normal file
35
vlib/v/tests/orm_array_field_test.v
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
import time
|
||||||
|
import db.sqlite
|
||||||
|
|
||||||
|
@[table: 'task_metadata']
|
||||||
|
struct TaskMetadata {
|
||||||
|
id string @[primary]
|
||||||
|
task_id string
|
||||||
|
key string
|
||||||
|
value string
|
||||||
|
created_at time.Time @[default: 'CURRENT_TIME']
|
||||||
|
updated_at time.Time @[default: 'CURRENT_TIME']
|
||||||
|
}
|
||||||
|
|
||||||
|
@[table: 'tasks']
|
||||||
|
struct Task {
|
||||||
|
id string @[primary]
|
||||||
|
name string
|
||||||
|
metadata []TaskMetadata @[fkey: 'task_id']
|
||||||
|
}
|
||||||
|
|
||||||
|
struct MyService {
|
||||||
|
mut:
|
||||||
|
db sqlite.DB
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn (s MyService) create(record Task) int {
|
||||||
|
result := sql s.db {
|
||||||
|
insert record into Task
|
||||||
|
} or { return -1 }
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_main() {
|
||||||
|
assert true
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue