wrap static method
Wraps the given object name with the specified quote character. If the quote character is not provided and the database provider is specified, it uses the appropriate quote character. Otherwise, it uses the defaultQuoteChar.
Implementation
static wrap(String objectName, [dynamic quoteChar, String dataBaseProvider = ""]) {
if (quoteChar is bool) {
if (quoteChar == false) {
return objectName;
} else {
quoteChar = null;
}
}
quoteChar ??= SqlUtil.quoteCharFromProvider(dataBaseProvider);
if (quoteChar is List) {
quoteChar = quoteChar.map((x) => flatString(x));
} else if (quoteChar != null && quoteChar is! String) {
quoteChar = flatString(quoteChar);
}
if (quoteChar is String) {
quoteChar = [quoteChar];
}
if (quoteChar is List && quoteChar.isNotEmpty) {
var oq = quoteChar.firstOrNull ?? SqlUtil.quoteCharFromProvider(dataBaseProvider);
var cq = quoteChar.skip(1).lastOrNull;
return objectName.wrap(flatString(oq), flatString(cq));
} else {
return objectName;
}
}