Alternative method to provide dynamic arguments into sql query #28
No reviewers
Labels
No Label
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Limework/skript-db#28
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "szumielxd/skript-db:master"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Sometimes you want to create a query with dynamic content. For now, you're limited to using
unsafe
keyword, but as name states it isn't safe.So... Here's simple idea to provide query arguments directly as object array. Maybe not 100% foolproof, but in my opinion much better option than self-made sanitization of input.
Some examples:
hey, sorry for noticing this so late, I like the idea, once I find time to test it, I will merge if it works ok.
"with arguments" seems to be only working if the arguments are variables, not if submitting the value directly, but other than that it's working :)
another interesting issue: when using UUID datatype in the database (PostgreSQL) and putting variable containing uuid of player in the arguments:
execute unsafe "UPDATE userprofile SET emeralds = ? where UUID = ?" in {-sql} with arguments {-test::*}
it gives error:
but it can be fixed by changing ? to UUID(?) so it's explicitly casted as UUID.
but this is not an issue if using '%uuid of player%' in the query directly, maybe this is how it should be, given that it is trying to avoid SQL query injection.
I will test a bit more to be sure all is right, but these issues are not critical and given that the pull request fixes another important issue, I think I will release with this.