v
v copied to clipboard
orm: where <field> == nil not work
select from Task where updated_at == nil
module main
import db.sqlite
[table: 'task']
struct Task {
mut:
id int [primary; sql: serial]
a string
updated_at string
}
fn main() {
mut db := sqlite.connect('database.db')!
sql db {
create table Task
} or { panic('error on create table: ${err}') }
mut task_model := Task{
a: 'a'
}
sql db {
insert task_model into Task
}
task_model = Task{
updated_at: 'lala'
}
sql db {
insert task_model into Task
} or { panic('error on create table: ${err}') }
tasks := sql db {
select from Task where updated_at == nil
}
dump(tasks)
db.close()!
}
from https://discord.com/channels/592103645835821068/700746775962714232/1004082565369569380
https://www.sqlservercentral.com/articles/understanding-the-difference-between-is-null-and-null

