-
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
Changes from 10 commits
eb9f5a3
d76b956
ef919c2
4eaf3a4
752f298
5196c3a
57fefb5
88383c3
716ccbe
f224767
df15d39
0e3a266
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# `wasi-sql` API | ||
|
||
## Interfaces | ||
|
||
```wit | ||
interface "wasi:sql" { | ||
// iterator item type | ||
record item { | ||
field-name: string | ||
values: data-type | ||
index: u32 | ||
} | ||
|
||
// common data types | ||
variant data-type { | ||
int32(s32), | ||
int64(s64), | ||
uint32(u32), | ||
uint64(u64), | ||
float(float64), | ||
double(float64), | ||
str(string), | ||
boolean(bool), | ||
date(string), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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 commentThe 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: "date" => {
let v: String = row.get(i);
let parsed = NaiveDate::parse_from_str(&v, "%Y-%m-%d").unwrap();
DataType::Date(parsed.to_string())
}
"time" => {
let v: String = row.get(i);
let parsed = NaiveTime::parse_from_str(&v, "%H:%M:%S").unwrap();
DataType::Time(parsed.to_string())
}
"timestamp" => {
let v: String = row.get(i);
let parsed =
NaiveDateTime::parse_from_str(&v, "%Y-%m-%d %H:%M:%S").unwrap();
DataType::Timestamp(parsed.to_string())
} |
||
time(string), | ||
timestamp(string), | ||
binary(list<u8>), | ||
null | ||
} | ||
|
||
// iterator for item | ||
resource row { | ||
next: func() -> option<row> | ||
danbugs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
// allows parameterized queries | ||
resource statement { | ||
// e.g., create("SELECT * FROM users WHERE name = ? AND age = ?", vec!["John Doe", "32"]) | ||
create: func(s: string, p: list<string>) -> result<statement, 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<row, error> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would expect the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks at the moment like FWIW, the Spin prototype has There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It made me confused hence my comments.
I assume that
That would my expectation here as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering about how to get the item as well. I also wonder, does |
||
|
||
// exec is for modifying data in the database. | ||
exec: func(q: statement) -> result<_, error> | ||
|
||
// common error types | ||
variant error { | ||
syntax-error(string), | ||
constraint-violation(string), | ||
access-violation(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" | ||
} | ||
``` |
Uh oh!
There was an error while loading. Please reload this page.