mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: breaking change, let V ORM queries return arrays for *all* non-count queries, including limit = 1
(#17719)
This commit is contained in:
@ -34,9 +34,10 @@ fn (mut app App) service_auth(username string, password string) !string {
|
||||
db.close() or { panic(err) }
|
||||
}
|
||||
|
||||
user := sql db {
|
||||
select from User where username == username limit 1
|
||||
users := sql db {
|
||||
select from User where username == username
|
||||
}
|
||||
user := users.first()
|
||||
if user.username != username {
|
||||
return error('user not found')
|
||||
}
|
||||
|
@ -61,5 +61,5 @@ fn (mut app App) service_get_user(id int) !User {
|
||||
select from User where id == id
|
||||
}
|
||||
|
||||
return results
|
||||
return results.first()
|
||||
}
|
||||
|
@ -31,13 +31,15 @@ fn (mut app App) service_auth(username string, password string) !string {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
user := sql db {
|
||||
select from User where username == username limit 1
|
||||
users := sql db {
|
||||
select from User where username == username
|
||||
}
|
||||
if user.username != username {
|
||||
|
||||
if users.len == 0 {
|
||||
return error('user not found')
|
||||
}
|
||||
|
||||
user := users.first()
|
||||
if !user.active {
|
||||
return error('user is not active')
|
||||
}
|
||||
|
@ -31,11 +31,11 @@ fn (mut app App) service_add_user(username string, password string) !User {
|
||||
return err
|
||||
}
|
||||
|
||||
result := sql db {
|
||||
users := sql db {
|
||||
select from User where username == username limit 1
|
||||
}
|
||||
|
||||
return result
|
||||
return users.first()
|
||||
}
|
||||
|
||||
fn (mut app App) service_get_user_by_id(user_id int) !User {
|
||||
@ -48,11 +48,11 @@ fn (mut app App) service_get_user_by_id(user_id int) !User {
|
||||
db.close() or { panic(err) }
|
||||
}
|
||||
|
||||
results := sql db {
|
||||
users := sql db {
|
||||
select from User where id == user_id
|
||||
}
|
||||
|
||||
return results
|
||||
return users.first()
|
||||
}
|
||||
|
||||
fn (mut app App) service_get_all_user() ![]User {
|
||||
|
Reference in New Issue
Block a user