mirror of
https://github.com/vlang/v.git
synced 2025-09-14 15:02:33 +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
|
@ -5,28 +5,28 @@ import orm
|
|||
fn test_orm_stmt_gen_update() {
|
||||
query_and, _ := orm.orm_stmt_gen(.default, 'Test', "'", .update, true, '?', 0, orm.QueryData{
|
||||
fields: ['test', 'a']
|
||||
data: []
|
||||
types: []
|
||||
kinds: []
|
||||
data: []
|
||||
types: []
|
||||
kinds: []
|
||||
}, orm.QueryData{
|
||||
fields: ['id', 'name']
|
||||
data: []
|
||||
types: []
|
||||
kinds: [.ge, .eq]
|
||||
data: []
|
||||
types: []
|
||||
kinds: [.ge, .eq]
|
||||
is_and: [true]
|
||||
})
|
||||
assert query_and == "UPDATE 'Test' SET 'test' = ?0, 'a' = ?1 WHERE 'id' >= ?2 AND 'name' = ?3;"
|
||||
|
||||
query_or, _ := orm.orm_stmt_gen(.default, 'Test', "'", .update, true, '?', 0, orm.QueryData{
|
||||
fields: ['test', 'a']
|
||||
data: []
|
||||
types: []
|
||||
kinds: []
|
||||
data: []
|
||||
types: []
|
||||
kinds: []
|
||||
}, orm.QueryData{
|
||||
fields: ['id', 'name']
|
||||
data: []
|
||||
types: []
|
||||
kinds: [.ge, .eq]
|
||||
data: []
|
||||
types: []
|
||||
kinds: [.ge, .eq]
|
||||
is_and: [false]
|
||||
})
|
||||
assert query_or == "UPDATE 'Test' SET 'test' = ?0, 'a' = ?1 WHERE 'id' >= ?2 OR 'name' = ?3;"
|
||||
|
@ -35,9 +35,9 @@ fn test_orm_stmt_gen_update() {
|
|||
fn test_orm_stmt_gen_insert() {
|
||||
query, _ := orm.orm_stmt_gen(.default, 'Test', "'", .insert, true, '?', 0, orm.QueryData{
|
||||
fields: ['test', 'a']
|
||||
data: []
|
||||
types: []
|
||||
kinds: []
|
||||
data: []
|
||||
types: []
|
||||
kinds: []
|
||||
}, orm.QueryData{})
|
||||
assert query == "INSERT INTO 'Test' ('test', 'a') VALUES (?0, ?1);"
|
||||
}
|
||||
|
@ -45,28 +45,28 @@ fn test_orm_stmt_gen_insert() {
|
|||
fn test_orm_stmt_gen_delete() {
|
||||
query_and, _ := orm.orm_stmt_gen(.default, 'Test', "'", .delete, true, '?', 0, orm.QueryData{
|
||||
fields: ['test', 'a']
|
||||
data: []
|
||||
types: []
|
||||
kinds: []
|
||||
data: []
|
||||
types: []
|
||||
kinds: []
|
||||
}, orm.QueryData{
|
||||
fields: ['id', 'name']
|
||||
data: []
|
||||
types: []
|
||||
kinds: [.ge, .eq]
|
||||
data: []
|
||||
types: []
|
||||
kinds: [.ge, .eq]
|
||||
is_and: [true]
|
||||
})
|
||||
assert query_and == "DELETE FROM 'Test' WHERE 'id' >= ?0 AND 'name' = ?1;"
|
||||
|
||||
query_or, _ := orm.orm_stmt_gen(.default, 'Test', "'", .delete, true, '?', 0, orm.QueryData{
|
||||
fields: ['test', 'a']
|
||||
data: []
|
||||
types: []
|
||||
kinds: []
|
||||
data: []
|
||||
types: []
|
||||
kinds: []
|
||||
}, orm.QueryData{
|
||||
fields: ['id', 'name']
|
||||
data: []
|
||||
types: []
|
||||
kinds: [.ge, .eq]
|
||||
data: []
|
||||
types: []
|
||||
kinds: [.ge, .eq]
|
||||
is_and: [false]
|
||||
})
|
||||
assert query_or == "DELETE FROM 'Test' WHERE 'id' >= ?0 OR 'name' = ?1;"
|
||||
|
@ -78,7 +78,7 @@ fn get_select_fields() []string {
|
|||
|
||||
fn test_orm_select_gen() {
|
||||
query := orm.orm_select_gen(orm.SelectConfig{
|
||||
table: 'test_table'
|
||||
table: 'test_table'
|
||||
fields: get_select_fields()
|
||||
}, "'", true, '?', 0, orm.QueryData{})
|
||||
|
||||
|
@ -87,8 +87,8 @@ fn test_orm_select_gen() {
|
|||
|
||||
fn test_orm_select_gen_with_limit() {
|
||||
query := orm.orm_select_gen(orm.SelectConfig{
|
||||
table: 'test_table'
|
||||
fields: get_select_fields()
|
||||
table: 'test_table'
|
||||
fields: get_select_fields()
|
||||
has_limit: true
|
||||
}, "'", true, '?', 0, orm.QueryData{})
|
||||
|
||||
|
@ -97,12 +97,12 @@ fn test_orm_select_gen_with_limit() {
|
|||
|
||||
fn test_orm_select_gen_with_where() {
|
||||
query := orm.orm_select_gen(orm.SelectConfig{
|
||||
table: 'test_table'
|
||||
fields: get_select_fields()
|
||||
table: 'test_table'
|
||||
fields: get_select_fields()
|
||||
has_where: true
|
||||
}, "'", true, '?', 0, orm.QueryData{
|
||||
fields: ['abc', 'test']
|
||||
kinds: [.eq, .gt]
|
||||
kinds: [.eq, .gt]
|
||||
is_and: [true]
|
||||
})
|
||||
|
||||
|
@ -111,9 +111,9 @@ fn test_orm_select_gen_with_where() {
|
|||
|
||||
fn test_orm_select_gen_with_order() {
|
||||
query := orm.orm_select_gen(orm.SelectConfig{
|
||||
table: 'test_table'
|
||||
fields: get_select_fields()
|
||||
has_order: true
|
||||
table: 'test_table'
|
||||
fields: get_select_fields()
|
||||
has_order: true
|
||||
order_type: .desc
|
||||
}, "'", true, '?', 0, orm.QueryData{})
|
||||
|
||||
|
@ -122,8 +122,8 @@ fn test_orm_select_gen_with_order() {
|
|||
|
||||
fn test_orm_select_gen_with_offset() {
|
||||
query := orm.orm_select_gen(orm.SelectConfig{
|
||||
table: 'test_table'
|
||||
fields: get_select_fields()
|
||||
table: 'test_table'
|
||||
fields: get_select_fields()
|
||||
has_offset: true
|
||||
}, "'", true, '?', 0, orm.QueryData{})
|
||||
|
||||
|
@ -132,16 +132,16 @@ fn test_orm_select_gen_with_offset() {
|
|||
|
||||
fn test_orm_select_gen_with_all() {
|
||||
query := orm.orm_select_gen(orm.SelectConfig{
|
||||
table: 'test_table'
|
||||
fields: get_select_fields()
|
||||
has_limit: true
|
||||
has_order: true
|
||||
table: 'test_table'
|
||||
fields: get_select_fields()
|
||||
has_limit: true
|
||||
has_order: true
|
||||
order_type: .desc
|
||||
has_offset: true
|
||||
has_where: true
|
||||
has_where: true
|
||||
}, "'", true, '?', 0, orm.QueryData{
|
||||
fields: ['abc', 'test']
|
||||
kinds: [.eq, .gt]
|
||||
kinds: [.eq, .gt]
|
||||
is_and: [true]
|
||||
})
|
||||
|
||||
|
@ -151,31 +151,31 @@ fn test_orm_select_gen_with_all() {
|
|||
fn test_orm_table_gen() {
|
||||
query := orm.orm_table_gen('test_table', "'", true, 0, [
|
||||
orm.TableField{
|
||||
name: 'id'
|
||||
typ: typeof[int]().idx
|
||||
name: 'id'
|
||||
typ: typeof[int]().idx
|
||||
default_val: '10'
|
||||
nullable: true
|
||||
attrs: [
|
||||
nullable: true
|
||||
attrs: [
|
||||
VAttribute{
|
||||
name: 'primary'
|
||||
},
|
||||
VAttribute{
|
||||
name: 'sql'
|
||||
name: 'sql'
|
||||
has_arg: true
|
||||
arg: 'serial'
|
||||
kind: .plain
|
||||
arg: 'serial'
|
||||
kind: .plain
|
||||
},
|
||||
]
|
||||
},
|
||||
orm.TableField{
|
||||
name: 'test'
|
||||
typ: typeof[string]().idx
|
||||
name: 'test'
|
||||
typ: typeof[string]().idx
|
||||
nullable: true
|
||||
},
|
||||
orm.TableField{
|
||||
name: 'abc'
|
||||
typ: typeof[i64]().idx
|
||||
nullable: true
|
||||
name: 'abc'
|
||||
typ: typeof[i64]().idx
|
||||
nullable: true
|
||||
default_val: '6754'
|
||||
},
|
||||
], sql_type_from_v, false) or { panic(err) }
|
||||
|
@ -183,31 +183,31 @@ fn test_orm_table_gen() {
|
|||
|
||||
alt_query := orm.orm_table_gen('test_table', "'", true, 0, [
|
||||
orm.TableField{
|
||||
name: 'id'
|
||||
typ: typeof[int]().idx
|
||||
nullable: true
|
||||
name: 'id'
|
||||
typ: typeof[int]().idx
|
||||
nullable: true
|
||||
default_val: '10'
|
||||
attrs: [
|
||||
attrs: [
|
||||
VAttribute{
|
||||
name: 'primary'
|
||||
},
|
||||
VAttribute{
|
||||
name: 'sql'
|
||||
name: 'sql'
|
||||
has_arg: true
|
||||
arg: 'serial'
|
||||
kind: .plain
|
||||
arg: 'serial'
|
||||
kind: .plain
|
||||
},
|
||||
]
|
||||
},
|
||||
orm.TableField{
|
||||
name: 'test'
|
||||
typ: typeof[string]().idx
|
||||
name: 'test'
|
||||
typ: typeof[string]().idx
|
||||
nullable: true
|
||||
},
|
||||
orm.TableField{
|
||||
name: 'abc'
|
||||
typ: typeof[i64]().idx
|
||||
nullable: true
|
||||
name: 'abc'
|
||||
typ: typeof[i64]().idx
|
||||
nullable: true
|
||||
default_val: '6754'
|
||||
},
|
||||
], sql_type_from_v, true) or { panic(err) }
|
||||
|
@ -215,25 +215,25 @@ fn test_orm_table_gen() {
|
|||
|
||||
unique_query := orm.orm_table_gen('test_table', "'", true, 0, [
|
||||
orm.TableField{
|
||||
name: 'id'
|
||||
typ: typeof[int]().idx
|
||||
nullable: true
|
||||
name: 'id'
|
||||
typ: typeof[int]().idx
|
||||
nullable: true
|
||||
default_val: '10'
|
||||
attrs: [
|
||||
attrs: [
|
||||
VAttribute{
|
||||
name: 'primary'
|
||||
},
|
||||
VAttribute{
|
||||
name: 'sql'
|
||||
name: 'sql'
|
||||
has_arg: true
|
||||
arg: 'serial'
|
||||
kind: .plain
|
||||
arg: 'serial'
|
||||
kind: .plain
|
||||
},
|
||||
]
|
||||
},
|
||||
orm.TableField{
|
||||
name: 'test'
|
||||
typ: typeof[string]().idx
|
||||
name: 'test'
|
||||
typ: typeof[string]().idx
|
||||
attrs: [
|
||||
VAttribute{
|
||||
name: 'unique'
|
||||
|
@ -241,8 +241,8 @@ fn test_orm_table_gen() {
|
|||
]
|
||||
},
|
||||
orm.TableField{
|
||||
name: 'abc'
|
||||
typ: typeof[i64]().idx
|
||||
name: 'abc'
|
||||
typ: typeof[i64]().idx
|
||||
default_val: '6754'
|
||||
},
|
||||
], sql_type_from_v, false) or { panic(err) }
|
||||
|
@ -250,46 +250,46 @@ fn test_orm_table_gen() {
|
|||
|
||||
mult_unique_query := orm.orm_table_gen('test_table', "'", true, 0, [
|
||||
orm.TableField{
|
||||
name: 'id'
|
||||
typ: typeof[int]().idx
|
||||
nullable: true
|
||||
name: 'id'
|
||||
typ: typeof[int]().idx
|
||||
nullable: true
|
||||
default_val: '10'
|
||||
attrs: [
|
||||
attrs: [
|
||||
VAttribute{
|
||||
name: 'primary'
|
||||
},
|
||||
VAttribute{
|
||||
name: 'sql'
|
||||
name: 'sql'
|
||||
has_arg: true
|
||||
arg: 'serial'
|
||||
kind: .plain
|
||||
arg: 'serial'
|
||||
kind: .plain
|
||||
},
|
||||
]
|
||||
},
|
||||
orm.TableField{
|
||||
name: 'test'
|
||||
typ: typeof[string]().idx
|
||||
name: 'test'
|
||||
typ: typeof[string]().idx
|
||||
nullable: true
|
||||
attrs: [
|
||||
attrs: [
|
||||
VAttribute{
|
||||
name: 'unique'
|
||||
name: 'unique'
|
||||
has_arg: true
|
||||
arg: 'test'
|
||||
kind: .string
|
||||
arg: 'test'
|
||||
kind: .string
|
||||
},
|
||||
]
|
||||
},
|
||||
orm.TableField{
|
||||
name: 'abc'
|
||||
typ: typeof[i64]().idx
|
||||
nullable: true
|
||||
name: 'abc'
|
||||
typ: typeof[i64]().idx
|
||||
nullable: true
|
||||
default_val: '6754'
|
||||
attrs: [
|
||||
attrs: [
|
||||
VAttribute{
|
||||
name: 'unique'
|
||||
name: 'unique'
|
||||
has_arg: true
|
||||
arg: 'test'
|
||||
kind: .string
|
||||
arg: 'test'
|
||||
kind: .string
|
||||
},
|
||||
]
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue