@toxplanet/pegasus-sdk 1.1.22 → 1.1.23

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.
Files changed (2) hide show
  1. package/lib/chemicals.js +6 -6
  2. package/package.json +1 -1
package/lib/chemicals.js CHANGED
@@ -121,7 +121,7 @@ class ChemicalsService {
121
121
  _buildChemicalUpsertSql(chemical) {
122
122
  const upsertSql = [
123
123
  'INSERT INTO chemicals (source_id, chemical_name, chemical_meta, chemical_identifiers, chemical_synonyms, chemical_categories, created_at, updated_at)',
124
- 'VALUES (:source_id, :chemical_name, :chemical_meta::jsonb, :chemical_identifiers::jsonb, :chemical_synonyms::text[], :chemical_categories::text[], :created_at, :updated_at)',
124
+ 'VALUES (:source_id, :chemical_name, :chemical_meta::jsonb, :chemical_identifiers::jsonb, :chemical_synonyms::text[], :chemical_categories::text[], :created_at::timestamp, :updated_at::timestamp)',
125
125
  'ON CONFLICT (source_id) DO UPDATE SET',
126
126
  ' chemical_name = EXCLUDED.chemical_name,',
127
127
  ' chemical_meta = EXCLUDED.chemical_meta,',
@@ -327,7 +327,7 @@ class ChemicalsService {
327
327
  await this.connection.ensureConnected();
328
328
 
329
329
  const columns = ['source_id', 'chemical_name', 'chemical_meta', 'chemical_identifiers', 'chemical_synonyms', 'chemical_categories', 'created_at', 'updated_at'];
330
- const values = [':source_id', ':chemical_name', ':chemical_meta::jsonb', ':chemical_identifiers::jsonb', ':chemical_synonyms::text[]', ':chemical_categories::text[]', ':created_at', ':updated_at'];
330
+ const values = [':source_id', ':chemical_name', ':chemical_meta::jsonb', ':chemical_identifiers::jsonb', ':chemical_synonyms::text[]', ':chemical_categories::text[]', ':created_at::timestamp', ':updated_at::timestamp'];
331
331
  const params = [
332
332
  { name: 'source_id', value: { stringValue: chemical.source_id } },
333
333
  { name: 'chemical_name', value: { stringValue: chemical.chemical_name } },
@@ -341,7 +341,7 @@ class ChemicalsService {
341
341
 
342
342
  if (chemical.imported_at) {
343
343
  columns.push('imported_at');
344
- values.push(':imported_at');
344
+ values.push(':imported_at::timestamp');
345
345
  params.push({ name: 'imported_at', value: { stringValue: this._serializeDate(chemical.imported_at) } });
346
346
  }
347
347
 
@@ -388,7 +388,7 @@ class ChemicalsService {
388
388
  params.push({ name: 'chemical_categories', value: { stringValue: this._toPostgresArray(updates.chemical_categories) } });
389
389
  }
390
390
 
391
- setClauses.push('updated_at = :updated_at');
391
+ setClauses.push('updated_at = :updated_at::timestamp');
392
392
  params.push({ name: 'updated_at', value: { stringValue: this._serializeDate(new Date()) } });
393
393
 
394
394
  params.push({ name: 'id', value: { stringValue: chemicalId } });
@@ -450,7 +450,7 @@ class ChemicalsService {
450
450
  await this.connection.ensureConnected();
451
451
 
452
452
  const pathArray = propertyPath.split('.');
453
- const sql = 'UPDATE chemicals SET chemical_meta = jsonb_set(chemical_meta, :path::text[], :value::jsonb), updated_at = :updated_at WHERE :collection_name = ANY(chemical_categories) RETURNING *';
453
+ const sql = 'UPDATE chemicals SET chemical_meta = jsonb_set(chemical_meta, :path::text[], :value::jsonb), updated_at = :updated_at::timestamp WHERE :collection_name = ANY(chemical_categories) RETURNING *';
454
454
  const params = [
455
455
  { name: 'path', value: { stringValue: JSON.stringify(pathArray) }, typeHint: 'JSON' },
456
456
  { name: 'value', value: { stringValue: JSON.stringify(newValue) }, typeHint: 'JSON' },
@@ -492,7 +492,7 @@ class ChemicalsService {
492
492
  }
493
493
 
494
494
  const pathArray = propertyPath.split('.');
495
- const sql = `UPDATE chemicals SET chemical_meta = jsonb_set(COALESCE(chemical_meta, '{}'), :path::text[], :value::jsonb), updated_at = :updated_at WHERE ${whereClause} RETURNING *`;
495
+ const sql = `UPDATE chemicals SET chemical_meta = jsonb_set(COALESCE(chemical_meta, '{}'), :path::text[], :value::jsonb), updated_at = :updated_at::timestamp WHERE ${whereClause} RETURNING *`;
496
496
 
497
497
  params.push({ name: 'path', value: { stringValue: JSON.stringify(pathArray) }, typeHint: 'JSON' });
498
498
  params.push({ name: 'value', value: { stringValue: JSON.stringify(newValue) }, typeHint: 'JSON' });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toxplanet/pegasus-sdk",
3
- "version": "1.1.22",
3
+ "version": "1.1.23",
4
4
  "description": "SDK for migrating chemical data to Pegasus PostgreSQL + OpenSearch architecture with Elasticsearch client compatibility",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",