orm: order by id by default

pull/5460/head
Alexander Medvednikov 2020-06-22 17:13:57 +02:00
parent e3f00ff28b
commit a4b159a80f
2 changed files with 6 additions and 2 deletions

View File

@ -107,7 +107,7 @@ fn (mut g Gen) sql_select_expr(node ast.SqlExpr) {
if node.has_where && node.where_expr is ast.InfixExpr {
g.expr_to_sql(node.where_expr)
}
g.writeln('"));')
g.writeln(' order by id"));')
// Dump all sql parameters generated by our custom expr handler
binds := g.sql_buf.str()
g.sql_buf = strings.new_builder(100)
@ -137,7 +137,7 @@ fn (mut g Gen) sql_select_expr(node ast.SqlExpr) {
//
g.writeln('int _step_res$tmp = sqlite3_step($g.sql_stmt_name);')
if node.is_array {
g.writeln('\tprintf("step res=%d\\n", _step_res$tmp);')
//g.writeln('\tprintf("step res=%d\\n", _step_res$tmp);')
g.writeln('\tif (_step_res$tmp == SQLITE_DONE) break;')
g.writeln('\tif (_step_res$tmp = SQLITE_ROW) ;') // another row
g.writeln('\telse if (_step_res$tmp != SQLITE_OK) break;')

View File

@ -402,3 +402,7 @@ fn strip(s string) string {
// strip('\nabc\r\n') => 'abc'
return s.trim('\r\n')
}
pub fn not_found() Result {
return Result{}
}