Writing a VTab that has a more complicated schema generated.
CREATE VIRTUAL TABLE IF NOT EXISTS temp.ideas_status
USING markdowndb(
schema='CREATE TABLE "ideas_status" ("inode" integer unsigned NOT NULL PRIMARY KEY CHECK ("inode" >= 0), "path" varchar(100) NOT NULL UNIQUE, "slug" varchar(50) NOT NULL UNIQUE, "content" text NOT NULL, "excerpt" text NOT NULL, "metadata" text NOT NULL CHECK ((JSON_VALID("metadata") OR "metadata" IS NULL)), "title" varchar(128) NOT NULL, "ordering" smallint NOT NULL)',
path='.../content/ideas.Status'
);
When the schema is generated, there are some extra = signs in there, for example CHECK ("inode" >= 0),
|
/// `<param_name>=['"]?<param_value>['"]?` => `(<param_name>, <param_value>)` |
|
pub fn parameter(c_slice: &[u8]) -> Result<(&str, &str)> { |
|
let arg = std::str::from_utf8(c_slice)?.trim(); |
|
let mut split = arg.split('='); |
|
if let Some(key) = split.next() { |
|
if let Some(value) = split.next() { |
|
let param = key.trim(); |
|
let value = dequote(value.trim()); |
|
return Ok((param, value)); |
|
} |
|
} |
|
Err(Error::ModuleError(format!("illegal argument: '{arg}'"))) |
|
} |
Currently does a simple arg.split('=') but perhaps migrating it to something like arg.split_once('=') might be more correct?
I am testing this locally though I can also try to prepare a patch if this seems reasonable (or if you have other suggestions)
/// `<param_name>=['"]?<param_value>['"]?` => `(<param_name>, <param_value>)`
pub fn parameter(c_slice: &[u8]) -> Result<(&str, &str)> {
std::str::from_utf8(c_slice)?
.trim()
.split_once('=')
.map(|parsed| {
let param = parsed.0.trim();
let value = vtab::dequote(parsed.1.trim());
(param, value)
})
.ok_or_else(|| Error::ModuleError(format!("illegal argument: '{arg}'"))
}
Writing a VTab that has a more complicated schema generated.
When the schema is generated, there are some extra
=signs in there, for exampleCHECK ("inode" >= 0),rusqlite/src/vtab/mod.rs
Lines 1045 to 1057 in 5c33953
Currently does a simple
arg.split('=')but perhaps migrating it to something likearg.split_once('=')might be more correct?I am testing this locally though I can also try to prepare a patch if this seems reasonable (or if you have other suggestions)