orm: use the new optionals

pull/5401/head
Alexander Medvednikov 2020-06-17 01:56:50 +02:00
parent ed58192e4c
commit 88654ad81b
1 changed files with 4 additions and 2 deletions

View File

@ -36,8 +36,10 @@ fn (mut g Gen) sql_expr(node ast.SqlExpr) {
g.sql_stmt_name = g.new_tmp_var()
db_name := g.new_tmp_var()
g.writeln('\n\t// sql')
g.write('${dbtype}__DB $db_name = *(${dbtype}__DB*)${node.db_var_name}.data;')
g.write('sqlite3_stmt* $g.sql_stmt_name = ${dbtype}__DB_init_stmt(*(${dbtype}__DB*)${node.db_var_name}.data, tos_lit("$q')
// g.write('${dbtype}__DB $db_name = *(${dbtype}__DB*)${node.db_var_name}.data;')
g.write('${dbtype}__DB $db_name = ${node.db_var_name};')
// g.write('sqlite3_stmt* $g.sql_stmt_name = ${dbtype}__DB_init_stmt(*(${dbtype}__DB*)${node.db_var_name}.data, tos_lit("$q')
g.write('sqlite3_stmt* $g.sql_stmt_name = ${dbtype}__DB_init_stmt($db_name, tos_lit("$q')
if node.has_where && node.where_expr is ast.InfixExpr {
g.expr_to_sql(node.where_expr)
}