mirror of
https://github.com/vlang/v.git
synced 2025-08-04 02:07:28 -04:00
db.mysql: use mysql datatype for alloc string_binds_map, not orm's (#24126)
This commit is contained in:
parent
567a7d9d67
commit
01a954310e
@ -203,10 +203,9 @@ fn test_mysql_orm() {
|
|||||||
}!
|
}!
|
||||||
|
|
||||||
assert results[0].created_at == model.created_at
|
assert results[0].created_at == model.created_at
|
||||||
// TODO: investigate why these fail with V 0.4.0 11a8a46 , and fix them:
|
assert results[0].username == model.username
|
||||||
// assert results[0].username == model.username
|
assert results[0].updated_at == model.updated_at
|
||||||
// assert results[0].updated_at == model.updated_at
|
assert results[0].deleted_at == model.deleted_at
|
||||||
// assert results[0].deleted_at == model.deleted_at
|
|
||||||
|
|
||||||
/** test default attribute
|
/** test default attribute
|
||||||
*/
|
*/
|
||||||
|
@ -21,7 +21,7 @@ pub fn (db DB) select(config orm.SelectConfig, data orm.QueryData, where orm.Que
|
|||||||
metadata := stmt.gen_metadata()
|
metadata := stmt.gen_metadata()
|
||||||
fields := stmt.fetch_fields(metadata)
|
fields := stmt.fetch_fields(metadata)
|
||||||
num_fields := stmt.get_field_count()
|
num_fields := stmt.get_field_count()
|
||||||
mut data_pointers := []&u8{}
|
mut data_pointers := []&u8{cap: int(num_fields)}
|
||||||
|
|
||||||
// Allocate memory for each column.
|
// Allocate memory for each column.
|
||||||
for i in 0 .. num_fields {
|
for i in 0 .. num_fields {
|
||||||
@ -71,25 +71,18 @@ pub fn (db DB) select(config orm.SelectConfig, data orm.QueryData, where orm.Que
|
|||||||
field_type := unsafe { FieldType(field.type) }
|
field_type := unsafe { FieldType(field.type) }
|
||||||
field_types << field_type
|
field_types << field_type
|
||||||
|
|
||||||
match types[i] {
|
match field_type {
|
||||||
orm.type_string {
|
.type_string, .type_var_string, .type_blob, .type_tiny_blob, .type_medium_blob,
|
||||||
|
.type_long_blob {
|
||||||
string_binds_map[i] = mysql_bind
|
string_binds_map[i] = mysql_bind
|
||||||
}
|
}
|
||||||
orm.time_ {
|
.type_long {
|
||||||
match field_type {
|
mysql_bind.buffer_type = C.MYSQL_TYPE_LONG
|
||||||
.type_long {
|
}
|
||||||
mysql_bind.buffer_type = C.MYSQL_TYPE_LONG
|
.type_time, .type_date, .type_datetime, .type_timestamp {
|
||||||
}
|
// FIXME: Allocate memory for blobs dynamically.
|
||||||
.type_time, .type_date, .type_datetime, .type_timestamp {
|
mysql_bind.buffer_type = C.MYSQL_TYPE_BLOB
|
||||||
// FIXME: Allocate memory for blobs dynamically.
|
mysql_bind.buffer_length = FieldType.type_blob.get_len()
|
||||||
mysql_bind.buffer_type = C.MYSQL_TYPE_BLOB
|
|
||||||
mysql_bind.buffer_length = FieldType.type_blob.get_len()
|
|
||||||
}
|
|
||||||
.type_string, .type_blob {}
|
|
||||||
else {
|
|
||||||
return error('Unknown type ${field.type}')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {}
|
else {}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user