fix: remove requirement on full wasm parser for row insert of db studio

This commit is contained in:
Ruben Fiszel
2024-04-11 01:12:47 +02:00
parent f17bed9741
commit cd07020edb
5 changed files with 74 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
[package]
name = "windmill-sql-datatype-parser-wasm"
version.workspace = true
edition.workspace = true
authors.workspace = true
[lib]
crate-type = ["cdylib"]
name = "windmill_sql_datatype_parser_wasm"
path = "./src/lib.rs"
[dev-dependencies]
wasm-bindgen-test.workspace = true
[dependencies]
windmill-parser.workspace = true
windmill-parser-sql.workspace = true
wasm-bindgen.workspace = true
serde = { version = "1.0", features = ["derive"] }

View File

@@ -0,0 +1,4 @@
#!/bin/bash
set -eou pipefail
deno task wasmbuild --out ../../../cli/wasm/

View File

@@ -0,0 +1,6 @@
{
"name": "windmill-parser-wasm",
"lockfileVersion": 3,
"requires": true,
"packages": {}
}

View File

@@ -0,0 +1,4 @@
{
"name": "windmill-sql-datatype-parser-wasm",
"version": "0.1.0"
}

View File

@@ -0,0 +1,40 @@
use wasm_bindgen::prelude::*;
use windmill_parser_sql::Typ;
fn to_str(typ: Typ) -> String {
match typ {
Typ::Str(_) => "str".to_string(),
Typ::Int => "int".to_string(),
Typ::Float => "float".to_string(),
Typ::Bool => "bool".to_string(),
Typ::List(t) => format!("list-{}", to_str(*t)),
Typ::Bytes => "bytes".to_string(),
Typ::Datetime => "datetime".to_string(),
_ => "unknown".to_string(),
}
}
#[wasm_bindgen]
pub fn parse_sql(typ: &str) -> String {
to_str(windmill_parser_sql::parse_pg_typ(typ))
}
#[wasm_bindgen]
pub fn parse_mysql(typ: &str) -> String {
to_str(windmill_parser_sql::parse_mysql_typ(typ))
}
#[wasm_bindgen]
pub fn parse_bigquery(typ: &str) -> String {
to_str(windmill_parser_sql::parse_bigquery_typ(typ))
}
#[wasm_bindgen]
pub fn parse_snowflake(typ: &str) -> String {
to_str(windmill_parser_sql::parse_snowflake_typ(typ))
}
#[wasm_bindgen]
pub fn parse_mssql(typ: &str) -> String {
to_str(windmill_parser_sql::parse_mssql_typ(typ))
}