mirror of
https://github.com/vlang/v.git
synced 2025-09-14 06:52:36 +03:00
fmt: fix alignment of struct init fields (#22025)
This commit is contained in:
parent
99da5726db
commit
c51d30bf53
671 changed files with 18817 additions and 18787 deletions
|
@ -29,7 +29,7 @@ fn test_main() {
|
|||
} or { panic(err) }
|
||||
|
||||
new_parent := Parent{
|
||||
name: 'first parent'
|
||||
name: 'first parent'
|
||||
children: [
|
||||
Child{
|
||||
name: 'first child'
|
||||
|
@ -46,23 +46,23 @@ fn test_main() {
|
|||
|
||||
babies := [
|
||||
Baby{
|
||||
name: 'first baby'
|
||||
name: 'first baby'
|
||||
child_id: 1
|
||||
},
|
||||
Baby{
|
||||
name: 'second baby'
|
||||
name: 'second baby'
|
||||
child_id: 1
|
||||
},
|
||||
Baby{
|
||||
name: 'third baby'
|
||||
name: 'third baby'
|
||||
child_id: 2
|
||||
},
|
||||
Baby{
|
||||
name: 'fourth baby'
|
||||
name: 'fourth baby'
|
||||
child_id: 2
|
||||
},
|
||||
Baby{
|
||||
name: 'fifth baby'
|
||||
name: 'fifth baby'
|
||||
child_id: 2
|
||||
},
|
||||
]
|
||||
|
|
|
@ -131,12 +131,12 @@ pub fn connect(path string) !DB {
|
|||
code := C.sqlite3_open(&char(path.str), &db)
|
||||
if code != 0 {
|
||||
return &SQLError{
|
||||
msg: unsafe { cstring_to_vstring(&char(C.sqlite3_errmsg(db))) }
|
||||
msg: unsafe { cstring_to_vstring(&char(C.sqlite3_errmsg(db))) }
|
||||
code: code
|
||||
}
|
||||
}
|
||||
return DB{
|
||||
conn: db
|
||||
conn: db
|
||||
is_open: true
|
||||
}
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ pub fn (mut db DB) close() !bool {
|
|||
db.is_open = false
|
||||
} else {
|
||||
return &SQLError{
|
||||
msg: unsafe { cstring_to_vstring(&char(C.sqlite3_errmsg(db.conn))) }
|
||||
msg: unsafe { cstring_to_vstring(&char(C.sqlite3_errmsg(db.conn))) }
|
||||
code: code
|
||||
}
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ pub fn (db &DB) exec_one(query string) !Row {
|
|||
}
|
||||
if rows.len == 0 {
|
||||
return &SQLError{
|
||||
msg: 'No rows'
|
||||
msg: 'No rows'
|
||||
code: sqlite.sqlite_done
|
||||
}
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ pub fn (db &DB) error_message(code int, query string) IError {
|
|||
msg := '${errmsg} (${code}) (${query})'
|
||||
unsafe { errmsg.free() }
|
||||
return SQLError{
|
||||
msg: msg
|
||||
msg: msg
|
||||
code: code
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,47 +33,47 @@ fn test_sqlite_orm() {
|
|||
}
|
||||
db.create('Test', [
|
||||
orm.TableField{
|
||||
name: 'id'
|
||||
typ: typeof[int]().idx
|
||||
name: 'id'
|
||||
typ: typeof[int]().idx
|
||||
attrs: [
|
||||
VAttribute{
|
||||
name: 'primary'
|
||||
},
|
||||
VAttribute{
|
||||
name: 'sql'
|
||||
name: 'sql'
|
||||
has_arg: true
|
||||
kind: .plain
|
||||
arg: 'serial'
|
||||
kind: .plain
|
||||
arg: 'serial'
|
||||
},
|
||||
]
|
||||
},
|
||||
orm.TableField{
|
||||
name: 'name'
|
||||
typ: typeof[string]().idx
|
||||
name: 'name'
|
||||
typ: typeof[string]().idx
|
||||
attrs: []
|
||||
},
|
||||
orm.TableField{
|
||||
name: 'age'
|
||||
typ: typeof[i64]().idx
|
||||
typ: typeof[i64]().idx
|
||||
},
|
||||
]) or { panic(err) }
|
||||
|
||||
db.insert('Test', orm.QueryData{
|
||||
fields: ['name', 'age']
|
||||
data: [orm.string_to_primitive('Louis'), orm.i64_to_primitive(100)]
|
||||
data: [orm.string_to_primitive('Louis'), orm.i64_to_primitive(100)]
|
||||
}) or { panic(err) }
|
||||
|
||||
res := db.@select(orm.SelectConfig{
|
||||
table: 'Test'
|
||||
table: 'Test'
|
||||
has_where: true
|
||||
fields: ['id', 'name', 'age']
|
||||
types: [typeof[int]().idx, typeof[string]().idx, typeof[i64]().idx]
|
||||
fields: ['id', 'name', 'age']
|
||||
types: [typeof[int]().idx, typeof[string]().idx, typeof[i64]().idx]
|
||||
}, orm.QueryData{}, orm.QueryData{
|
||||
fields: ['name', 'age']
|
||||
data: [orm.Primitive('Louis'), i64(100)]
|
||||
types: [typeof[string]().idx, typeof[i64]().idx]
|
||||
data: [orm.Primitive('Louis'), i64(100)]
|
||||
types: [typeof[string]().idx, typeof[i64]().idx]
|
||||
is_and: [true, true]
|
||||
kinds: [.eq, .eq]
|
||||
kinds: [.eq, .eq]
|
||||
}) or { panic(err) }
|
||||
|
||||
id := res[0][0]
|
||||
|
@ -177,7 +177,7 @@ fn test_get_affected_rows_count() {
|
|||
);')!
|
||||
|
||||
fst := EntityToTest{
|
||||
id: 1
|
||||
id: 1
|
||||
smth: '1'
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,7 @@ fn test_get_affected_rows_count() {
|
|||
assert db.get_affected_rows_count() == 1
|
||||
|
||||
snd := EntityToTest{
|
||||
id: 1
|
||||
id: 1
|
||||
smth: '2'
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ fn test_vfs_register() {
|
|||
|
||||
vfs_name := 'sometest'
|
||||
mut vfs_descr := &sqlite.Sqlite3_vfs{
|
||||
zName: vfs_name.str
|
||||
zName: vfs_name.str
|
||||
iVersion: 2
|
||||
}
|
||||
|
||||
|
@ -42,23 +42,23 @@ fn test_verify_vfs_is_actually_used() {
|
|||
log: []string{cap: 100}
|
||||
}
|
||||
mut vfs_descr := &sqlite.Sqlite3_vfs{
|
||||
iVersion: 2
|
||||
szOsFile: int(sizeof(ExampleVfsOpenedFile))
|
||||
mxPathname: max_file_name_len
|
||||
zName: vfs_name.str
|
||||
pAppData: vfs_state
|
||||
xOpen: example_vfs_open
|
||||
xDelete: example_vfs_delete
|
||||
xAccess: example_vfs_access
|
||||
xFullPathname: example_vfs_fullpathname
|
||||
xDlOpen: wrapped.xDlOpen
|
||||
xDlError: wrapped.xDlError
|
||||
xDlSym: wrapped.xDlSym
|
||||
xDlClose: wrapped.xDlClose
|
||||
xRandomness: wrapped.xRandomness
|
||||
xSleep: wrapped.xSleep
|
||||
xCurrentTime: wrapped.xCurrentTime
|
||||
xGetLastError: example_vfs_getlasterror
|
||||
iVersion: 2
|
||||
szOsFile: int(sizeof(ExampleVfsOpenedFile))
|
||||
mxPathname: max_file_name_len
|
||||
zName: vfs_name.str
|
||||
pAppData: vfs_state
|
||||
xOpen: example_vfs_open
|
||||
xDelete: example_vfs_delete
|
||||
xAccess: example_vfs_access
|
||||
xFullPathname: example_vfs_fullpathname
|
||||
xDlOpen: wrapped.xDlOpen
|
||||
xDlError: wrapped.xDlError
|
||||
xDlSym: wrapped.xDlSym
|
||||
xDlClose: wrapped.xDlClose
|
||||
xRandomness: wrapped.xRandomness
|
||||
xSleep: wrapped.xSleep
|
||||
xCurrentTime: wrapped.xCurrentTime
|
||||
xGetLastError: example_vfs_getlasterror
|
||||
xCurrentTimeInt64: wrapped.xCurrentTimeInt64
|
||||
}
|
||||
|
||||
|
@ -155,18 +155,18 @@ fn example_vfs_open(vfs &sqlite.Sqlite3_vfs, file_name_or_null_for_tempfile &cha
|
|||
unsafe {
|
||||
mut outp := to_vfsopenedfile(vfs_opened_file)
|
||||
outp.base.pMethods = &sqlite.Sqlite3_io_methods{
|
||||
iVersion: 1
|
||||
xClose: example_vfsfile_close
|
||||
xRead: example_vfsfile_read
|
||||
xWrite: example_vfsfile_write
|
||||
xTruncate: example_vfsfile_truncate
|
||||
xSync: example_vfsfile_sync
|
||||
xFileSize: example_vfsfile_size
|
||||
xLock: example_vfsfile_lock
|
||||
xUnlock: example_vfsfile_unlock
|
||||
xCheckReservedLock: example_vfsfile_checkreservedlock
|
||||
xFileControl: example_vfsfile_filecontrol
|
||||
xSectorSize: example_vfsfile_sectorsize
|
||||
iVersion: 1
|
||||
xClose: example_vfsfile_close
|
||||
xRead: example_vfsfile_read
|
||||
xWrite: example_vfsfile_write
|
||||
xTruncate: example_vfsfile_truncate
|
||||
xSync: example_vfsfile_sync
|
||||
xFileSize: example_vfsfile_size
|
||||
xLock: example_vfsfile_lock
|
||||
xUnlock: example_vfsfile_unlock
|
||||
xCheckReservedLock: example_vfsfile_checkreservedlock
|
||||
xFileControl: example_vfsfile_filecontrol
|
||||
xSectorSize: example_vfsfile_sectorsize
|
||||
xDeviceCharacteristics: example_vfsfile_devicecharacteristics
|
||||
}
|
||||
|
||||
|
|
|
@ -155,12 +155,12 @@ pub fn connect_full(path string, mode_flags []OpenModeFlag, vfs_name string) !DB
|
|||
code := C.sqlite3_open_v2(&char(path.str), &db, flags, vfs_name.str)
|
||||
if code != 0 {
|
||||
return &SQLError{
|
||||
msg: unsafe { cstring_to_vstring(&char(C.sqlite3_errstr(code))) }
|
||||
msg: unsafe { cstring_to_vstring(&char(C.sqlite3_errstr(code))) }
|
||||
code: code
|
||||
}
|
||||
}
|
||||
return DB{
|
||||
conn: db
|
||||
conn: db
|
||||
is_open: true
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue