asSelectWhereCommand method
Generates a SELECT command with a WHERE clause for the given table name and column names.
The tableName
parameter specifies the name of the table to select from.
The columns
parameter specifies the list of column names to select.
The nullAsBlank
parameter determines whether null values should be treated as blank strings.
The quoteChar
parameter specifies the character used for quoting identifiers.
The dataBaseProvider
parameter specifies the database provider.
The and
parameter determines whether to use "AND" or "OR" in the WHERE clause.
Returns the generated SELECT command as a string.
Implementation
String asSelectWhereCommand({
required String tableName,
List<String> columns = const [],
bool nullAsBlank = false,
dynamic quoteChar,
String dataBaseProvider = "",
bool and = true,
}) {
String whereClause = asWhereClausule(
nullAsBlank: nullAsBlank,
quoteChar: quoteChar,
dataBaseProvider: dataBaseProvider,
and: and,
);
String columnString = SqlUtil.columnsFromList(
items: columns,
quoteChar: quoteChar,
dataBaseProvider: dataBaseProvider,
).ifBlank("*");
return 'SELECT $columnString FROM ${SqlUtil.wrap(tableName, quoteChar, dataBaseProvider)} WHERE $whereClause;';
}