-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add typed sql parameter helpers #9
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
fjakobs
left a comment
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.
Looks good. Let's just make sure that the encoding for binary parameters is correct.
| .join(""); | ||
| } else if (value instanceof ArrayBuffer) { | ||
| binaryValue = Array.from(new Uint8Array(value)) | ||
| .map((b) => b.toString(16).padStart(2, "0").toUpperCase()) |
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.
Did you test sending binary data. Would like to have confidence that we are encoding the data properly.
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.
Improved the tests and added a new interactive demo showing the features + doing a real SQL test on the dev-playground.
Summary
Add sql.* helpers for type-safe SQL query parameters. Solves the problem of agents struggling to parameterize SQL and properly cast values.
Helpers
sql.date()- Date objects or ISO strings → YYYY-MM-DDsql.timestamp()- Date, ISO string, or Unix timestampsql.string()- String, number, or booleansql.number()- Number or numeric stringsql.boolean()- Boolean, string ("true"/"false"), or number (0/1)sql.binary()- Uint8Array, ArrayBuffer, or hex-encoded stringUsage
Notes