queryMaker method
PostgrestFilterBuilder
queryMaker()
Implementation
PostgrestFilterBuilder queryMaker(
String column, OperType operType, dynamic value, PostgrestFilterBuilder filterBuilder) {
logger.fine('queryMaker : $column $operType, $value');
switch (operType) {
case OperType.isEqualTo:
if (value is bool) {
//print('This is boolean type ------------------------------');
return filterBuilder.eq(column, value ? 'true' : 'false');
}
return filterBuilder.eq(column, value);
case OperType.isGreaterThan:
return filterBuilder.gt(column, value);
case OperType.isGreaterThanOrEqualTo:
return filterBuilder.gte(column, value);
case OperType.isLessThan:
return filterBuilder.lt(column, value);
case OperType.isLessThanOrEqualTo:
return filterBuilder.lte(column, value);
case OperType.isNotEqualTo:
return filterBuilder.neq(column, value);
case OperType.arrayContains: //cs : contains
List data = [];
if (value is List<String>) {
data = value;
//print('string type case-------------list:$data');
} else if (value is String) {
//print('list type case-------------list:$data');
//data = jsonStringToList(value);
data = value.split(',');
}
List<String> tempList = data.map((item) => '"$item"').toList();
String filterString = '{${tempList.join(',')}}'; // Supabase에서는 {}가 리스트를 의미하므로 묶어 주어야 합니다.
//print('---------filterString : $filterString');
return filterBuilder.filter(column, "cs", filterString);
case OperType.arrayContainsAny: // ov : overlap
List data = [];
if (value is List<String>) {
data = value;
//print('string type case-------------list:$data');
} else if (value is String) {
//print('list type case-------------list:$data');
//data = jsonStringToList(value);
data = value.split(',');
}
List<String> tempList = data.map((item) => '"$item"').toList();
String filterString = '{${tempList.join(',')}}'; // Supabase에서는 {}가 리스트를 의미하므로 묶어 주어야 합니다.
//print('---------filterString : $filterString');
return filterBuilder.filter(column, "ov", filterString);
case OperType.whereIn:
List data = [];
if (value is List<String>) {
data = value;
//print('string type case-------------list:$data');
} else if (value is String) {
//data = jsonStringToList(value);
data = value.split(',');
//print('list type case-------------list:$data');
}
//print('*******************QUERY---------------$column whereIn $data');
return filterBuilder.inFilter(column, data);
case OperType.whereNotIn:
return filterBuilder.not(column, "in", value);
case OperType.isNull:
return filterBuilder.isFilter(column, null);
case OperType.textSearch:
return filterBuilder.textSearch(column, value);
}
//return filterBuilder;
}