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

orm: declare missing functions to handle literal types (#16627)

This commit is contained in:
Felipe Pena 2022-12-09 15:34:34 -03:00 committed by GitHub
parent b6c2aab092
commit 1ba1f99b9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 0 deletions

View File

@ -137,6 +137,7 @@ const (
'vlib/crypto/rand/crypto_rand_read_test.v', 'vlib/crypto/rand/crypto_rand_read_test.v',
'vlib/net/smtp/smtp_test.v', 'vlib/net/smtp/smtp_test.v',
'vlib/v/tests/websocket_logger_interface_should_compile_test.v', 'vlib/v/tests/websocket_logger_interface_should_compile_test.v',
'vlib/v/tests/fn_literal_type_test.v',
] ]
skip_with_fsanitize_address = [ skip_with_fsanitize_address = [
'vlib/net/websocket/websocket_test.v', 'vlib/net/websocket/websocket_test.v',
@ -189,6 +190,7 @@ const (
'vlib/builtin/js/array_test.js.v', 'vlib/builtin/js/array_test.js.v',
'vlib/net/smtp/smtp_test.v', 'vlib/net/smtp/smtp_test.v',
'vlib/v/tests/websocket_logger_interface_should_compile_test.v', 'vlib/v/tests/websocket_logger_interface_should_compile_test.v',
'vlib/v/tests/fn_literal_type_test.v',
] ]
skip_on_linux = [ skip_on_linux = [
'do_not_remove', 'do_not_remove',
@ -224,6 +226,7 @@ const (
'vlib/sync/many_times_test.v', 'vlib/sync/many_times_test.v',
'vlib/sync/once_test.v', 'vlib/sync/once_test.v',
'vlib/v/tests/websocket_logger_interface_should_compile_test.v', 'vlib/v/tests/websocket_logger_interface_should_compile_test.v',
'vlib/v/tests/fn_literal_type_test.v',
] ]
skip_on_non_windows = [ skip_on_non_windows = [
'do_not_remove', 'do_not_remove',

View File

@ -562,6 +562,16 @@ pub fn int_to_primitive(b int) Primitive {
return Primitive(b) return Primitive(b)
} }
// int_literal_to_primitive handles int literal value
pub fn int_literal_to_primitive(b int) Primitive {
return Primitive(b)
}
// float_literal_to_primitive handles float literal value
pub fn float_literal_to_primitive(b f64) Primitive {
return Primitive(b)
}
pub fn i64_to_primitive(b i64) Primitive { pub fn i64_to_primitive(b i64) Primitive {
return Primitive(b) return Primitive(b)
} }

View File

@ -0,0 +1,36 @@
import sqlite
[table: 'Users']
struct User {
id int [primary; sql: serial]
name string
}
const (
const_users_offset = 1
const_users_offset2 = 1
)
fn test_orm() {
db := sqlite.connect(':memory:') or { panic(err) }
upper_1 := User{
name: 'Test'
}
upper_2 := User{
name: 'Test2'
}
sql db {
create table User
insert upper_1 into User
insert upper_2 into User
} or { panic(err) }
result := sql db {
select from User limit const_users_offset2
} or { panic(err) }
assert result[0].name == 'Test'
}