Consider reducing whitespaces of Sql.query
trungdo-epi opened this issue · 3 comments
I usually write multiple lines queries like
Sql.connect str
|> Sql.query """
update xx
set a = x,
b = y
"""
I think it would be fine to reduce whitespaces of the query. Maybe we can use Regex.Replace(sql, @"\s+", " ")
.
Hi there @trungdo-epi, why do you want to trim the whitespace? It could result in a bad query. This is something that you can do from your application and not so much from the library like this
let cleanQuery (input: string) = Regex.Replace(input, @"\s+", " ")
let sql = cleanQuery """
update xx
set a = x,
b = y
"""
connectionString
|> Sql.connect
|> Sql.query sql
I want to trim whitespaces because I think it would reduce the amount of data transferred to the database. I guess I should do that in application code. Thanks.
Btw: I think the trimming is safe because it affects only sql commands, not user input, as we always use parameterized query.
I think it would reduce the amount of data transferred to the database
Unless you are sending huge queries with megabytes of text, this wouldn't improve anything significantly. Of course, that is up to you decide 😉