Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle unmatched types in permission builder #3712

Merged
merged 5 commits into from
Jan 17, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const PGTypes = {
'double precision',
],
uuid: ['uuid'],
user_defined: [], // default for all other types
};

const boolOperatorsInfo = {
Expand All @@ -44,40 +45,103 @@ const boolOperatorsInfo = {
const columnOperatorsInfo = {
_eq: {
type: 'object',
PGTypes: ['boolean', 'character', 'dateTime', 'numeric', 'uuid'],
PGTypes: [
'boolean',
'character',
'dateTime',
'numeric',
'uuid',
'user_defined',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this list the same for every operator? Would it make sense to extract it to the variable, so that another changes would be done just in the one place?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does seem like there can be a better way to represent this info. Will take a stab at it and request a review

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@beerose Made changes to avoid repetition in the future as well. This was a good catch. Thanks.

],
},
_ne: {
type: 'object',
PGTypes: ['boolean', 'character', 'dateTime', 'numeric', 'uuid'],
PGTypes: [
'boolean',
'character',
'dateTime',
'numeric',
'uuid',
'user_defined',
],
},
_in: {
type: 'array',
PGTypes: ['boolean', 'character', 'dateTime', 'numeric', 'uuid'],
PGTypes: [
'boolean',
'character',
'dateTime',
'numeric',
'uuid',
'user_defined',
],
},
_nin: {
type: 'array',
PGTypes: ['boolean', 'character', 'dateTime', 'numeric', 'uuid'],
PGTypes: [
'boolean',
'character',
'dateTime',
'numeric',
'uuid',
'user_defined',
],
},
_gt: {
type: 'object',
PGTypes: ['boolean', 'character', 'dateTime', 'numeric', 'uuid'],
PGTypes: [
'boolean',
'character',
'dateTime',
'numeric',
'uuid',
'user_defined',
],
},
_lt: {
type: 'object',
PGTypes: ['boolean', 'character', 'dateTime', 'numeric', 'uuid'],
PGTypes: [
'boolean',
'character',
'dateTime',
'numeric',
'uuid',
'user_defined',
],
},
_gte: {
type: 'object',
PGTypes: ['boolean', 'character', 'dateTime', 'numeric', 'uuid'],
PGTypes: [
'boolean',
'character',
'dateTime',
'numeric',
'uuid',
'user_defined',
],
},
_lte: {
type: 'object',
PGTypes: ['boolean', 'character', 'dateTime', 'numeric', 'uuid'],
PGTypes: [
'boolean',
'character',
'dateTime',
'numeric',
'uuid',
'user_defined',
],
},
_is_null: {
type: 'object',
inputType: 'boolean',
PGTypes: ['boolean', 'character', 'dateTime', 'numeric', 'uuid'],
PGTypes: [
'boolean',
'character',
'dateTime',
'numeric',
'uuid',
'user_defined',
],
},
_ceq: {
type: 'object',
Expand Down Expand Up @@ -271,6 +335,10 @@ export const getRootPGType = type => {
}
}

if (!rootType) {
rootType = 'user_defined';
}

return rootType;
};

Expand Down