VARCHAR(MAX) for params in mssql

This commit is contained in:
lovasoa
2023-11-28 00:33:38 +01:00
parent f3f1440e9c
commit b4a04d7675
2 changed files with 3 additions and 6 deletions
+1 -1
View File
@@ -131,7 +131,7 @@ and to create JSON APIs.
#### Other sql syntax enhancements
- SQLPage now supports the custom `CONVERT` expression syntax for MS SQL Server, and the one for MySQL.
- SQLPage now supports the `VARCHAR(MAX)` type in MS SQL Server.
- SQLPage now supports the `VARCHAR(MAX)` type in MS SQL Server and uses it for all variables bound as parameters to your SQL queries (we used to use `VARCHAR(8000)` before).
- `INSERT INTO ... DEFAULT VALUES ...` is now supported
### Other news
+2 -5
View File
@@ -274,10 +274,7 @@ impl ParameterExtractor {
let data_type = match self.db_kind {
// MySQL requires CAST(? AS CHAR) and does not understand CAST(? AS TEXT)
AnyKind::MySql => DataType::Char(None),
AnyKind::Mssql => DataType::Varchar(Some(CharacterLength::IntegerLength {
length: 8000,
unit: None,
})),
AnyKind::Mssql => DataType::Varchar(Some(CharacterLength::Max)),
_ => DataType::Text,
};
let value = Expr::Value(Value::Placeholder(name));
@@ -664,7 +661,7 @@ mod test {
let parameters = ParameterExtractor::extract_parameters(&mut ast, AnyKind::Mssql);
assert_eq!(
ast.to_string(),
"SELECT CONCAT('', CAST(@p1 AS VARCHAR(8000))) FROM [a schema].[a table]"
"SELECT CONCAT('', CAST(@p1 AS VARCHAR(MAX))) FROM [a schema].[a table]"
);
assert_eq!(parameters, [StmtParam::GetOrPost("1".to_string()),]);
}