• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

panates / postgresql-client / 153d71be-3f57-44f4-80b5-4bcc14c4ad78

01 Jul 2024 08:06AM UTC coverage: 85.684%. Remained the same
153d71be-3f57-44f4-80b5-4bcc14c4ad78

push

circleci

erayhanoglu
Update dependencies

698 of 985 branches covered (70.86%)

Branch coverage included in aggregate %.

2522 of 2773 relevant lines covered (90.95%)

816.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

62.5
/src/data-types/json-type.ts
1
import { DataTypeOIDs } from '../constants.js';
30✔
2
import type { DataMappingOptions } from '../interfaces/data-mapping-options.js';
3
import type { DataType } from '../interfaces/data-type.js';
4

5
export const JsonType: DataType = {
30✔
6
  name: 'json',
7
  oid: DataTypeOIDs.json,
8
  jsType: 'string',
9

10
  parseBinary(v: Buffer, options: DataMappingOptions): string {
11
    const content = v.toString('utf8');
75✔
12
    const fetchAsString = options.fetchAsString && options.fetchAsString.includes(DataTypeOIDs.jsonb);
75!
13
    if (fetchAsString) return content;
75!
14
    return content ? JSON.parse(content) : undefined;
75!
15
  },
16

17
  encodeText(v): string {
18
    if (typeof v === 'object' || typeof v === 'bigint') return JSON.stringify(v);
54!
19
    if (typeof v === 'boolean') return v ? 'true' : 'false';
×
20
    return '' + v;
×
21
  },
22

23
  parseText(v: string, options: DataMappingOptions): object | string | null {
24
    const fetchAsString = options.fetchAsString && options.fetchAsString.includes(DataTypeOIDs.jsonb);
21!
25
    if (fetchAsString) return v;
21!
26
    return v ? JSON.parse(v) : null;
21!
27
  },
28

29
  isType(v: any): boolean {
30
    return v && typeof v === 'object';
9✔
31
  },
32
};
33

34
export const ArrayJsonType: DataType = {
30✔
35
  ...JsonType,
36
  name: '_json',
37
  oid: DataTypeOIDs._json,
38
  elementsOID: DataTypeOIDs.json,
39
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc