sedentary-pg 0.0.38 → 0.0.39

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.
package/dist/cjs/pgdb.js CHANGED
@@ -345,13 +345,13 @@ class PGDB extends sedentary_1.DB {
345
345
  if (this.sync)
346
346
  await this._client.query(statement);
347
347
  };
348
- const setDefault = async (isNotNull, create) => {
348
+ const setDefault = async (isNotNull) => {
349
349
  if (defaultValue !== undefined) {
350
350
  let statement = `ALTER TABLE ${tableName} ALTER COLUMN ${fieldName} SET DEFAULT ${defaultValue}`;
351
351
  this.syncLog(statement);
352
352
  if (this.sync)
353
353
  await this._client.query(statement);
354
- if (!isNotNull && !create) {
354
+ if (notNull && !isNotNull) {
355
355
  statement = `UPDATE ${tableName} SET ${fieldName} = ${defaultValue} WHERE ${fieldName} IS NULL`;
356
356
  this.syncLog(statement);
357
357
  if (this.sync)
@@ -362,7 +362,7 @@ class PGDB extends sedentary_1.DB {
362
362
  };
363
363
  if (!res.rowCount) {
364
364
  await addField();
365
- await setDefault(false, true);
365
+ await setDefault(false);
366
366
  }
367
367
  else {
368
368
  const { adsrc, attnotnull, atttypmod, typname } = res.rows[0];
@@ -370,7 +370,7 @@ class PGDB extends sedentary_1.DB {
370
370
  if (needDrop.filter(([type, name]) => attribute.type === type && typname === name).length) {
371
371
  await this.dropField(tableName, fieldName);
372
372
  await addField();
373
- await setDefault(false, true);
373
+ await setDefault(false);
374
374
  }
375
375
  else {
376
376
  if (adsrc)
@@ -380,7 +380,7 @@ class PGDB extends sedentary_1.DB {
380
380
  this.syncLog(statement);
381
381
  if (this.sync)
382
382
  await this._client.query(statement);
383
- await setDefault(attnotnull, false);
383
+ await setDefault(attnotnull);
384
384
  }
385
385
  }
386
386
  else if (defaultValue === undefined) {
@@ -389,7 +389,7 @@ class PGDB extends sedentary_1.DB {
389
389
  await setNotNull(attnotnull);
390
390
  }
391
391
  else if (!adsrc || this.defaultNeq(adsrc, defaultValue))
392
- await setDefault(attnotnull, false);
392
+ await setDefault(attnotnull);
393
393
  }
394
394
  }
395
395
  }
package/dist/es/pgdb.js CHANGED
@@ -340,13 +340,13 @@ export class PGDB extends DB {
340
340
  if (this.sync)
341
341
  await this._client.query(statement);
342
342
  };
343
- const setDefault = async (isNotNull, create) => {
343
+ const setDefault = async (isNotNull) => {
344
344
  if (defaultValue !== undefined) {
345
345
  let statement = `ALTER TABLE ${tableName} ALTER COLUMN ${fieldName} SET DEFAULT ${defaultValue}`;
346
346
  this.syncLog(statement);
347
347
  if (this.sync)
348
348
  await this._client.query(statement);
349
- if (!isNotNull && !create) {
349
+ if (notNull && !isNotNull) {
350
350
  statement = `UPDATE ${tableName} SET ${fieldName} = ${defaultValue} WHERE ${fieldName} IS NULL`;
351
351
  this.syncLog(statement);
352
352
  if (this.sync)
@@ -357,7 +357,7 @@ export class PGDB extends DB {
357
357
  };
358
358
  if (!res.rowCount) {
359
359
  await addField();
360
- await setDefault(false, true);
360
+ await setDefault(false);
361
361
  }
362
362
  else {
363
363
  const { adsrc, attnotnull, atttypmod, typname } = res.rows[0];
@@ -365,7 +365,7 @@ export class PGDB extends DB {
365
365
  if (needDrop.filter(([type, name]) => attribute.type === type && typname === name).length) {
366
366
  await this.dropField(tableName, fieldName);
367
367
  await addField();
368
- await setDefault(false, true);
368
+ await setDefault(false);
369
369
  }
370
370
  else {
371
371
  if (adsrc)
@@ -375,7 +375,7 @@ export class PGDB extends DB {
375
375
  this.syncLog(statement);
376
376
  if (this.sync)
377
377
  await this._client.query(statement);
378
- await setDefault(attnotnull, false);
378
+ await setDefault(attnotnull);
379
379
  }
380
380
  }
381
381
  else if (defaultValue === undefined) {
@@ -384,7 +384,7 @@ export class PGDB extends DB {
384
384
  await setNotNull(attnotnull);
385
385
  }
386
386
  else if (!adsrc || this.defaultNeq(adsrc, defaultValue))
387
- await setDefault(attnotnull, false);
387
+ await setDefault(attnotnull);
388
388
  }
389
389
  }
390
390
  }
package/package.json CHANGED
@@ -9,22 +9,22 @@
9
9
  "@types/pg": "8.6.5",
10
10
  "pg": "8.7.3",
11
11
  "pg-format": "1.0.4",
12
- "sedentary": "0.0.38"
12
+ "sedentary": "0.0.39"
13
13
  },
14
14
  "description": "The ORM which never needs to migrate - PostgreSQL",
15
15
  "devDependencies": {
16
- "@types/mocha": "9.1.0",
17
- "@types/node": "17.0.24",
16
+ "@types/mocha": "9.1.1",
17
+ "@types/node": "18.0.0",
18
18
  "@types/pg-format": "1.0.2",
19
19
  "@types/yamljs": "0.2.31",
20
- "@typescript-eslint/eslint-plugin": "5.19.0",
21
- "@typescript-eslint/parser": "5.19.0",
22
- "eslint": "8.13.0",
23
- "mocha": "9.2.2",
20
+ "@typescript-eslint/eslint-plugin": "5.30.0",
21
+ "@typescript-eslint/parser": "5.30.0",
22
+ "eslint": "8.18.0",
23
+ "mocha": "10.0.0",
24
24
  "nyc": "15.1.0",
25
- "prettier": "2.6.2",
26
- "ts-node": "10.7.0",
27
- "typescript": "4.6.3",
25
+ "prettier": "2.7.1",
26
+ "ts-node": "10.8.1",
27
+ "typescript": "4.7.4",
28
28
  "yamljs": "0.3.0"
29
29
  },
30
30
  "engines": {
@@ -84,5 +84,5 @@
84
84
  }
85
85
  },
86
86
  "types": "./dist/types/index.d.ts",
87
- "version": "0.0.38"
87
+ "version": "0.0.39"
88
88
  }