From c37945e37f76c1fca77eaa41a7019082d490e1ff Mon Sep 17 00:00:00 2001 From: Louis Schmieder Date: Thu, 8 Apr 2021 02:13:25 +0200 Subject: [PATCH] orm: add != (#9600) --- vlib/orm/orm_test.v | 5 +++++ vlib/v/gen/c/sql.v | 1 + 2 files changed, 6 insertions(+) diff --git a/vlib/orm/orm_test.v b/vlib/orm/orm_test.v index 408f35da40..bfef599add 100644 --- a/vlib/orm/orm_test.v +++ b/vlib/orm/orm_test.v @@ -32,6 +32,11 @@ fn test_orm_sqlite() { db.exec("insert into User (name, age) values ('Peter', 31)") db.exec("insert into User (name, age, is_customer) values ('Kate', 30, 1)") + c := sql db { + select count from User where id != 1 + } + assert c == 2 + nr_all_users := sql db { select count from User } diff --git a/vlib/v/gen/c/sql.v b/vlib/v/gen/c/sql.v index b782ff6bec..02fb4073ab 100644 --- a/vlib/v/gen/c/sql.v +++ b/vlib/v/gen/c/sql.v @@ -478,6 +478,7 @@ fn (mut g Gen) expr_to_sql(expr ast.Expr, typ SqlType) { g.sql_side = .left g.expr_to_sql(expr.left, typ) match expr.op { + .ne { g.write(' != ') } .eq { g.write(' = ') } .gt { g.write(' > ') } .lt { g.write(' < ') }