Skip to content

Commit

Permalink
Merge pull request #214 from viddagrava/double_precision_datatype
Browse files Browse the repository at this point in the history
adding DataTypeDouble to the core engine
  • Loading branch information
chriskalmar committed Apr 30, 2021
2 parents 41dfa65 + 175bfd1 commit a2ff3d7
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/engine/datatype/dataTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ export const DataTypeFloat = new DataType({
mock: () => casual.double(-2 ^ 10, 2 ^ 10),
});

export const DataTypeDouble = new DataType({
name: 'DataTypeDouble',
description: 'Data type representing double precision values',
/* istanbul ignore next */
mock: () => casual.double(-2 ^ 10, 2 ^ 10),
});

export const DataTypeBoolean = new DataType({
name: 'DataTypeBoolean',
description: 'Data type representing boolean values',
Expand Down
2 changes: 2 additions & 0 deletions src/graphqlProtocol/ProtocolGraphQL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
DataTypeTimeTz,
DataTypeUUID,
DataTypeI18n,
DataTypeDouble,
} from '../engine/datatype/dataTypes';

import { isDataTypeState } from '../engine/datatype/DataTypeState';
Expand Down Expand Up @@ -57,6 +58,7 @@ ProtocolGraphQL.addDataTypeMap(DataTypeID, GraphQLID);
ProtocolGraphQL.addDataTypeMap(DataTypeInteger, GraphQLInt);
ProtocolGraphQL.addDataTypeMap(DataTypeBigInt, GraphQLBigInt);
ProtocolGraphQL.addDataTypeMap(DataTypeFloat, GraphQLFloat);
ProtocolGraphQL.addDataTypeMap(DataTypeDouble, GraphQLFloat);
ProtocolGraphQL.addDataTypeMap(DataTypeBoolean, GraphQLBoolean);
ProtocolGraphQL.addDataTypeMap(DataTypeString, GraphQLString);
ProtocolGraphQL.addDataTypeMap(DataTypeJson, GraphQLJSON);
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ import {
DataTypeInteger,
DataTypeBigInt,
DataTypeFloat,
DataTypeDouble,
DataTypeBoolean,
DataTypeString,
DataTypeJson,
Expand Down Expand Up @@ -205,6 +206,7 @@ export {
DataTypeInteger,
DataTypeBigInt,
DataTypeFloat,
DataTypeDouble,
DataTypeBoolean,
DataTypeString,
DataTypeJson,
Expand Down
3 changes: 3 additions & 0 deletions src/storage-connector/StorageTypePostgres.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
DataTypeInteger,
DataTypeBigInt,
DataTypeFloat,
DataTypeDouble,
DataTypeBoolean,
DataTypeString,
DataTypeJson,
Expand Down Expand Up @@ -43,6 +44,7 @@ import {
StorageDataTypeTimeTz,
StorageDataTypeUUID,
StorageDataTypeI18n,
StorageDataTypeDouble,
} from './storageDataTypes';

import Dataloader from 'dataloader';
Expand Down Expand Up @@ -750,6 +752,7 @@ StorageTypePostgres.addDataTypeMap(DataTypeID, StorageDataTypeBigInt);
StorageTypePostgres.addDataTypeMap(DataTypeInteger, StorageDataTypeInteger);
StorageTypePostgres.addDataTypeMap(DataTypeBigInt, StorageDataTypeBigInt);
StorageTypePostgres.addDataTypeMap(DataTypeFloat, StorageDataTypeNumeric);
StorageTypePostgres.addDataTypeMap(DataTypeDouble, StorageDataTypeDouble);
StorageTypePostgres.addDataTypeMap(DataTypeBoolean, StorageDataTypeBoolean);
StorageTypePostgres.addDataTypeMap(DataTypeString, StorageDataTypeText);
StorageTypePostgres.addDataTypeMap(DataTypeJson, StorageDataTypeJSON);
Expand Down
2 changes: 2 additions & 0 deletions src/storage-connector/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ const upgradeMigrationQuery = (_query, isUpMigration = false) => {
defaultValue = '0';
} else if (type.includes('numeric')) {
defaultValue = '0.0';
} else if (type.includes('double precision')) {
defaultValue = '0.0';
} else if (type.includes('boolean')) {
defaultValue = false;
} else if (type.includes('json') || type.includes('jsonb')) {
Expand Down
9 changes: 9 additions & 0 deletions src/storage-connector/storageDataTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ export const StorageDataTypeNumeric = new StorageDataType({
capabilities: ['in', 'lt', 'lte', 'gt', 'gte', 'ne', 'not_in'],
});

export const StorageDataTypeDouble = new StorageDataType({
name: 'StorageDataTypeDouble',
description: 'Data type representing a double precision value',
nativeDataType: 'double precision',
isSortable: true,
serialize: toFloat,
capabilities: ['in', 'lt', 'lte', 'gt', 'gte', 'ne', 'not_in'],
});

export const StorageDataTypeBoolean = new StorageDataType({
name: 'StorageDataTypeBoolean',
description: 'Data type representing a boolean value',
Expand Down

0 comments on commit a2ff3d7

Please sign in to comment.