imean-cassandra-orm 1.4.2 → 1.4.4

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/mod.cjs CHANGED
@@ -130,14 +130,14 @@ var Model = class {
130
130
  return;
131
131
  }
132
132
  const currentColumns = new Map(
133
- tableInfo.columns.map((col) => [col.name, col])
133
+ tableInfo.columns.map((col) => [col.name.toLowerCase(), col])
134
134
  );
135
135
  const newFields = Object.entries(this.schema).filter(
136
- ([fieldName]) => !currentColumns.has(fieldName)
136
+ ([fieldName]) => !currentColumns.has(fieldName.toLowerCase())
137
137
  );
138
138
  const changes = [];
139
139
  Object.entries(this.schema).forEach(([fieldName, config]) => {
140
- const currentColumn = currentColumns.get(fieldName);
140
+ const currentColumn = currentColumns.get(fieldName.toLowerCase());
141
141
  if (!currentColumn) return;
142
142
  const currentType = this.getCqlTypeFromCode(currentColumn.type.code);
143
143
  const newType = config.type;
@@ -147,7 +147,7 @@ var Model = class {
147
147
  );
148
148
  }
149
149
  const isCurrentPartitionKey = tableInfo.partitionKeys.some(
150
- (key) => key.name === fieldName
150
+ (key) => key.name.toLowerCase() === fieldName.toLowerCase()
151
151
  );
152
152
  if (isCurrentPartitionKey !== config.flags.partitionKey) {
153
153
  changes.push(
@@ -155,7 +155,7 @@ var Model = class {
155
155
  );
156
156
  }
157
157
  const isCurrentClusteringKey = tableInfo.clusteringKeys.some(
158
- (key) => key.name === fieldName
158
+ (key) => key.name.toLowerCase() === fieldName.toLowerCase()
159
159
  );
160
160
  const isClusteringKey = !!config.flags.clusteringKey;
161
161
  if (isCurrentClusteringKey !== isClusteringKey) {
@@ -219,6 +219,18 @@ ${changes.join(
219
219
  }
220
220
  return typeName;
221
221
  }
222
+ // 将查询结果转换为我们的类型
223
+ convertResultToType(result) {
224
+ const converted = {};
225
+ Object.keys(this.schema).forEach((key) => {
226
+ const lowerKey = key.toLowerCase();
227
+ const resultKey = Object.keys(result).find((k) => k.toLowerCase() === lowerKey);
228
+ if (resultKey) {
229
+ converted[key] = result[resultKey];
230
+ }
231
+ });
232
+ return this.zodSchemas.entity.parse(converted);
233
+ }
222
234
  // 构建查询条件
223
235
  buildWhereClause(partitionFields, clusteringFields) {
224
236
  const conditions = [];
@@ -275,14 +287,6 @@ ${changes.join(
275
287
  return error;
276
288
  }
277
289
  }
278
- // 将查询结果转换为我们的类型
279
- convertResultToType(result) {
280
- const converted = {};
281
- Object.keys(this.schema).forEach((key) => {
282
- converted[key] = result[key];
283
- });
284
- return this.zodSchemas.entity.parse(converted);
285
- }
286
290
  // 查询方法
287
291
  async findAll(partitionFields, clusteringFields) {
288
292
  const whereClause = this.buildWhereClause(
package/dist/mod.d.cts CHANGED
@@ -266,11 +266,11 @@ declare class Model<S extends Record<string, FieldConfig<keyof TypeMap>>, P = In
266
266
  getTableSchema(): string;
267
267
  syncSchema(force?: boolean): Promise<void>;
268
268
  private getCqlTypeFromCode;
269
+ private convertResultToType;
269
270
  private buildWhereClause;
270
271
  private buildQueryParams;
271
272
  validate(data: any): data is Simplify<A>;
272
273
  getValidationErrors(data: any): z.ZodError | null;
273
- private convertResultToType;
274
274
  findAll(partitionFields: Simplify<P>, clusteringFields?: Simplify<Partial<C>>): Promise<Simplify<A>[]>;
275
275
  findOne(partitionFields: Simplify<P>, clusteringFields?: Simplify<Partial<C>>): Promise<Simplify<A> | null>;
276
276
  create(data: Simplify<P & Partial<NP>>): Promise<void>;
package/dist/mod.d.ts CHANGED
@@ -266,11 +266,11 @@ declare class Model<S extends Record<string, FieldConfig<keyof TypeMap>>, P = In
266
266
  getTableSchema(): string;
267
267
  syncSchema(force?: boolean): Promise<void>;
268
268
  private getCqlTypeFromCode;
269
+ private convertResultToType;
269
270
  private buildWhereClause;
270
271
  private buildQueryParams;
271
272
  validate(data: any): data is Simplify<A>;
272
273
  getValidationErrors(data: any): z.ZodError | null;
273
- private convertResultToType;
274
274
  findAll(partitionFields: Simplify<P>, clusteringFields?: Simplify<Partial<C>>): Promise<Simplify<A>[]>;
275
275
  findOne(partitionFields: Simplify<P>, clusteringFields?: Simplify<Partial<C>>): Promise<Simplify<A> | null>;
276
276
  create(data: Simplify<P & Partial<NP>>): Promise<void>;
package/dist/mod.js CHANGED
@@ -126,14 +126,14 @@ var Model = class {
126
126
  return;
127
127
  }
128
128
  const currentColumns = new Map(
129
- tableInfo.columns.map((col) => [col.name, col])
129
+ tableInfo.columns.map((col) => [col.name.toLowerCase(), col])
130
130
  );
131
131
  const newFields = Object.entries(this.schema).filter(
132
- ([fieldName]) => !currentColumns.has(fieldName)
132
+ ([fieldName]) => !currentColumns.has(fieldName.toLowerCase())
133
133
  );
134
134
  const changes = [];
135
135
  Object.entries(this.schema).forEach(([fieldName, config]) => {
136
- const currentColumn = currentColumns.get(fieldName);
136
+ const currentColumn = currentColumns.get(fieldName.toLowerCase());
137
137
  if (!currentColumn) return;
138
138
  const currentType = this.getCqlTypeFromCode(currentColumn.type.code);
139
139
  const newType = config.type;
@@ -143,7 +143,7 @@ var Model = class {
143
143
  );
144
144
  }
145
145
  const isCurrentPartitionKey = tableInfo.partitionKeys.some(
146
- (key) => key.name === fieldName
146
+ (key) => key.name.toLowerCase() === fieldName.toLowerCase()
147
147
  );
148
148
  if (isCurrentPartitionKey !== config.flags.partitionKey) {
149
149
  changes.push(
@@ -151,7 +151,7 @@ var Model = class {
151
151
  );
152
152
  }
153
153
  const isCurrentClusteringKey = tableInfo.clusteringKeys.some(
154
- (key) => key.name === fieldName
154
+ (key) => key.name.toLowerCase() === fieldName.toLowerCase()
155
155
  );
156
156
  const isClusteringKey = !!config.flags.clusteringKey;
157
157
  if (isCurrentClusteringKey !== isClusteringKey) {
@@ -215,6 +215,18 @@ ${changes.join(
215
215
  }
216
216
  return typeName;
217
217
  }
218
+ // 将查询结果转换为我们的类型
219
+ convertResultToType(result) {
220
+ const converted = {};
221
+ Object.keys(this.schema).forEach((key) => {
222
+ const lowerKey = key.toLowerCase();
223
+ const resultKey = Object.keys(result).find((k) => k.toLowerCase() === lowerKey);
224
+ if (resultKey) {
225
+ converted[key] = result[resultKey];
226
+ }
227
+ });
228
+ return this.zodSchemas.entity.parse(converted);
229
+ }
218
230
  // 构建查询条件
219
231
  buildWhereClause(partitionFields, clusteringFields) {
220
232
  const conditions = [];
@@ -271,14 +283,6 @@ ${changes.join(
271
283
  return error;
272
284
  }
273
285
  }
274
- // 将查询结果转换为我们的类型
275
- convertResultToType(result) {
276
- const converted = {};
277
- Object.keys(this.schema).forEach((key) => {
278
- converted[key] = result[key];
279
- });
280
- return this.zodSchemas.entity.parse(converted);
281
- }
282
286
  // 查询方法
283
287
  async findAll(partitionFields, clusteringFields) {
284
288
  const whereClause = this.buildWhereClause(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imean-cassandra-orm",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "description": "cassandra orm",
5
5
  "keywords": [
6
6
  "cassandra",