New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sqlite-replication

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sqlite-replication - npm Package Compare versions

Comparing version 0.0.24-b to 0.0.25-b

4

dist/SQLHelpers.d.ts
export declare class SQLHelpers {
static safeValue(value: any): any;
static joinSafeValues(values: any[]): string;
static getSafeSQLMapping(document: any, option?: {
excludeUndefinedProperties: boolean;
}): string;
static getUpsertStatement(collectionName: string, document: any, option?: {

@@ -5,0 +7,0 @@ excludeUndefinedProperties: boolean;

@@ -22,4 +22,8 @@ export class SQLHelpers {

}
static joinSafeValues(values) {
return values.map((value) => SQLHelpers.safeValue(value)).join();
static getSafeSQLMapping(document, option = { excludeUndefinedProperties: true }) {
if (!document)
throw Error('undefined document');
const keys = Object.keys(document).filter((key) => typeof document[key] !== 'undefined' || !option.excludeUndefinedProperties);
const values = keys.map((key) => SQLHelpers.safeValue(document[key])).join();
return `(${keys.map((key) => `"${key}"`).join()}) values (${values})`;
}

@@ -26,0 +30,0 @@ static getUpsertStatement(collectionName, document, option = { excludeUndefinedProperties: true }) {

{
"name": "sqlite-replication",
"version": "0.0.24b",
"version": "0.0.25b",
"description": "A Typescript module to replicate SQLite DB with server.",

@@ -5,0 +5,0 @@ "scripts": {

@@ -48,7 +48,7 @@ import { SQLHelpers } from './SQLHelpers';

});
describe('joinSafeValues', () => {
it('should wrap strings with single quotes', async () => {
expect(SQLHelpers.joinSafeValues(['value', [1, 2, 3], "Hi all' WHERE true"])).toEqual(
`'value','[1,2,3]','Hi all'' WHERE true'`,
);
describe('getSafeSQLMapping', () => {
it('should build the SQL mapping for insert/update query', async () => {
expect(
SQLHelpers.getSafeSQLMapping({ prop1: 'value', prop2: [1, 2, 3], prop3: "Hi all' WHERE true" }),
).toEqual(`("prop1","prop2","prop3") values ('value','[1,2,3]','Hi all'' WHERE true')`);
});

@@ -55,0 +55,0 @@ });

@@ -17,4 +17,12 @@ export class SQLHelpers {

}
static joinSafeValues(values: any[]) {
return values.map((value) => SQLHelpers.safeValue(value)).join();
static getSafeSQLMapping(
document: any,
option: { excludeUndefinedProperties: boolean } = { excludeUndefinedProperties: true },
) {
if (!document) throw Error('undefined document');
const keys = Object.keys(document).filter(
(key) => typeof document[key] !== 'undefined' || !option.excludeUndefinedProperties,
);
const values = keys.map((key) => SQLHelpers.safeValue(document[key])).join();
return `(${keys.map((key) => `"${key}"`).join()}) values (${values})`;
}

@@ -21,0 +29,0 @@

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