sea-orm icon indicating copy to clipboard operation
sea-orm copied to clipboard

JsonValue Type Does Not Match SQL Type.

Open Jungle666 opened this issue 11 months ago • 0 comments

There is a table define:

CREATE TABLE `demo` ( 
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`char_col` varchar(20) DEFAULT NULL ,
`text_col` text  DEFAULT NULL ,
 PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4
)

Then insert data:

insert into demo (null,"1234","1234");
insert into demo (null,"aabbcc","aabbcc");

There is The sea-orm Query Code:

    let list = JsonValue::find_by_statement(Statement::from_sql_and_values(DbBackend::MySql,"select * from demo", []))
            .all(db)
            .await
            .context(DbSnafu)?;

Then we found that the list<JsonValue>:

[{
"id":1,
"char_col": "1234",
"text_col": 1234
},
{
"id":2,
"char_col": "1234",
"text_col": "aabbcc"
}
]

The Question is :

Why first row data text_col is a number type,then second text_col row data is String, How can i fix it?

Jungle666 avatar Nov 19 '24 04:11 Jungle666