Open
Description
While working with DateOnly and TimeOnly support I realized that the ObjectToSQLString method of ILiteralType is quite problematic.
AbstractStringType:
"'" + (string)value + "'"
- SQL injection
- No N-prefix for unicode (required in SQL server when the string is outside ANSI)
AbstractCharType:
'\'' + value.ToString() + '\''
- SQL injection
- No N-prefix for unicode (required in SQL server when the string is outside ANSI)
AbstractDateTimeType:
"'" + (DateTime) value + "'"
- No guarantee that the stringified DateTime will be a supported datetime syntax
DateTimeOffsetType:
"'" + ((DateTimeOffset) value) + "'"
- No guarantee that the stringified DateTimeOffset will be a supported datetimeoffset syntax
DateType:
"\'" + ((DateTime)value).ToShortDateString() + "\'"
- No guarantee that the stringified DateTime will be a supported datetime syntax
DecimalType:
value.ToString()
- Could very well be a decimal with the wrong kind of decimal separator
And there are more.
Since the method has access to the dialect, maybe more formatting should be moved there.
Metadata
Metadata
Assignees
Labels
No labels