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:
@ -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 {
|
||||
|
Reference in New Issue
Block a user