@nocobase/database 2.1.0-beta.16 → 2.1.0-beta.19

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.
@@ -58,13 +58,10 @@ const _QueryFormatter = class _QueryFormatter {
58
58
  if (import_moment_timezone.default.tz.zone(offset)) {
59
59
  return offset;
60
60
  }
61
- if (!/^[+-]\d{1,2}:\d{2}$/.test(offset)) {
62
- return;
61
+ if (/^[+-]\d{1,2}:\d{2}$/.test(offset)) {
62
+ return offset;
63
63
  }
64
- const offsetMinutes = import_moment_timezone.default.duration(offset).asMinutes();
65
- return import_moment_timezone.default.tz.names().find((timezone) => {
66
- return import_moment_timezone.default.tz(timezone).utcOffset() === offsetMinutes;
67
- });
64
+ return;
68
65
  }
69
66
  getOffsetExpression(timezone) {
70
67
  const sign = timezone.charAt(0);
@@ -9,6 +9,7 @@
9
9
  import { QueryFormatter, Col } from '../formatter';
10
10
  export declare class PostgresQueryFormatter extends QueryFormatter {
11
11
  convertFormat(format: string): string;
12
+ private buildTimezoneLiteral;
12
13
  formatDate(field: Col, format: string, timezone?: string, _preserveLocalTime?: boolean): import("sequelize/types/utils").Fn;
13
14
  formatUnixTimestamp(field: string, format: string, accuracy?: 'second' | 'millisecond', timezone?: string): import("sequelize/types/utils").Fn;
14
15
  }
@@ -35,6 +35,12 @@ const _PostgresQueryFormatter = class _PostgresQueryFormatter extends import_for
35
35
  convertFormat(format) {
36
36
  return format.replace(/hh/g, "HH24").replace(/mm/g, "MI").replace(/ss/g, "SS");
37
37
  }
38
+ buildTimezoneLiteral(target) {
39
+ if (/^[+-]\d{1,2}:\d{2}$/.test(target)) {
40
+ return `INTERVAL '${target}'`;
41
+ }
42
+ return `'${target}'`;
43
+ }
38
44
  formatDate(field, format, timezone, _preserveLocalTime) {
39
45
  const fmt = this.convertFormat(format);
40
46
  const resolvedTimezone = this.getTimezoneByOffset(timezone);
@@ -42,7 +48,7 @@ const _PostgresQueryFormatter = class _PostgresQueryFormatter extends import_for
42
48
  const quoted = this.sequelize.getQueryInterface().quoteIdentifiers(field.col);
43
49
  return this.sequelize.fn(
44
50
  "to_char",
45
- this.sequelize.literal(`(${quoted} AT TIME ZONE '${resolvedTimezone}')`),
51
+ this.sequelize.literal(`timezone(${this.buildTimezoneLiteral(resolvedTimezone)}, ${quoted})`),
46
52
  fmt
47
53
  );
48
54
  }
@@ -52,7 +58,7 @@ const _PostgresQueryFormatter = class _PostgresQueryFormatter extends import_for
52
58
  const quoted = this.sequelize.getQueryInterface().quoteIdentifiers(field);
53
59
  const timestamp = accuracy === "millisecond" ? `to_timestamp(ROUND(${quoted} / 1000))` : `to_timestamp(${quoted})`;
54
60
  const resolvedTimezone = this.getTimezoneByOffset(timezone);
55
- const literal = resolvedTimezone ? `${timestamp} AT TIME ZONE '${resolvedTimezone}'` : timestamp;
61
+ const literal = resolvedTimezone ? `timezone(${this.buildTimezoneLiteral(resolvedTimezone)}, ${timestamp})` : timestamp;
56
62
  return this.sequelize.fn("to_char", this.sequelize.literal(literal), this.convertFormat(format));
57
63
  }
58
64
  };
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@nocobase/database",
3
- "version": "2.1.0-beta.16",
3
+ "version": "2.1.0-beta.19",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
7
7
  "license": "Apache-2.0",
8
8
  "dependencies": {
9
- "@nocobase/logger": "2.1.0-beta.16",
10
- "@nocobase/utils": "2.1.0-beta.16",
9
+ "@nocobase/logger": "2.1.0-beta.19",
10
+ "@nocobase/utils": "2.1.0-beta.19",
11
11
  "async-mutex": "^0.3.2",
12
12
  "chalk": "^4.1.1",
13
13
  "cron-parser": "4.4.0",
@@ -38,5 +38,5 @@
38
38
  "url": "git+https://github.com/nocobase/nocobase.git",
39
39
  "directory": "packages/database"
40
40
  },
41
- "gitHead": "b9a191705a440a336c85d82fd877fdf152bec70f"
41
+ "gitHead": "d89ab08dbcb25877de69827d5bad6823c27b2cbb"
42
42
  }