diff --git a/vlib/db/mysql/mysql_orm_test.v b/vlib/db/mysql/mysql_orm_test.v index 2bc199fca7..a0e89f00c4 100644 --- a/vlib/db/mysql/mysql_orm_test.v +++ b/vlib/db/mysql/mysql_orm_test.v @@ -203,10 +203,9 @@ fn test_mysql_orm() { }! 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].updated_at == model.updated_at - // assert results[0].deleted_at == model.deleted_at + assert results[0].username == model.username + assert results[0].updated_at == model.updated_at + assert results[0].deleted_at == model.deleted_at /** test default attribute */ diff --git a/vlib/db/mysql/orm.c.v b/vlib/db/mysql/orm.c.v index ab7c6b54c0..fc01bdc56e 100644 --- a/vlib/db/mysql/orm.c.v +++ b/vlib/db/mysql/orm.c.v @@ -21,7 +21,7 @@ pub fn (db DB) select(config orm.SelectConfig, data orm.QueryData, where orm.Que metadata := stmt.gen_metadata() fields := stmt.fetch_fields(metadata) num_fields := stmt.get_field_count() - mut data_pointers := []&u8{} + mut data_pointers := []&u8{cap: int(num_fields)} // Allocate memory for each column. 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_types << field_type - match types[i] { - orm.type_string { + match field_type { + .type_string, .type_var_string, .type_blob, .type_tiny_blob, .type_medium_blob, + .type_long_blob { string_binds_map[i] = mysql_bind } - orm.time_ { - match field_type { - .type_long { - mysql_bind.buffer_type = C.MYSQL_TYPE_LONG - } - .type_time, .type_date, .type_datetime, .type_timestamp { - // FIXME: Allocate memory for blobs dynamically. - 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}') - } - } + .type_long { + mysql_bind.buffer_type = C.MYSQL_TYPE_LONG + } + .type_time, .type_date, .type_datetime, .type_timestamp { + // FIXME: Allocate memory for blobs dynamically. + mysql_bind.buffer_type = C.MYSQL_TYPE_BLOB + mysql_bind.buffer_length = FieldType.type_blob.get_len() } else {} }