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

orm: fix time (#11026)

This commit is contained in:
Louis Schmieder
2021-08-03 04:17:00 +02:00
committed by GitHub
parent 6dcf72fe9b
commit a55ba08fad
7 changed files with 52 additions and 15 deletions

View File

@ -1,6 +1,7 @@
// import os
// import pg
// import term
import time
import sqlite
struct Module {
@ -23,6 +24,11 @@ struct Foo {
age int
}
struct TestTime {
id int [primary; sql: serial]
create time.Time
}
fn test_orm_sqlite() {
db := sqlite.connect(':memory:') or { panic(err) }
db.exec('drop table if exists User')
@ -287,4 +293,24 @@ fn test_orm_sqlite() {
}
assert first.age == 60
sql db {
create table TestTime
}
tnow := time.now()
time_test := TestTime{
create: tnow
}
sql db {
insert time_test into TestTime
}
data := sql db {
select from TestTime where create == tnow
}
assert data.len == 1
}