-
Notifications
You must be signed in to change notification settings - Fork 21
Add custom sql functions #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ojects/nims/ormin/tests/tcommon.nim
| Function(name: "length", arity: 1, typ: dbInt), | ||
| Function(name: "lower", arity: 1, typ: dbVarchar), | ||
| Function(name: "upper", arity: 1, typ: dbVarchar), | ||
| Function(name: "replace", arity: 3, typ: dbVarchar) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be nice to upgrade these at some point to also support type checking the args. But alas, not today.
| macro importSql*(n: typed): untyped = | ||
| ## Registers a Nim proc as callable SQL function within the query DSL. | ||
| if n.kind notin {nnkProcDef, nnkFuncDef}: | ||
| macros.error("{.importSql.} can only be applied to proc or func definitions", n) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used GPT5-Codex-High for this. Seems to have done a good job. It checked for conditions I wouldn't have thought to check. I had to cleanup a little bit in the tests.
Adds basic support for custom sql functions using
importSqlpragma: