generated from WebAssembly/wasi-proposal-template
-
Notifications
You must be signed in to change notification settings - Fork 6
updated sql.wit.md, and README.md #2
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
eb9f5a3
commenting out wit-abi 'cause of worlds
danbugs d76b956
updated README up until before TOC
danbugs ef919c2
updated sql.wit.md file according to discussions w/ @itowlson
danbugs 4eaf3a4
forgot to add title to README
danbugs 752f298
added wit label on worlds code block
danbugs 5196c3a
fixing quick typo
danbugs 57fefb5
typo
danbugs 88383c3
added null type to data-types
danbugs 716ccbe
added unsigned/signed short and longs
danbugs f224767
typos in sql.wit.md, andmostly completed README
danbugs df15d39
fixed typo, some renames, and updated examples
danbugs 0e3a266
change stream to list
danbugs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# `wasi-sql` API | ||
|
||
## Interfaces | ||
|
||
```wit | ||
interface "wasi:sql" { | ||
// one single row item | ||
record row { | ||
field-name: string, | ||
value: data-type, | ||
} | ||
|
||
// common data types | ||
variant data-type { | ||
int32(s32), | ||
int64(s64), | ||
uint32(u32), | ||
uint64(u64), | ||
float(float64), | ||
double(float64), | ||
str(string), | ||
boolean(bool), | ||
date(string), | ||
time(string), | ||
timestamp(string), | ||
binary(list<u8>), | ||
null | ||
} | ||
|
||
// allows parameterized queries | ||
resource statement { | ||
// e.g., create("SELECT * FROM users WHERE name = ? AND age = ?", vec!["John Doe", "32"]) | ||
prepare: func(query: string, params: list<string>) -> result<statement, sql-error> | ||
} | ||
|
||
// query is optimized for querying data, and | ||
// implementors can make use of that fact to optimize | ||
// the performance of query execution (e.g., using | ||
// indexes). | ||
query: func(q: statement) -> result<list<row>, sql-error> | ||
|
||
// exec is for modifying data in the database. | ||
exec: func(q: statement) -> result<_, sql-error> | ||
|
||
// common error types | ||
variant sql-error { | ||
syntax-error(string), | ||
constraint-violation(string), | ||
access-violation(string), | ||
unexpected-error(string) | ||
} | ||
} | ||
``` | ||
|
||
## Worlds | ||
|
||
```wit | ||
world "wasi:sql/http-sql" { | ||
import sql: "wasi:sql" | ||
|
||
export handle-create: "wasi:http/handler" | ||
export handle-read: "wasi:http/handler" | ||
export handle-update: "wasi:http/handler" | ||
export handle-delete: "wasi:http/handler" | ||
} | ||
``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is interesting... are you thinking the standard would define a canonical string format and implementations would adapt however they saw the database's DATE type into that string format? (I don't have a better plan.)
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.
That's a good point. Initially, I was thinking of just relying on the format used by the underlying database. On the other hand, it might be a good idea to define a standardized format for storing dates in the interface itself for consistency's sake — we could use ISO 8601, or smt of the sort. That said, I'm not sure. How do you feel about just relying on the underlying format?
Uh oh!
There was an error while loading. Please reload this page.
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'm not sure what "the underlying format" is. When I ask SQL Server for a
datetimeoffset
column, I assume it is stored in some opaque binary format, and surfaced as aSystem.DateTimeOffset
orchrono::DateTime
or whatever type by the driver. So we would probably need to format it anyway.I could be wrong though - could you expand on your understanding of "underlying format"?
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.
@itowlson ~ I tried out implementing this interface for postgres, and here's what I did w/ regard to this: