@travetto/model-postgres 6.0.1 → 7.0.0-rc.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/model-postgres",
3
- "version": "6.0.1",
3
+ "version": "7.0.0-rc.1",
4
4
  "description": "PostgreSQL backing for the travetto model module, with real-time modeling support for SQL schemas.",
5
5
  "keywords": [
6
6
  "sql",
@@ -27,13 +27,13 @@
27
27
  "directory": "module/model-postgres"
28
28
  },
29
29
  "dependencies": {
30
- "@travetto/cli": "^6.0.1",
31
- "@travetto/config": "^6.0.1",
32
- "@travetto/context": "^6.0.1",
33
- "@travetto/model": "^6.0.1",
34
- "@travetto/model-query": "^6.0.1",
35
- "@travetto/model-sql": "^6.0.1",
36
- "@types/pg": "^8.15.5",
30
+ "@travetto/cli": "^7.0.0-rc.1",
31
+ "@travetto/config": "^7.0.0-rc.1",
32
+ "@travetto/context": "^7.0.0-rc.1",
33
+ "@travetto/model": "^7.0.0-rc.1",
34
+ "@travetto/model-query": "^7.0.0-rc.1",
35
+ "@travetto/model-sql": "^7.0.0-rc.1",
36
+ "@types/pg": "^8.15.6",
37
37
  "pg": "^8.16.3"
38
38
  },
39
39
  "travetto": {
package/src/connection.ts CHANGED
@@ -40,7 +40,11 @@ export class PostgreSQLConnection extends Connection<PoolClient> {
40
40
 
41
41
  await this.runWithActive(() =>
42
42
  this.runWithTransaction('required', () =>
43
- this.execute(this.active!, 'CREATE EXTENSION IF NOT EXISTS pgcrypto;')
43
+ this.execute(this.active!, 'CREATE EXTENSION IF NOT EXISTS pgcrypto;').catch(err => {
44
+ if (!(err instanceof Error && err.message.includes('already exists'))) {
45
+ throw err;
46
+ }
47
+ })
44
48
  )
45
49
  );
46
50
 
package/src/dialect.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { FieldConfig } from '@travetto/schema';
1
+ import { SchemaFieldConfig } from '@travetto/schema';
2
2
  import { Injectable } from '@travetto/di';
3
3
  import { AsyncContext } from '@travetto/context';
4
4
  import { ModelType } from '@travetto/model';
@@ -19,6 +19,7 @@ export class PostgreSQLDialect extends SQLDialect {
19
19
  constructor(context: AsyncContext, config: SQLModelConfig) {
20
20
  super(config.namespace);
21
21
  this.conn = new PostgreSQLConnection(context, config);
22
+ this.ID_AFFIX = '"';
22
23
 
23
24
  // Special operators
24
25
  Object.assign(this.SQL_OPS, {
@@ -43,17 +44,13 @@ export class PostgreSQLDialect extends SQLDialect {
43
44
  return `encode(digest('${value}', 'sha1'), 'hex')`;
44
45
  }
45
46
 
46
- ident(field: FieldConfig | string): string {
47
- return `"${typeof field === 'string' ? field : field.name}"`;
48
- }
49
-
50
47
  /**
51
48
  * Define column modification
52
49
  */
53
50
  getModifyColumnSQL(stack: VisitStack[]): string {
54
- const field: FieldConfig = castTo(stack.at(-1));
51
+ const field: SchemaFieldConfig = castTo(stack.at(-1));
55
52
  const type = this.getColumnType(field);
56
- const ident = this.ident(field.name);
53
+ const ident = this.ident(field.name.toString());
57
54
  return `ALTER TABLE ${this.parentTable(stack)} ALTER COLUMN ${ident} TYPE ${type} USING (${ident}::${type});`;
58
55
  }
59
56
 
@@ -1,6 +1,6 @@
1
1
  import type { ServiceDescriptor } from '@travetto/cli';
2
2
 
3
- const version = process.env.POSTGRESQL_VERSION || '17.6';
3
+ const version = process.env.POSTGRESQL_VERSION || '18.1';
4
4
 
5
5
  export const service: ServiceDescriptor = {
6
6
  name: 'postgresql',