Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@databases/split-sql-query

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@databases/split-sql-query - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

14

lib/__tests__/index.test.js

@@ -82,2 +82,16 @@ "use strict";

});
test('regression - 2', () => {
expect(__1.default(sql_1.default `
CREATE OR REPLACE FUNCTION update_updated_at_column()
RETURNS TRIGGER AS $$
BEGIN
NEW.updated_at = now();
RETURN NEW;
END;
$$ language 'plpgsql';
CREATE TRIGGER <trigger_name> BEFORE UPDATE ON <table_name> FOR EACH ROW EXECUTE PROCEDURE update_updated_at_column();
`).length).toBe(2);
expect(__1.default(sql_1.default `$SomeTag$Dianne's$WrongTag$;$some non tag an$identifier;; horse$SomeTag$;$SomeTag$Dianne's horse$SomeTag$`).length).toBe(2);
});
//# sourceMappingURL=index.test.js.map

@@ -50,2 +50,8 @@ "use strict";

let isBlockCommentEnd = false;
// https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-DOLLAR-QUOTING
// The tag, if any, of a dollar-quoted string follows the same rules as an unquoted identifier,
// except that it cannot contain a dollar sign. Tags are case sensitive, so $tag$String content$tag$
// is correct, but $TAG$String content$tag$ is not.
let dollarQuoteStart = ``;
let dollarQuote = ``;
for (const part of query) {

@@ -74,2 +80,18 @@ if (part.type === web_1.SQLItemType.RAW) {

}
if (dollarQuoteStart && !dollarQuote) {
if (char === `$`) {
dollarQuote = `${dollarQuoteStart}$`;
dollarQuoteStart = ``;
str += char;
continue;
}
else if (/[0-9_]/i.test(char) ||
// we allow letters with diacritical marks
char.toLowerCase() !== char.toUpperCase()) {
dollarQuoteStart += char;
}
else {
dollarQuoteStart = ``;
}
}
if (isBlockCommentFirstChar) {

@@ -113,2 +135,15 @@ isBlockCommentFirstChar = false;

}
else if (dollarQuote) {
if (dollarQuoteStart) {
dollarQuoteStart += char;
if (dollarQuoteStart === dollarQuote) {
dollarQuote = ``;
dollarQuoteStart = ``;
}
}
if (dollarQuote && char === `$`) {
dollarQuoteStart = `$`;
}
str += char;
}
else {

@@ -122,2 +157,6 @@ switch (char) {

break;
case `$`:
dollarQuoteStart = `$`;
str += char;
break;
case `-`:

@@ -124,0 +163,0 @@ lineCommentStart = true;

2

package.json
{
"name": "@databases/split-sql-query",
"version": "1.0.2",
"version": "1.0.3",
"description": "",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc