Skip to content
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

Added wasm and created extract_table_names method #1

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

rameezshuhaibcleartax
Copy link

@rameezshuhaibcleartax rameezshuhaibcleartax commented Mar 11, 2022

No description provided.

src/lib.rs Outdated Show resolved Hide resolved
extern { pub fn alert(s: &str); }

#[wasm_bindgen]
pub fn extract_table_names(sql: String) -> JsValue {
Copy link
Author

@rameezshuhaibcleartax rameezshuhaibcleartax Mar 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Anks I'm not sure which is the best option here monadic error handling or raising alerts.

type Error = String;
pub fn extract_table_names(sql: String) -> (Error, JsValue)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, I have just made the function return a string (in case of error) or an array of strings in case of success. Not a great interface, but it allows the caller to distinguish between parsing failure and empty state

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants