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

fix: Handle multiline sql without spaces #215

Open
wants to merge 1 commit into
base: typescript
Choose a base branch
from

Conversation

nossrannug
Copy link
Contributor

When replacing multiline comment, it is now done with a space instead of
nothing since this would be valid sql:

SELECT pid FROM/*comment*/pg_stat_activity;

But replacing the comment with "" would make it incorrect.

Also join the lines in query on getContent with a space to remove the
need for spaces in the sql. Previously this sql:

SELECT some_column
FROM some_table;

would result in this error: [error] column "some_columnfrom" does not exist
This PR fixes that.

@joereynolds
Copy link
Owner

Hey @nossrannug thanks for this, I'll try and take a proper look at it in the week, looks good though!

@joereynolds
Copy link
Owner

Hey again @nossrannug,

I've just given this a go and there's a few test failures when running npm test.

Let me know if you need any help with them.
I've added github actions to the repo so that tests run on pull requests now too

@joereynolds
Copy link
Owner

Also, would this solve this longstanding issue:

#55

?

@nossrannug
Copy link
Contributor Author

Thanks, @joereynolds.
I'll take a look at the tests :) and yes, it looks like this will solve #55

When replacing multiline comment, it is now done with a space instead of
nothing since this would be valid sql:
```sql
SELECT pid FROM/*comment*/pg_stat_activity;
```
But replacing the comment with "" would make it incorrect.

Also join the lines in query on getContent with a space to remove the
need for spaces in the sql. Previously this sql:
```sql
SELECT some_column
FROM some_table;
```
would result in this error: `[error] column "some_columnfrom" does not
exist`
This PR fixes that.
@nossrannug nossrannug force-pushed the query-content-spaces branch from 7abfaf3 to 45e465a Compare June 22, 2022 17:47
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