sasat 0.17.1 → 0.17.2

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.
@@ -73,8 +73,8 @@ export class SasatDBDatasource {
73
73
  async executeQuery(query, fields) {
74
74
  const info = createQueryResolveInfo(this.tableName, fields, this.relationMap, this.tableInfo);
75
75
  const sql = queryToSql(query);
76
- const resultRows = await this.client.rawQuery(sql);
77
76
  this.queryLogger(sql);
77
+ const resultRows = await this.client.rawQuery(sql);
78
78
  return hydrate(resultRows, info);
79
79
  }
80
80
  createIdentifiableExpression(entity) {
@@ -16,15 +16,6 @@ declare type PagingOption = ListQueryOption & {
16
16
  };
17
17
  export declare const createPagingInnerQuery: (tableName: string, tableAlias: string, fields: Fields, option: PagingOption, tableInfo: TableInfo) => Query;
18
18
  export declare const runQuery: (client: SQLExecutor, query: Query, resolveInfo: QueryResolveInfo) => Promise<unknown[]>;
19
- declare type RunFieldQueryArg = {
20
- client: SQLExecutor;
21
- queryOptions: QueryOptions;
22
- tableInfo: TableInfo;
23
- relationMap: RelationMap;
24
- baseTableName: string;
25
- fields: Fields;
26
- };
27
- export declare const runFieldQuery: ({ client, tableInfo, baseTableName, fields, relationMap, queryOptions, }: RunFieldQueryArg) => Promise<unknown[]>;
28
19
  declare type CreatePagingFieldQueryArg = {
29
20
  baseTableName: string;
30
21
  fields: Fields;
@@ -1,9 +1,9 @@
1
- import { createQueryResolveInfo, } from '../dsl/query/createQueryResolveInfo.js';
2
1
  import { QExpr } from '../dsl/factory.js';
3
2
  import { unique } from '../util.js';
4
3
  import { queryToSql } from '../dsl/query/sql/queryToSql.js';
5
4
  import { hydrate, } from '../dsl/query/sql/hydrate.js';
6
5
  import { SELECT_ALIAS_SEPARATOR } from '../dsl/query/sql/nodeToSql.js';
6
+ const notTypeName = (fieldName) => fieldName !== '__typename';
7
7
  export const createQuery = (baseTableName, fields, options, tableInfo, relationMap, context) => {
8
8
  let tableCount = 0;
9
9
  const select = [];
@@ -12,8 +12,9 @@ export const createQuery = (baseTableName, fields, options, tableInfo, relationM
12
12
  table.tableAlias = tableAlias;
13
13
  tableCount++;
14
14
  const info = tableInfo[tableName];
15
- select.push(...unique([...table.fields, ...info.identifiableKeys]).map(it => {
16
- const realName = info.columnMap[it];
15
+ select.push(...unique([...table.fields.filter(notTypeName), ...info.identifiableKeys])
16
+ .map(it => {
17
+ const realName = info.columnMap[it] || it;
17
18
  return QExpr.field(tableAlias, realName, tableAlias + SELECT_ALIAS_SEPARATOR + it);
18
19
  }));
19
20
  return QExpr.table(tableName, Object.entries(table.relations || {}).map(([relationName, table]) => {
@@ -32,7 +33,7 @@ export const createQuery = (baseTableName, fields, options, tableInfo, relationM
32
33
  export const createPagingInnerQuery = (tableName, tableAlias, fields, option, tableInfo) => {
33
34
  const map = tableInfo[tableName].columnMap;
34
35
  return {
35
- select: fields.fields.map(it => QExpr.field(tableAlias, map[it])),
36
+ select: fields.fields.filter(notTypeName).map(it => QExpr.field(tableAlias, map[it])),
36
37
  from: QExpr.table(tableName, [], tableAlias),
37
38
  limit: option.numberOfItem,
38
39
  offset: option.offset,
@@ -48,11 +49,6 @@ export const runQuery = async (client, query, resolveInfo) => {
48
49
  const resultRows = await client.rawQuery(queryToSql(query));
49
50
  return hydrate(resultRows, resolveInfo);
50
51
  };
51
- export const runFieldQuery = async ({ client, tableInfo, baseTableName, fields, relationMap, queryOptions, }) => {
52
- const query = createQuery(baseTableName, fields, queryOptions, tableInfo, relationMap);
53
- const resolveInfo = createQueryResolveInfo(baseTableName, fields, relationMap, tableInfo);
54
- return runQuery(client, query, resolveInfo);
55
- };
56
52
  export const createPagingFieldQuery = ({ baseTableName, fields, queryOption, pagingOption, tableInfo, relationMap, context, }) => {
57
53
  const tableAlias = fields.tableAlias || 't0';
58
54
  const innerQuery = createPagingInnerQuery(baseTableName, tableAlias, fields, pagingOption, tableInfo);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sasat",
3
- "version": "0.17.1",
3
+ "version": "0.17.2",
4
4
  "repository": "https://github.com/yanokunpei/sasat.git",
5
5
  "author": "yanokunpei <ninian138@gmail.com>",
6
6
  "license": "MIT",