Skip to content

Commit b4a04d7

Browse files
committed
VARCHAR(MAX) for params in mssql
1 parent f3f1440 commit b4a04d7

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ and to create JSON APIs.
131131
#### Other sql syntax enhancements
132132

133133
- SQLPage now supports the custom `CONVERT` expression syntax for MS SQL Server, and the one for MySQL.
134-
- SQLPage now supports the `VARCHAR(MAX)` type in MS SQL Server.
134+
- 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).
135135
- `INSERT INTO ... DEFAULT VALUES ...` is now supported
136136

137137
### Other news

src/webserver/database/sql.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,7 @@ impl ParameterExtractor {
274274
let data_type = match self.db_kind {
275275
// MySQL requires CAST(? AS CHAR) and does not understand CAST(? AS TEXT)
276276
AnyKind::MySql => DataType::Char(None),
277-
AnyKind::Mssql => DataType::Varchar(Some(CharacterLength::IntegerLength {
278-
length: 8000,
279-
unit: None,
280-
})),
277+
AnyKind::Mssql => DataType::Varchar(Some(CharacterLength::Max)),
281278
_ => DataType::Text,
282279
};
283280
let value = Expr::Value(Value::Placeholder(name));
@@ -664,7 +661,7 @@ mod test {
664661
let parameters = ParameterExtractor::extract_parameters(&mut ast, AnyKind::Mssql);
665662
assert_eq!(
666663
ast.to_string(),
667-
"SELECT CONCAT('', CAST(@p1 AS VARCHAR(8000))) FROM [a schema].[a table]"
664+
"SELECT CONCAT('', CAST(@p1 AS VARCHAR(MAX))) FROM [a schema].[a table]"
668665
);
669666
assert_eq!(parameters, [StmtParam::GetOrPost("1".to_string()),]);
670667
}

0 commit comments

Comments
 (0)