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:
@ -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) }
|
||||
|
||||
|
Reference in New Issue
Block a user