@hypequery/clickhouse 1.2.8-beta.0 → 1.2.9

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.
@@ -35,6 +35,40 @@ const clickhouseToTsType = (type) => {
35
35
  return `${clickhouseToTsType(innerType)} | null`;
36
36
  }
37
37
 
38
+ // Handle Map types
39
+ if (type.startsWith('Map(')) {
40
+ // Extract key and value types from Map(KeyType, ValueType)
41
+ const mapContent = type.slice(4, -1); // Remove 'Map(' and ')'
42
+ const commaIndex = mapContent.lastIndexOf(',');
43
+ if (commaIndex !== -1) {
44
+ const keyType = mapContent.substring(0, commaIndex).trim();
45
+ const valueType = mapContent.substring(commaIndex + 1).trim();
46
+
47
+ // Handle different key types
48
+ let keyTsType = 'string';
49
+ if (keyType === 'LowCardinality(String)') {
50
+ keyTsType = 'string';
51
+ } else if (keyType.includes('Int') || keyType.includes('UInt')) {
52
+ keyTsType = 'number';
53
+ }
54
+
55
+ // Handle different value types
56
+ let valueTsType = 'unknown';
57
+ if (valueType.startsWith('Array(')) {
58
+ const innerType = valueType.slice(6, -1);
59
+ valueTsType = `Array<${clickhouseToTsType(innerType)}>`;
60
+ } else if (valueType.startsWith('Nullable(')) {
61
+ const innerType = valueType.slice(9, -1);
62
+ valueTsType = `${clickhouseToTsType(innerType)} | null`;
63
+ } else {
64
+ valueTsType = clickhouseToTsType(valueType);
65
+ }
66
+
67
+ return `Record<${keyTsType}, ${valueTsType}>`;
68
+ }
69
+ return 'Record<string, unknown>';
70
+ }
71
+
38
72
  switch (type.toLowerCase()) {
39
73
  case 'string':
40
74
  case 'fixedstring':
@@ -43,12 +77,16 @@ const clickhouseToTsType = (type) => {
43
77
  case 'int16':
44
78
  case 'int32':
45
79
  case 'uint8':
80
+ case 'int64':
46
81
  case 'uint16':
47
82
  case 'uint32':
48
- return 'number';
49
- case 'int64':
50
83
  case 'uint64':
51
- return 'string'; // Use string for 64-bit integers to avoid precision loss
84
+ return 'number';
85
+ case 'uint128':
86
+ case 'uint256':
87
+ case 'int128':
88
+ case 'int256':
89
+ return 'string';
52
90
  case 'float32':
53
91
  case 'float64':
54
92
  case 'decimal':
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hypequery/clickhouse",
3
- "version": "1.2.8-beta.0",
3
+ "version": "1.2.9",
4
4
  "description": "ClickHouse typescript query builder",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,7 +0,0 @@
1
- /**
2
- * Common initialization for all integration tests
3
- * Import this at the beginning of each test file to ensure consistent setup
4
- */
5
- export declare const skipIntegrationTests: () => boolean;
6
- export declare const initializeForTest: () => Promise<void>;
7
- //# sourceMappingURL=test-initializer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-initializer.d.ts","sourceRoot":"","sources":["../../../../src/core/tests/integration/test-initializer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,eAAO,MAAM,oBAAoB,eAEhC,CAAC;AAEF,eAAO,MAAM,iBAAiB,QAAa,OAAO,CAAC,IAAI,CAqBtD,CAAC"}
@@ -1,32 +0,0 @@
1
- /**
2
- * Common initialization for all integration tests
3
- * Import this at the beginning of each test file to ensure consistent setup
4
- */
5
- import { startClickHouseContainer, waitForClickHouse, ensureConnectionInitialized, setupTestDatabase } from './setup.js';
6
- export const skipIntegrationTests = () => {
7
- return process.env.SKIP_INTEGRATION_TESTS === 'true' || process.env.CI === 'true';
8
- };
9
- export const initializeForTest = async () => {
10
- if (skipIntegrationTests()) {
11
- return;
12
- }
13
- try {
14
- // Initialize the connection
15
- ensureConnectionInitialized();
16
- // Make sure container is running
17
- await startClickHouseContainer();
18
- // Wait for ClickHouse to be ready
19
- await waitForClickHouse();
20
- // Set up the test database
21
- await setupTestDatabase();
22
- }
23
- catch (error) {
24
- console.error('Failed to initialize test environment:', error);
25
- throw error;
26
- }
27
- };
28
- // Automatically initialize when this module is imported
29
- initializeForTest().catch(error => {
30
- console.error('Test initialization failed:', error);
31
- process.exit(1);
32
- });