@oino-ts/db-postgresql 0.3.4 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -186,9 +186,18 @@ class OINODbPostgresql extends db_1.OINODb {
186
186
  return "\'" + cellValue.toISOString() + "\'";
187
187
  }
188
188
  else {
189
- return "\'" + cellValue?.toString().replaceAll("'", "''") + "\'";
189
+ return this.printSqlString(cellValue.toString());
190
190
  }
191
191
  }
192
+ /**
193
+ * Print a single string value as valid sql literal
194
+ *
195
+ * @param sqlString string value
196
+ *
197
+ */
198
+ printSqlString(sqlString) {
199
+ return "\'" + sqlString.replaceAll("'", "''") + "\'";
200
+ }
192
201
  /**
193
202
  * Parse a single SQL result value for serialization using the context of the native data
194
203
  * type.
@@ -201,7 +210,7 @@ class OINODbPostgresql extends db_1.OINODb {
201
210
  if ((sqlValue === null) || (sqlValue == "NULL")) {
202
211
  return null;
203
212
  }
204
- else if ((sqlValue === undefined)) {
213
+ else if (sqlValue === undefined) {
205
214
  return undefined;
206
215
  }
207
216
  else if (((sqlType == "date")) && (typeof (sqlValue) == "string")) {
@@ -183,9 +183,18 @@ export class OINODbPostgresql extends OINODb {
183
183
  return "\'" + cellValue.toISOString() + "\'";
184
184
  }
185
185
  else {
186
- return "\'" + cellValue?.toString().replaceAll("'", "''") + "\'";
186
+ return this.printSqlString(cellValue.toString());
187
187
  }
188
188
  }
189
+ /**
190
+ * Print a single string value as valid sql literal
191
+ *
192
+ * @param sqlString string value
193
+ *
194
+ */
195
+ printSqlString(sqlString) {
196
+ return "\'" + sqlString.replaceAll("'", "''") + "\'";
197
+ }
189
198
  /**
190
199
  * Parse a single SQL result value for serialization using the context of the native data
191
200
  * type.
@@ -198,7 +207,7 @@ export class OINODbPostgresql extends OINODb {
198
207
  if ((sqlValue === null) || (sqlValue == "NULL")) {
199
208
  return null;
200
209
  }
201
- else if ((sqlValue === undefined)) {
210
+ else if (sqlValue === undefined) {
202
211
  return undefined;
203
212
  }
204
213
  else if (((sqlType == "date")) && (typeof (sqlValue) == "string")) {
@@ -36,6 +36,13 @@ export declare class OINODbPostgresql extends OINODb {
36
36
  *
37
37
  */
38
38
  printCellAsSqlValue(cellValue: OINODataCell, sqlType: string): string;
39
+ /**
40
+ * Print a single string value as valid sql literal
41
+ *
42
+ * @param sqlString string value
43
+ *
44
+ */
45
+ printSqlString(sqlString: string): string;
39
46
  /**
40
47
  * Parse a single SQL result value for serialization using the context of the native data
41
48
  * type.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oino-ts/db-postgresql",
3
- "version": "0.3.4",
3
+ "version": "0.4.1",
4
4
  "description": "OINO TS package for using Postgresql databases.",
5
5
  "author": "Matias Kiviniemi (pragmatta)",
6
6
  "license": "MPL-2.0",
@@ -20,7 +20,7 @@
20
20
  "module": "./dist/esm/index.js",
21
21
  "types": "./dist/types/index.d.ts",
22
22
  "dependencies": {
23
- "@oino-ts/db": "0.3.4",
23
+ "@oino-ts/db": "0.4.1",
24
24
  "pg": "^8.11.3"
25
25
  },
26
26
  "devDependencies": {
@@ -197,10 +197,21 @@ export class OINODbPostgresql extends OINODb {
197
197
  return "\'" + cellValue.toISOString() + "\'"
198
198
 
199
199
  } else {
200
- return "\'" + cellValue?.toString().replaceAll("'", "''") + "\'"
200
+ return this.printSqlString(cellValue.toString())
201
201
  }
202
202
  }
203
203
 
204
+ /**
205
+ * Print a single string value as valid sql literal
206
+ *
207
+ * @param sqlString string value
208
+ *
209
+ */
210
+ printSqlString(sqlString:string): string {
211
+ return "\'" + sqlString.replaceAll("'", "''") + "\'"
212
+ }
213
+
214
+
204
215
  /**
205
216
  * Parse a single SQL result value for serialization using the context of the native data
206
217
  * type.
@@ -213,7 +224,7 @@ export class OINODbPostgresql extends OINODb {
213
224
  if ((sqlValue === null) || (sqlValue == "NULL")) {
214
225
  return null
215
226
 
216
- } else if ((sqlValue === undefined)) {
227
+ } else if (sqlValue === undefined) {
217
228
  return undefined
218
229
 
219
230
  } else if (((sqlType == "date")) && (typeof(sqlValue) == "string")) {