by hadcomplained · 6y ago · 0 comments
Q("""select 1 from {otherQuery}""")
What does the following code enable that the code above cannot do? Q(lambda: f"""select 1 from {otherQuery}""") function Q(stringBits: string[]): Query {
for (bit in stringBits) {
if (bit is string) {
add to sql
} else if (bit is Query) {
add bit to dependencies
add bit.name to sql
}
}
}
But this cannot be done currently in Python (see PEP-501), so I'm forcing the user to pass a lambda, which I can get the AST of, with which I can implement the machinery to do the above.Suggestions for improvements are welcome!