1
0
mirror of https://github.com/janet-lang/janet synced 2024-12-24 07:20:27 +00:00

Update deps.

This commit is contained in:
Calvin Rose 2018-11-16 11:49:38 -05:00
parent b20cbdfde6
commit fe7c591c40
2 changed files with 37 additions and 9 deletions

View File

@ -498,7 +498,6 @@ static const char *encode_one(Encoder *e, Janet x, int depth) {
janet_indexed_view(x, &items, &len);
if (janet_buffer_push_u8(e->buffer, '[')) goto overflow;
e->indent++;
if ((err = encode_newline(e))) return err;
for (int32_t i = 0; i < len; i++) {
if ((err = encode_newline(e))) return err;
if ((err = encode_one(e, items[i], depth + 1)))
@ -596,7 +595,7 @@ static const JanetReg cfuns[] = {
"(json.decode json-source)\n\n"
"Returns a janet object after parsing JSON."
},
{NULL, NULL}
{NULL, NULL, NULL}
};
JANET_MODULE_ENTRY(JanetArgs args) {

View File

@ -240,7 +240,7 @@ static const char *execute_collect(sqlite3_stmt *stmt, JanetArray *rows) {
break;
case SQLITE_TEXT:
{
int nbytes = sqlite3_column_bytes(stmt, i) - 1;
int nbytes = sqlite3_column_bytes(stmt, i);
uint8_t *str = janet_string_begin(nbytes);
memcpy(str, sqlite3_column_text(stmt, i), nbytes);
value = janet_wrap_string(janet_string_end(str));
@ -384,12 +384,41 @@ static int sql_error_code(JanetArgs args) {
/*****************************************************************************/
static const JanetReg cfuns[] = {
{"open", sql_open},
{"close", sql_close},
{"eval", sql_eval},
{"last-insert-rowid", sql_last_insert_rowid},
{"error-code", sql_error_code},
{NULL, NULL}
{"open", sql_open,
"(sqlite3.open path)\n\n"
"Opens a sqlite3 database on disk. Returns the database handle if the database was opened "
"successfully, and otheriwse throws an error."
},
{"close", sql_close,
"(sqlite3.close db)\n\n"
"Closes a database. Use this to free a database after use. Returns nil."
},
{"eval", sql_eval,
"(sqlite3.eval db sql [,params])\n\n"
"Evaluate sql in the context of database db. Multiple sql statements "
"can be changed together, and optionally parameters maybe passed in. "
"The optional parameters maybe either an indexed data type (tuple or array), or a dictionary "
"data type (struct or table). If params is a tuple or array, then sqlite "
"parameters are substituted using indices. For example:\n\n"
"\t(sqlite3.eval db `SELECT * FROM tab WHERE id = ?;` [123])\n\n"
"Will select rows from tab where id is equal to 123. Alternatively, "
"the programmer can use named parameters with tables or structs, like so:\n\n"
"\t(sqlite3.eval db `SELECT * FROM tab WHERE id = :id;` {:id 123})\n\n"
"Will return an array of rows, where each row contains a table where columns names "
"are keys for column values."
},
{"last-insert-rowid", sql_last_insert_rowid,
"(sqlite3.last-insert-rowid db)\n\n"
"Returns the id of the last inserted row. If the id will fit into a 32-bit"
"signed integer, will returned an integer, otherwise will return a string representation "
"of the id (an 8 bytes string containing a long integer)."
},
{"error-code", sql_error_code,
"(sqlite3.error-code db)\n\n"
"Returns the error number of the last sqlite3 command that threw an error. Cross "
"check these numbers with the SQLite documentation for more information."
},
{NULL, NULL, NULL}
};
JANET_MODULE_ENTRY(JanetArgs args) {