Created
February 25, 2020 18:30
-
-
Save reidev275/4b0541d17b2c1fccfdd87099766e5e79 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const interpretToSql = <A>(dsl: Filter<A>): string => { | |
switch (dsl.kind) { | |
case "Equals": | |
return `[${dsl.field}] = '${dsl.val}'`; | |
case "Greater": | |
return `[${dsl.field}] > '${dsl.val}'`; | |
case "Less": | |
return `[${dsl.field}] < '${dsl.val}'`; | |
case "And": | |
return `(${interpretToSql(dsl.a)} and ${interpretToSql(dsl.b)})`; | |
case "Or": | |
return `(${interpretToSql(dsl.a)} or ${interpretToSql(dsl.b)})`; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment