You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
module main
import db.mysql
import time
import orm
fn db_mysql() !mysql.DB {
mut mysql_config := mysql.Config{
host: 'mysql2.sqlpub.com'
port: 3307
username: 'vcore_test'
password: 'wfo8wS7CylT0qIMg'
dbname: 'vcore_test'
}
mut conn := mysql.connect(mysql_config) or { return err }
return conn
}
@[table: 'sys_users']
struct User {
pub:
id string @[immutable; primary; sql: 'id'; sql_type: 'VARCHAR(255)'; unique]
name string @[immutable; sql: 'username'; sql_type: 'VARCHAR(255)'; unique]
created_at ?time.Time @[omitempty; sql_type: 'TIMESTAMP']
updated_at time.Time @[default: '0001-01-01T00:00:00 +00:00'; omitempty; sql_type: 'TIMESTAMP']
}
fn main() {
mut db := db_mysql() or { panic('failed to connect to database') }
defer { db.close() }
mut result := sql db {
select from User
} or { panic(err) }
dump(result)
mut qb := orm.new_query[User](db)
result1 := qb.select('id', 'username')!.query()!
dump(result1)
}
Expected Behavior
success
Current Behavior
V panic: as cast: cannot cast orm.Null to string
v hash: 3b4c016
/tmp/v_1000/orm.01JRVGQJH83TA5PGMBGH7MTE7A.tmp.c:6880: at _v_panic: Backtrace
/tmp/v_1000/orm.01JRVGQJH83TA5PGMBGH7MTE7A.tmp.c:7272: by __as_cast
/tmp/v_1000/orm.01JRVGQJH83TA5PGMBGH7MTE7A.tmp.c:11887: by orm__QueryBuilder_T_main__User_map_row_T_main__User
/tmp/v_1000/orm.01JRVGQJH83TA5PGMBGH7MTE7A.tmp.c:12161: by orm__QueryBuilder_T_main__User_query_T_main__User
/tmp/v_1000/orm.01JRVGQJH83TA5PGMBGH7MTE7A.tmp.c:14849: by main__main
/tmp/v_1000/orm.01JRVGQJH83TA5PGMBGH7MTE7A.tmp.c:14987: by main
Describe the bug
The required field database is null, v panic
Reproduction Steps
Expected Behavior
success
Current Behavior
V panic: as cast: cannot cast
orm.Null
tostring
v hash: 3b4c016
/tmp/v_1000/orm.01JRVGQJH83TA5PGMBGH7MTE7A.tmp.c:6880: at _v_panic: Backtrace
/tmp/v_1000/orm.01JRVGQJH83TA5PGMBGH7MTE7A.tmp.c:7272: by __as_cast
/tmp/v_1000/orm.01JRVGQJH83TA5PGMBGH7MTE7A.tmp.c:11887: by orm__QueryBuilder_T_main__User_map_row_T_main__User
/tmp/v_1000/orm.01JRVGQJH83TA5PGMBGH7MTE7A.tmp.c:12161: by orm__QueryBuilder_T_main__User_query_T_main__User
/tmp/v_1000/orm.01JRVGQJH83TA5PGMBGH7MTE7A.tmp.c:14849: by main__main
/tmp/v_1000/orm.01JRVGQJH83TA5PGMBGH7MTE7A.tmp.c:14987: by main
Possible Solution
No response
Additional Information/Context
No response
V version
V 0.4.10 3b4c016
Environment details (OS name and version, etc.)
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
The text was updated successfully, but these errors were encountered: