使用以下变量将 OData 过滤器解析为 SQL 过滤器
%var odataFilterToSQLFilter = (odataFilter) ->
(( odataFilter replace "eq null" with "is null"
replace "ne null" with "is not null"
replace " eq " with " = "
replace " ne " with " != "
replace " gt " with " > "
replace " lt " with " < "
replace " ge " with " >= "
replace " le " with " <= "
replace " and " with " AND "
replace " or " with " OR " ) splitBy " " map (
("TO_DATE('" ++ (($ replace "datetime'" with "" ) replace "T" with " ") ++ ",'yyyy-MM-dd HH24:MI:SS')") when $ as :string contains "datetime" otherwise $
)) joinBy " "
%var toSQLWhere = (odataFilter) -> (" WHERE " ++ odataFilterToSQLFilter(odataFilter)) unless odataFilter == null otherwise ""
---
"SELECT " ++ generateSqlFields(filters.select) ++ " FROM $remoteEntityName"
++ (
(toSQLWhere(filters.filter))