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

test-cleancode: add vlib/orm (#7577)

This commit is contained in:
Lukas Neubert 2020-12-26 13:40:22 +01:00 committed by GitHub
parent 693e5137eb
commit 6969300f8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 27 deletions

View File

@ -24,6 +24,7 @@ const (
'vlib/builtin/array_test.v',
'vlib/builtin/map.v',
'vlib/math/bits/bits.v',
'vlib/orm/',
'vlib/term/colors.v',
'vlib/term/term.v',
'vlib/v/ast/',

View File

@ -23,11 +23,9 @@ struct Foo {
fn test_orm_sqlite() {
db := sqlite.connect(':memory:') or { panic(err) }
db.exec("drop table if exists User")
db.exec('drop table if exists User')
db.exec("create table User (id integer primary key, age int default 0, name text default '', is_customer int default 0);")
name := 'Peter'
db.exec("insert into User (name, age) values ('Sam', 29)")
db.exec("insert into User (name, age) values ('Peter', 31)")
db.exec("insert into User (name, age, is_customer) values ('Kate', 30, 1)")
@ -99,8 +97,10 @@ fn test_orm_sqlite() {
assert users3[0].age == 29
assert users3[1].age == 31
//
new_user := User{name:'New user' age:30}
new_user := User{
name: 'New user'
age: 30
}
sql db {
insert new_user into User
}
@ -197,23 +197,18 @@ fn test_orm_sqlite() {
}
assert z.len == 2
assert z[0].id == 3
oldest := sql db {
select from User order by age desc limit 1
}
assert oldest.age == 34
offs := 1
second_oldest := sql db {
select from User order by age desc limit 1 offset offs
}
assert second_oldest.age == 31
sql db {
delete from User where age == 34
}
updated_oldest := sql db {
select from User order by age desc limit 1
}
@ -244,7 +239,6 @@ fn test_orm_pg() {
println(mod)
}
*/
/*
mod := db.retrieve<Module>(1)
mod := db.select from Module where id = 1