Skip to content

Commit

Permalink
plugins/sql: allow datetime functions
Browse files Browse the repository at this point in the history
Changelog-Changed: Plugins:  now allows date and time sqlite functions.
  • Loading branch information
JosephGoulden authored and rustyrussell committed Jul 19, 2024
1 parent 6bfa303 commit 89ede8a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
9 changes: 8 additions & 1 deletion contrib/msggen/msggen/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -28382,6 +28382,9 @@
"* avg",
"* coalesce",
"* count",
"* date",
"* datetime",
"* julianday",
"* hex",
"* quote",
"* length",
Expand All @@ -28390,8 +28393,12 @@
"* upper",
"* min",
"* max",
"* strftime",
"* sum",
"* total"
"* time",
"* timediff",
"* total",
"* unixepoch"
],
"tables": [
"Note that the first column of every table is a unique integer called `rowid`: this is used for related tables to refer to specific rows in their parent. sqlite3 usually has this as an implicit column, but we make it explicit as the implicit version is not allowed to be used as a foreign key.",
Expand Down
9 changes: 8 additions & 1 deletion doc/schemas/lightning-sql-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@
"* avg",
"* coalesce",
"* count",
"* date",
"* datetime",
"* julianday",
"* hex",
"* quote",
"* length",
Expand All @@ -98,8 +101,12 @@
"* upper",
"* min",
"* max",
"* strftime",
"* sum",
"* total"
"* time",
"* timediff",
"* total",
"* unixepoch"
],
"tables": [
"Note that the first column of every table is a unique integer called `rowid`: this is used for related tables to refer to specific rows in their parent. sqlite3 usually has this as an implicit column, but we make it explicit as the implicit version is not allowed to be used as a foreign key.",
Expand Down
14 changes: 14 additions & 0 deletions plugins/sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,20 @@ static int sqlite_authorize(void *dbq_, int code,
return SQLITE_OK;
if (streq(b, "total"))
return SQLITE_OK;
if (streq(b, "date"))
return SQLITE_OK;
if (streq(b, "datetime"))
return SQLITE_OK;
if (streq(b, "julianday"))
return SQLITE_OK;
if (streq(b, "strftime"))
return SQLITE_OK;
if (streq(b, "time"))
return SQLITE_OK;
if (streq(b, "timediff"))
return SQLITE_OK;
if (streq(b, "unixepoch"))
return SQLITE_OK;
}

/* See https://www.sqlite.org/c3ref/c_alter_table.html to decode these! */
Expand Down

0 comments on commit 89ede8a

Please sign in to comment.