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

all: introduce isize and usize (#11437)

This commit is contained in:
Enzo
2021-09-08 04:53:39 +02:00
committed by GitHub
parent 577fedfce1
commit cc8ee5fb84
13 changed files with 213 additions and 130 deletions

View File

@ -1,26 +1,38 @@
module orm
import time
import v.ast
pub const (
num64 = [8, 12]
nums = [5, 6, 7, 9, 10, 11, 16]
float = [13, 14]
string = 18
num64 = [ast.i64_type_idx, ast.u64_type_idx]
nums = [
ast.i8_type_idx,
ast.i16_type_idx,
ast.int_type_idx,
ast.byte_type_idx,
ast.u16_type_idx,
ast.u32_type_idx,
ast.bool_type_idx,
]
float = [
ast.f32_type_idx,
ast.f64_type_idx,
]
string = ast.string_type_idx
time = -2
type_idx = {
'i8': 5
'i16': 6
'int': 7
'i64': 8
'byte': 9
'u16': 10
'u32': 11
'u64': 12
'f32': 13
'f64': 14
'bool': 16
'string': 18
'i8': ast.i8_type_idx
'i16': ast.i16_type_idx
'int': ast.int_type_idx
'i64': ast.i64_type_idx
'byte': ast.byte_type_idx
'u16': ast.u16_type_idx
'u32': ast.u32_type_idx
'u64': ast.u64_type_idx
'f32': ast.f32_type_idx
'f64': ast.f64_type_idx
'bool': ast.bool_type_idx
'string': ast.string_type_idx
}
string_max_len = 2048
)

View File

@ -1,4 +1,5 @@
import orm
import v.ast
fn test_orm_stmt_gen_update() {
query := orm.orm_stmt_gen('Test', "'", .update, true, '?', 0, orm.QueryData{
@ -120,7 +121,7 @@ fn test_orm_table_gen() {
query := orm.orm_table_gen('test_table', "'", true, 0, [
orm.TableField{
name: 'id'
typ: 7
typ: ast.int_type_idx
default_val: '10'
attrs: [
StructAttribute{
@ -136,11 +137,11 @@ fn test_orm_table_gen() {
},
orm.TableField{
name: 'test'
typ: 18
typ: ast.string_type_idx
},
orm.TableField{
name: 'abc'
typ: 8
typ: ast.i64_type_idx
default_val: '6754'
},
], sql_type_from_v, false) or { panic(err) }
@ -149,7 +150,7 @@ fn test_orm_table_gen() {
alt_query := orm.orm_table_gen('test_table', "'", true, 0, [
orm.TableField{
name: 'id'
typ: 7
typ: ast.int_type_idx
default_val: '10'
attrs: [
StructAttribute{
@ -165,11 +166,11 @@ fn test_orm_table_gen() {
},
orm.TableField{
name: 'test'
typ: 18
typ: ast.string_type_idx
},
orm.TableField{
name: 'abc'
typ: 8
typ: ast.i64_type_idx
default_val: '6754'
},
], sql_type_from_v, true) or { panic(err) }
@ -178,7 +179,7 @@ fn test_orm_table_gen() {
unique_query := orm.orm_table_gen('test_table', "'", true, 0, [
orm.TableField{
name: 'id'
typ: 7
typ: ast.int_type_idx
default_val: '10'
attrs: [
StructAttribute{
@ -194,7 +195,7 @@ fn test_orm_table_gen() {
},
orm.TableField{
name: 'test'
typ: 18
typ: ast.string_type_idx
attrs: [
StructAttribute{
name: 'unique'
@ -203,7 +204,7 @@ fn test_orm_table_gen() {
},
orm.TableField{
name: 'abc'
typ: 8
typ: ast.i64_type_idx
default_val: '6754'
},
], sql_type_from_v, false) or { panic(err) }
@ -212,7 +213,7 @@ fn test_orm_table_gen() {
mult_unique_query := orm.orm_table_gen('test_table', "'", true, 0, [
orm.TableField{
name: 'id'
typ: 7
typ: ast.int_type_idx
default_val: '10'
attrs: [
StructAttribute{
@ -228,7 +229,7 @@ fn test_orm_table_gen() {
},
orm.TableField{
name: 'test'
typ: 18
typ: ast.string_type_idx
attrs: [
StructAttribute{
name: 'unique'
@ -240,7 +241,7 @@ fn test_orm_table_gen() {
},
orm.TableField{
name: 'abc'
typ: 8
typ: ast.i64_type_idx
default_val: '6754'
attrs: [
StructAttribute{