1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

db, json, time, term: change optional to result (#16201)

This commit is contained in:
yuyi
2022-10-26 16:26:28 +08:00
committed by GitHub
parent 2a7420f572
commit 992b502198
57 changed files with 340 additions and 340 deletions

View File

@ -170,12 +170,12 @@ pub:
// Every function without last_id() returns an optional, which returns an error if present
// last_id returns the last inserted id of the db
pub interface Connection {
@select(config SelectConfig, data QueryData, where QueryData) ?[][]Primitive
insert(table string, data QueryData) ?
update(table string, data QueryData, where QueryData) ?
delete(table string, where QueryData) ?
create(table string, fields []TableField) ?
drop(table string) ?
@select(config SelectConfig, data QueryData, where QueryData) ![][]Primitive
insert(table string, data QueryData) !
update(table string, data QueryData, where QueryData) !
delete(table string, where QueryData) !
create(table string, fields []TableField) !
drop(table string) !
last_id() Primitive
}
@ -392,7 +392,7 @@ pub fn orm_select_gen(orm SelectConfig, q string, num bool, qm string, start_pos
// fields - See TableField
// sql_from_v - Function which maps type indices to sql type names
// alternative - Needed for msdb
pub fn orm_table_gen(table string, q string, defaults bool, def_unique_len int, fields []TableField, sql_from_v fn (int) ?string, alternative bool) ?string {
pub fn orm_table_gen(table string, q string, defaults bool, def_unique_len int, fields []TableField, sql_from_v fn (int) !string, alternative bool) !string {
mut str := 'CREATE TABLE IF NOT EXISTS $q$table$q ('
if alternative {
@ -416,7 +416,7 @@ pub fn orm_table_gen(table string, q string, defaults bool, def_unique_len int,
mut field_name := sql_field_name(field)
mut ctyp := sql_from_v(sql_field_type(field)) or {
field_name = '${field_name}_id'
sql_from_v(7)?
sql_from_v(7)!
}
for attr in field.attrs {
match attr.name {