Skip to content

Commit

Permalink
use nulltype condition in nulltype check when inserting
Browse files Browse the repository at this point in the history
  • Loading branch information
lmcmicu committed Dec 1, 2023
1 parent 3984a72 commit 2249fd4
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2556,7 +2556,16 @@ pub async fn insert_new_row_tx(
let value = cell.get("value").and_then(|v| v.as_str()).ok_or(SqlxCErr(
format!("No string named 'value' in {:?}", cell).into(),
))?;
let nulltype = cell.get("nulltype");
let nulltype = cell.get("nulltype").and_then(|n| n.as_str());
let nulltype_condition = match nulltype {
None => None,
Some(nulltype) => Some(
compiled_datatype_conditions
.get(&nulltype.to_string())
.and_then(|cc| Some(&cc.compiled))
.unwrap(),
),
};
let messages = sort_messages(
&sorted_datatypes,
cell.get("messages")
Expand Down Expand Up @@ -2586,7 +2595,7 @@ pub async fn insert_new_row_tx(
}

match nulltype {
Some(nulltype) if nulltype == "empty" && value == "" => {
Some(_) if nulltype_condition.unwrap()(value) => {
insert_values.push(String::from("NULL"));
}
_ => {
Expand Down

0 comments on commit 2249fd4

Please sign in to comment.