sqlite-replication
Advanced tools
Comparing version 0.0.25-b to 0.0.26-b
export declare class SQLHelpers { | ||
static safeValue(value: any): any; | ||
static getSafeSQLMapping(document: any, option?: { | ||
excludeUndefinedProperties: boolean; | ||
}): string; | ||
static getUpsertStatement(collectionName: string, document: any, option?: { | ||
@@ -7,0 +4,0 @@ excludeUndefinedProperties: boolean; |
@@ -22,9 +22,2 @@ export class SQLHelpers { | ||
} | ||
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})`; | ||
} | ||
static getUpsertStatement(collectionName, document, option = { excludeUndefinedProperties: true }) { | ||
@@ -31,0 +24,0 @@ if (!document) |
{ | ||
"name": "sqlite-replication", | ||
"version": "0.0.25b", | ||
"version": "0.0.26b", | ||
"description": "A Typescript module to replicate SQLite DB with server.", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -48,9 +48,2 @@ import { SQLHelpers } from './SQLHelpers'; | ||
}); | ||
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')`); | ||
}); | ||
}); | ||
describe('upsert', () => { | ||
@@ -57,0 +50,0 @@ it('should generate SQL from random object', () => { |
@@ -17,13 +17,2 @@ export class SQLHelpers { | ||
} | ||
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})`; | ||
} | ||
@@ -30,0 +19,0 @@ static getUpsertStatement( |
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
96015
1832