1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

orm: allow inserting empty objects with db.sqlite (SQLite uses a slightly different SQL dialect) (#17334)

This commit is contained in:
walking devel
2023-02-16 09:34:16 +00:00
committed by GitHub
parent 289993ad7f
commit 580dbc3f0e
9 changed files with 72 additions and 34 deletions

View File

@ -21,12 +21,33 @@ mut:
text string
}
struct Account {
id int [primary; sql: serial]
}
pub fn insert_parent(db sqlite.DB, mut parent Parent) {
sql db {
insert parent into Parent
}
}
fn test_insert_empty_object() {
db := sqlite.connect(':memory:') or { panic(err) }
account := Account{}
sql db {
create table Account
insert account into Account
}
accounts := sql db {
select from Account
}
assert accounts.len == 1
}
fn test_orm_insert_mut_object() {
db := sqlite.connect(':memory:') or { panic(err) }